Class DifferencesImagePresenter

  • All Implemented Interfaces:
    NamedExtension

    public class DifferencesImagePresenter
    extends BasePresenter
    This presenter generates images of all pages as well as side-by-side images of pages with differences. It's recommended to only use this presenter for strict-mode comparisons as it cannot handle content offsets.
    • Constructor Detail

      • DifferencesImagePresenter

        public DifferencesImagePresenter()
        Creates a difference image presenter. The presenter will write difference and page images according to the configuration into sub folders of the 'differences' folder in the current working directory.
        DEFAULT is to print difference images for the first and the second document. To change this, call setCreateDifferenceImages(boolean, boolean, boolean).
        Since:
        i-net PDFC 3.0
      • DifferencesImagePresenter

        public DifferencesImagePresenter​(java.io.File rootFolder)
        Creates a difference image presenter. The presenter will write difference and page images according to the configuration into sub folders of the given root folder.
        Parameters:
        rootFolder - the root folder for all difference folders. must not be null
        Since:
        i-net PDFC 3.0
    • Method Detail

      • getExtensionName

        public java.lang.String getExtensionName()
        Returns the UNIQUE name of the extension. With UNIQUE referring to 'unique among all implementations of the same interface'
        Returns:
        the UNIQUE name of the extension
      • spawn

        public BasePresenter spawn​(boolean spawnWithParent)
        Creates another presenter of the the same type as the current one. The spawned presenter may either have the same settings as the current one or it may be a child of the current one.
        Overrides:
        spawn in class BasePresenter
        Parameters:
        spawnWithParent - if true, the presenter is allowed to keep a reference to it's parent to create a summary on onFinish()
        Returns:
        a new presenter for the same batch comparison run as the current one
      • setCreateDifferenceImages

        @Deprecated
        public void setCreateDifferenceImages​(boolean forFirstDocument,
                                              boolean forSecondDocument,
                                              boolean xorOfDocuments)
        Sets what should be content of the differences images per page. This setter permanently OVERRIDES the values of the profile for this instnace!
        Parameters:
        forFirstDocument - set to include the page of the first document
        forSecondDocument - set to include the page of the second document
        xorOfDocuments - set to include an XOR-image of the pages pair
        Since:
        i-net PDFC 3.0
      • setCreatePageImages

        @Deprecated
        public void setCreatePageImages​(boolean createPageImages)
        Deprecated.
        Enables or disables the output of plain page images. This setter permanently OVERRIDES the values of the profile for this instance!
        Parameters:
        createPageImages - true to enable
        Since:
        i-net PDFC 3.0
      • setImageScaleFactor

        public void setImageScaleFactor​(double scale)
        Sets the scale factor for all produced images.
        This setter permanently OVERRIDES the values of the profile for this instance!
        Parameters:
        scale - the (positive) scale factor
        Throws:
        java.lang.IllegalArgumentException - if scale is <= 0
        Since:
        i-net PDFC 3.0
      • onInit

        public void onInit()
                    throws java.lang.Exception
        Creates the root and the subfolder for the current comparison run.
        IT IS RECOMMENDED TO OVERWRITE THIS METHOD in case the output destination is changed!
        Overrides:
        onInit in class BasePresenter
        Throws:
        java.lang.Exception - not thrown in this implementation
        java.io.IOException - in case the destination folder cannot be accessed or created
        Since:
        i-net PDFC 3.0
      • onComparisonDone

        public void onComparisonDone()
                              throws java.lang.Exception
        Called to indicate that a comparison has finished. This does not imply that any page data or differences are available.
        Specified by:
        onComparisonDone in class BasePresenter
        Throws:
        java.lang.Exception - thrown in case the processing of the finish step fails
        Since:
        i-net PDFC 3.0
      • writeDifferencesImage

        protected void writeDifferencesImage​(int pageIndex,
                                             java.awt.image.BufferedImage targetImg)
        Writes a differences image. Override this method to implement different storage types, destinations or image encoders.
        Parameters:
        pageIndex - the zero based index of the page pair presented in the image
        targetImg - the rendered difference image, never null
        Since:
        i-net PDFC 3.0
      • writePageImage

        protected void writePageImage​(int pageIndex,
                                      boolean isFirstPDF,
                                      java.awt.image.BufferedImage pageImage)
        Writes the image of a rendered page. This method will be called for any page in either document if the property PDFCProperty.CREATE_ORIGIMAGES is set to 'true'.
        Parameters:
        pageIndex - the zero-based index of the page
        isFirstPDF - true, if the page belongs to the first document hence false
        pageImage - the image of the page, unscaled
        Since:
        i-net PDFC 3.0