Class DifferencesPDFPresenter

All Implemented Interfaces:
NamedExtension, Cloneable

public class DifferencesPDFPresenter extends ExportFilePresenter
This presenter creates a complete comparison PDF for any comparison. The PDF contains all pages of both documents along with a highlighting of all differences. The visual representation is similar to the one of the i-net PDFC GUI.
NOTE: In case you want to redirect the output to a non-file destination, please overwrite the getExportStream() method.
Since:
i-net PDFC 3.0
  • Constructor Details

    • DifferencesPDFPresenter

      public DifferencesPDFPresenter(File rootFolder)
      Creates the presenter
      Parameters:
      rootFolder - the folder to store the comparison results to.
      Throws:
      IllegalStateException - in case there is no 'reporting' plugin available
      Since:
      i-net PDFC 3.0
    • DifferencesPDFPresenter

      public DifferencesPDFPresenter(File target, boolean isFolder)
      Creates the presenter
      Parameters:
      target - the folder or file to store the comparison results to.
      isFolder - if the target is a folder or a file
      Throws:
      IllegalStateException - in case there is no 'reporting' plugin available
      Since:
      i-net PDFC 4.3
    • DifferencesPDFPresenter

      public DifferencesPDFPresenter(OutputStream customStream)
      Creates the presenter.
      CAUTION: Since only a single stream is passed here, this instance must be used only for a single comparison! If used for a batch comparison all created PDFs will be written to this stream without further notice.
      Parameters:
      customStream - the stream to export to.
      Since:
      i-net PDFC 5.0
    • DifferencesPDFPresenter

      protected DifferencesPDFPresenter() throws IllegalStateException
      Shortcut to better support spawn for extended classes
      Throws:
      IllegalStateException - thrown if there is no active 'reporting' plugin available
      Since:
      i-net PDFC 4.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
    • getExportStream

      protected OutputStream getExportStream() throws IOException
      Opens an returns an output stream for the result of the current BasePresenter.getModel(). The caller of this method will close the stream itself!
      Overrides:
      getExportStream in class ExportFilePresenter
      Returns:
      the stream to write the current result to
      Throws:
      IOException - thrown in case the stream could not be created
    • onComparisonDone

      public void onComparisonDone() throws Exception
      Creates the actual result PDF 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
    • setPassword

      public void setPassword(String password)
      Set the password for the exported file
      Parameters:
      password - the pdf password, null or empty for no password
      Since:
      i-net PDFC 21.4
    • getExtension

      protected String getExtension()
      Get the extension of the target file
      Specified by:
      getExtension in class ExportFilePresenter
      Returns:
      the file extension like .pdf or .png
    • setReplaceSystemFonts

      public void setReplaceSystemFonts(boolean replace)
      Sets whether system font references should be replaced by embedded PDF default fonts. E.g. a reference to a 'Arial' font may not work when displayed on Unix. Since some system fonts are not allowed to be embedded, the export will replace them by PDF default fonts like 'Helvetica'. This may result in visual differences but generates a consistent result for any viewer.
      Parameters:
      replace - true to replace the fonts, false to use system font references
      Since:
      i-net PDFC 22.4
    • setPagelayout

      public void setPagelayout(int pageWidth, int pageHeight, int marginLeft, int marginTop, int marginRight, int marginBottom)
      Set the desired pageLayout for the pdf to render.
      Parameters:
      pageWidth - the desired with in px, including margins.
      pageHeight - the desired height in px, including margins.
      marginLeft - margins to apply on the left side in px.
      marginTop - margins to apply on top of the page in px.
      marginRight - margins to apply on the right side in px.
      marginBottom - margins to apply on the bottom side in px.
      Since:
      i-net PDFC 3.0