Class Optimizer


  • public class Optimizer
    extends NativeObject

    The class to optimize PDF documents

    • Constructor Detail

      • Optimizer

        public Optimizer()
    • Method Detail

      • optimizeDocument

        public Document optimizeDocument​(Document inDoc,
                                         Stream outStream,
                                         Profile profile)
                                  throws java.io.IOException,
                                         GenericException,
                                         LicenseException,
                                         ProcessingException

        Optimize the PDF document

        Parameters:
        inDoc - The input PDF document
        outStream - The stream to which the output PDF is written
        profile - The profile defining the optimization parameters.
        Returns:

        The optimized result PDF, which can be used as a new input for further processing.

        Note that, this object must be disposed before the output stream object (method argument outStream).

        Throws:
        LicenseException - The license check has failed.
        java.lang.IllegalArgumentException - An invalid encryption was specified in outOptions.
        ProcessingException - The processing has failed.
        java.io.IOException - Writing to the output PDF has failed.
        GenericException - A generic error occurred.
        java.lang.IllegalArgumentException - if inDoc is null
        java.lang.IllegalArgumentException - if outStream is null
        java.lang.IllegalArgumentException - if profile is null
      • optimizeDocument

        public Document optimizeDocument​(Document inDoc,
                                         Stream outStream,
                                         Profile profile,
                                         OutputOptions outOptions)
                                  throws java.io.IOException,
                                         GenericException,
                                         LicenseException,
                                         ProcessingException

        Optimize the PDF document

        Parameters:
        inDoc - The input PDF document
        outStream - The stream to which the output PDF is written
        profile - The profile defining the optimization parameters.
        outOptions - The PDF output options, e.g. to encrypt the output document.
        Returns:

        The optimized result PDF, which can be used as a new input for further processing.

        Note that, this object must be disposed before the output stream object (method argument outStream).

        Throws:
        LicenseException - The license check has failed.
        java.lang.IllegalArgumentException - An invalid encryption was specified in outOptions.
        ProcessingException - The processing has failed.
        java.io.IOException - Writing to the output PDF has failed.
        GenericException - A generic error occurred.
        java.lang.IllegalArgumentException - if inDoc is null
        java.lang.IllegalArgumentException - if outStream is null
        java.lang.IllegalArgumentException - if profile is null