Class DifferencesImagePresenter

java.lang.Object
com.inet.pdfc.presenter.BasePresenter
com.inet.pdfc.presenter.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 Details

    • 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(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 Details

    • getExtensionName

      public 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
    • configure

      public DifferencesImagePresenter configure(IProfile profile)
      Configures the presenter according to a profile. The presenter will read the property PDFCProperty.IMAGE_SCALE_FACTOR from the profile.
      Overrides:
      configure in class BasePresenter
      Parameters:
      profile - the profile to read from, must not be null
      Returns:
      this instance for concatenation
      Since:
      i-net PDFC 3.0
    • 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:
      IllegalArgumentException - if scale is <= 0
      Since:
      i-net PDFC 3.0
    • onInit

      public void onInit() throws 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:
      Exception - not thrown in this implementation
      IOException - in case the destination folder cannot be accessed or created
      Since:
      i-net PDFC 3.0
    • onComparisonDone

      public void onComparisonDone() throws 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:
      Exception - thrown in case the processing of the finish step fails
      Since:
      i-net PDFC 3.0
    • writeDifferencesImage

      protected void writeDifferencesImage(int pageIndex, 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, 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
    • getConfigSetting

      @Deprecated public static DifferencesImagePresenter.IMAGE_CONFIG getConfigSetting(IProfile config)
      Deprecated.
      As of i-net PDFC 5.0 , the property will be stored in settings Settings.EXPORT.CREATE_DIFFIMAGES_FIRST and Settings.EXPORT.CREATE_DIFFIMAGES_SECOND
      Returns the image paint type as defined by the configuration
      Parameters:
      config - the configuration to read
      Returns:
      the defined image paint type
      Since:
      i-net PDFC 3.0