Class Documents4jRemoteServices

java.lang.Object
org.docx4j.documents4j.remote.Documents4jRemoteServices
All Implemented Interfaces:
Exporter<Documents4jConversionSettings>

public class Documents4jRemoteServices
extends java.lang.Object
implements Exporter<Documents4jConversionSettings>
Import/update/export docx/xlsx using Documents4j, with Microsoft Word running on a remote server. You can use this to export to PDF, or to update your ToC. It can also import binary .doc or RTF. The easiest way to set up documents4j on a remote server is to build it from https://github.com/documents4j/documents4j using maven, then in documents4j-server-standalone, create a shaded jar using profile shaded-jar. Note: to update ToC, you'll need a custom script in documents4j on your remote server. You can update the script documents4j provides, or you can create a new one, and in the server code, point to it using System.setProperty com.documents4j.conversion.msoffice.word_convert.vbs
Since:
8.2.0
Author:
jharrop
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected static Documents4jRemoteServices instance  
  • Constructor Summary

    Constructors 
    Constructor Description
    Documents4jRemoteServices()
    Configure the converter with default settings.
    Documents4jRemoteServices​(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, long timeout)
    Configures a worker pool for the converter.
  • Method Summary

    Modifier and Type Method Description
    void export​(java.io.File officeFile, java.io.OutputStream target, com.documents4j.api.DocumentType documentType)
    Export docx or xlsx file as PDF
    void export​(java.io.File officeFile, java.io.OutputStream target, com.documents4j.api.DocumentType documentType, com.documents4j.api.DocumentType asDocumentType)
    Export docx or xlsx file as specified com.documents4j.api.DocumentType
    void export​(Documents4jConversionSettings conversionSettings, java.io.OutputStream outputStream)
    Export to outputStream as PDF.
    void export​(OpcPackage pkg, java.io.OutputStream outputStream)
    Export WordprocessingMLPackage or SpreadsheetMLPackage as PDF
    void export​(OpcPackage pkg, java.io.OutputStream outputStream, com.documents4j.api.DocumentType asDocumentType)
    Export WordprocessingMLPackage or SpreadsheetMLPackage as specified com.documents4j.api.DocumentType
    static Exporter<Documents4jConversionSettings> getInstance()  
    WordprocessingMLPackage importAsDocx​(java.io.File officeFile)
    Import as a docx from one of the other file types supported by Word.
    void importAsDocx​(java.io.File officeFile, java.io.OutputStream target)
    Import as a docx from one of the other file types supported by Word.
    void updateDocx​(java.io.File officeFile, java.io.OutputStream target)
    Run the script to update the docx (eg ToC).
    WordprocessingMLPackage updateDocx​(WordprocessingMLPackage pkg)
    Run the script to update the docx (eg ToC).
    void updateDocx​(WordprocessingMLPackage pkg, java.io.OutputStream outputStream)
    Run the script to update the docx (eg ToC).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Documents4jRemoteServices

      public Documents4jRemoteServices()
      Configure the converter with default settings.
    • Documents4jRemoteServices

      public Documents4jRemoteServices​(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, long timeout)
      Configures a worker pool for the converter. This worker pool implicitly sets a maximum number of conversions that are concurrently undertaken by the resulting converter. When a converter is requested to concurrently execute more conversions than maximumPoolSize, it will queue excess conversions until capacities are available again.

       

      If this number is set too low, the concurrent performance of the resulting converter will be weak compared to a higher number. If this number is set too high, the converter might overheat when accessing the underlying external resource (such as for example an external process or a HTTP connection). A remote converter that shares a conversion server with another converter might also starve these other remote converters.
      Parameters:
      corePoolSize - The core pool size of the worker pool.
      maximumPoolSize - The maximum pool size of the worker pool.
      keepAliveTime - The keep alive time of the worker pool.
      unit - The time unit of the specified keep alive time.
      timeout - The timeout for a network request (in ms).
  • Method Details