com.groupdocs.assembly

Class DocumentAssembler

  • java.lang.Object
    • com.groupdocs.assembly.DocumentAssembler


  • public class DocumentAssembler
    extends java.lang.Object
    Provides routines to populate template documents with data and a set of settings to control these routines.
    • Constructor Summary

      Constructors 
      Constructor and Description
      DocumentAssembler()
      Initializes a new instance of this class.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void assembleDocument(java.io.InputStream sourceStream, java.io.OutputStream targetStream, java.lang.Object dataSource)
      Loads a template document from the specified source stream, populates the template document with data from the specified source, and stores the result document to the target stream.
      void assembleDocument(java.io.InputStream sourceStream, java.io.OutputStream targetStream, java.lang.Object[] dataSources, java.lang.String[] dataSourceNames)
      Loads a template document from the specified source stream, populates the template document with data from the specified sources, and stores the result document to the target stream.
      void assembleDocument(java.io.InputStream sourceStream, java.io.OutputStream targetStream, java.lang.Object dataSource, java.lang.String dataSourceName)
      Loads a template document from the specified source stream, populates the template document with data from the specified source, and stores the result document to the target stream.
      void assembleDocument(java.lang.String sourcePath, java.lang.String targetPath, java.lang.Object dataSource)
      Loads a template document from the specified source path, populates the template document with data from the specified source, and stores the result document to the target path.
      void assembleDocument(java.lang.String sourcePath, java.lang.String targetPath, java.lang.Object[] dataSources, java.lang.String[] dataSourceNames)
      Loads a template document from the specified source path, populates the template document with data from the specified sources, and stores the result document to the target path.
      void assembleDocument(java.lang.String sourcePath, java.lang.String targetPath, java.lang.Object dataSource, java.lang.String dataSourceName)
      Loads a template document from the specified source path, populates the template document with data from the specified source, and stores the result document to the target path.
      BarcodeSettings getBarcodeSettings()
      Gets a set of settings controlling barcode generation while assembling a document.
      KnownTypeSet getKnownTypes()
      Gets an unordered set (that is, a collection of unique items) containing Class objects which fully or partially qualified names can be used within document templates processed by this assembler instance to invoke the corresponding types' static members, perform type casts, etc.
      int getOptions()
      Gets a set of flags controlling behavior of this DocumentAssembler instance while assembling a document.
      static boolean getUseReflectionOptimization()
      Gets a value indicating whether invocations of custom type members performed via reflection API are optimized using dynamic class generation or not.
      void setOptions(int value)
      Sets a set of flags controlling behavior of this DocumentAssembler instance while assembling a document.
      static void setUseReflectionOptimization(boolean value)
      Sets a value indicating whether invocations of custom type members performed via reflection API are optimized using dynamic class generation or not.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DocumentAssembler

        public DocumentAssembler()
        Initializes a new instance of this class.
    • Method Detail

      • assembleDocument

        public void assembleDocument(java.lang.String sourcePath,
                                     java.lang.String targetPath,
                                     java.lang.Object dataSource)
                              throws java.lang.Exception
        Loads a template document from the specified source path, populates the template document with data from the specified source, and stores the result document to the target path. Using this overload you can reference the data source's members in the template document, but you can not reference the data source object itself. You should use the assembleDocument(java.lang.String, java.lang.String, java.lang.Object, java.lang.String) overload to achieve this.
        Parameters:
        sourcePath - The path of a template document to be populated with data.
        targetPath - The path of a result document.
        dataSource - A data source object.
        Throws:
        java.lang.Exception
      • assembleDocument

        public void assembleDocument(java.lang.String sourcePath,
                                     java.lang.String targetPath,
                                     java.lang.Object dataSource,
                                     java.lang.String dataSourceName)
                              throws java.lang.Exception
        Loads a template document from the specified source path, populates the template document with data from the specified source, and stores the result document to the target path. Using this overload you can reference the data source's members and the data source object itself in the template. If you are not going to reference the data source object itself, you can omit dataSourceName passing null or use the assembleDocument(java.lang.String, java.lang.String, java.lang.Object) overload.
        Parameters:
        sourcePath - The path of a template document to be populated with data.
        targetPath - The path of a result document.
        dataSource - A data source object.
        dataSourceName - A name to reference the data source object in the template.
        Throws:
        java.lang.Exception
      • assembleDocument

        public void assembleDocument(java.lang.String sourcePath,
                                     java.lang.String targetPath,
                                     java.lang.Object[] dataSources,
                                     java.lang.String[] dataSourceNames)
                              throws java.lang.Exception
        Loads a template document from the specified source path, populates the template document with data from the specified sources, and stores the result document to the target path.

        Using this overload you can reference multiple data source objects and their members in the template. The name of the first data source can be omitted (i.e. be an empty string or null) if you are going to reference the data source's members but not the data source object itself. Names of the other data sources must be specified and unique.

        If you are going to use a single data source, consider using of assembleDocument(java.lang.String, java.lang.String, java.lang.Object) and assembleDocument(java.lang.String, java.lang.String, java.lang.Object, java.lang.String) overloads instead.

        Parameters:
        sourcePath - The path of a template document to be populated with data.
        targetPath - The path of a result document.
        dataSources - An array of data source objects.
        dataSourceNames - An array of names to reference the data source objects within the template.
        Throws:
        java.lang.Exception
      • assembleDocument

        public void assembleDocument(java.io.InputStream sourceStream,
                                     java.io.OutputStream targetStream,
                                     java.lang.Object dataSource)
                              throws java.lang.Exception
        Loads a template document from the specified source stream, populates the template document with data from the specified source, and stores the result document to the target stream. Using this overload you can reference the data source's members in the template document, but you can not reference the data source object itself. You should use the assembleDocument(java.io.InputStream, java.io.OutputStream, java.lang.Object, java.lang.String) overload to achieve this.
        Parameters:
        sourceStream - The stream to read a template document from.
        targetStream - The stream to write a result document.
        dataSource - A data source object.
        Throws:
        java.lang.Exception
      • assembleDocument

        public void assembleDocument(java.io.InputStream sourceStream,
                                     java.io.OutputStream targetStream,
                                     java.lang.Object dataSource,
                                     java.lang.String dataSourceName)
                              throws java.lang.Exception
        Loads a template document from the specified source stream, populates the template document with data from the specified source, and stores the result document to the target stream. Using this overload you can reference the data source's members and the data source object itself in the template. If you are not going to reference the data source object itself, you can omit dataSourceName passing null or use the assembleDocument(java.io.InputStream, java.io.OutputStream, java.lang.Object) overload.
        Parameters:
        sourceStream - The stream to read a template document from.
        targetStream - The stream to write a result document.
        dataSource - A data source object.
        dataSourceName - A name to reference the data source object in the template.
        Throws:
        java.lang.Exception
      • assembleDocument

        public void assembleDocument(java.io.InputStream sourceStream,
                                     java.io.OutputStream targetStream,
                                     java.lang.Object[] dataSources,
                                     java.lang.String[] dataSourceNames)
                              throws java.lang.Exception
        Loads a template document from the specified source stream, populates the template document with data from the specified sources, and stores the result document to the target stream.

        Using this overload you can reference multiple data source objects and their members in the template. The name of the first data source can be omitted (i.e. be an empty string or null) if you are going to reference the data source's members but not the data source object itself. Names of the other data sources must be specified and unique.

        If you are going to use a single data source, consider using of assembleDocument(java.io.InputStream, java.io.OutputStream, java.lang.Object) and assembleDocument(java.io.InputStream, java.io.OutputStream, java.lang.Object, java.lang.String) overloads instead.

        Parameters:
        sourceStream - The stream to read a template document from.
        targetStream - The stream to write a result document.
        dataSources - An array of data source objects.
        dataSourceNames - An array of names to reference the data source objects within the template.
        Throws:
        java.lang.Exception
      • getOptions

        public int getOptions()
        Gets a set of flags controlling behavior of this DocumentAssembler instance while assembling a document.
        Returns:
        A set of flags controlling behavior of this DocumentAssembler instance while assembling a document. The returned value is a bitwise combination of DocumentAssemblyOptions constants.
      • setOptions

        public void setOptions(int value)
        Sets a set of flags controlling behavior of this DocumentAssembler instance while assembling a document.
        Parameters:
        value - A set of flags controlling behavior of this DocumentAssembler instance while assembling a document. The value must be a bitwise combination of DocumentAssemblyOptions constants.
      • getBarcodeSettings

        public BarcodeSettings getBarcodeSettings()
        Gets a set of settings controlling barcode generation while assembling a document.
        Returns:
        A set of settings controlling barcode generation while assembling a document.
      • getKnownTypes

        public KnownTypeSet getKnownTypes()
        Gets an unordered set (that is, a collection of unique items) containing Class objects which fully or partially qualified names can be used within document templates processed by this assembler instance to invoke the corresponding types' static members, perform type casts, etc.
        Returns:
        An unordered set (that is, a collection of unique items) containing Class objects which fully or partially qualified names can be used within document templates processed by this assembler instance to invoke the corresponding types' static members, perform type casts, etc.
      • getUseReflectionOptimization

        public static boolean getUseReflectionOptimization()
        Gets a value indicating whether invocations of custom type members performed via reflection API are optimized using dynamic class generation or not. The default value is true. There are some scenarios where it is preferrable to disable this optimization. For example, if you are dealing with small collections of data items all the time, then an overhead of dynamic class generation can be more noticeable than an overhead of direct reflection API calls.
        Returns:
        A value indicating whether invocations of custom type members performed via reflection API are optimized using dynamic class generation or not.
      • setUseReflectionOptimization

        public static void setUseReflectionOptimization(boolean value)
        Sets a value indicating whether invocations of custom type members performed via reflection API are optimized using dynamic class generation or not. The default value is true. There are some scenarios where it is preferrable to disable this optimization. For example, if you are dealing with small collections of data items all the time, then an overhead of dynamic class generation can be more noticeable than an overhead of direct reflection API calls.
        Parameters:
        value - A value indicating whether invocations of custom type members performed via reflection API are optimized using dynamic class generation or not.