### PdfCompare CLI Help Source: https://github.com/red6/pdfcompare/blob/master/README.md When running the PdfCompare JAR without arguments, it starts an interactive UI. Alternatively, it can be used via the command line with expected and actual files. Use the -h or --help option to display usage information. ```shell usage: java -jar pdfcompare-x.x.x-full.jar [EXPECTED] [ACTUAL] -h,--help Displays this text and exit ... ``` -------------------------------- ### Apply Ignore File to Comparison Source: https://github.com/red6/pdfcompare/blob/master/README.md Integrate an ignore configuration file into the PDF comparison process by passing its path to the `withIgnore` method. ```java new PdfComparator("expected.pdf", "actual.pdf").withIgnore("ignore.conf").compare(); ``` -------------------------------- ### PdfCompare Configuration Options Source: https://github.com/red6/pdfcompare/blob/master/README.md Lists and describes the various configuration options available for PdfCompare, which can be set via configuration files or programmatically through the API. These options control rendering DPI, colors, temporary directories, difference percentages, and processing behavior. ```APIDOC PdfCompare Configuration Options: Configuration can be managed via application.conf, system properties (-D), environment variables, or programmatically. - DPI - Description: Sets the DPI (dots per inch) that PDF pages are rendered with. - Default: 300 - expectedColor - Description: The color used for pixels that were expected but are missing. Specified in HTML-style format (e.g., RRGGBB). - Example Value: 00B400 (GREEN) - Default: D20000 (RED) - actualColor - Description: The color used for pixels that are present but were not expected. Specified in HTML-style format (e.g., RRGGBB). - Example Value: D20000 (RED) - Default: 00B400 (GREEN) - tempDir - Description: Sets the directory where temporary files are written. - Default: System.property("java.io.tmpdir") (e.g., /tmp on Unix-like systems) - allowedDifferenceInPercentPerPage - Description: The percentage of pixels that may differ per page before a difference is reported. Calculated per page. - Default: 0.0 - parallelProcessing - Description: Controls whether parallel processing is enabled. - Default: true - addEqualPagesToResult - Description: Determines if pages without differences are included in the result PDF. - Default: true - failOnMissingIgnoreFile - Description: If true, a missing ignore file will cause an exception; otherwise, it results in an info-level log message. - Default: false ``` -------------------------------- ### PdfCompare Configuration Options (application.conf) Source: https://github.com/red6/pdfcompare/blob/master/README.md Lists and describes various configuration parameters that can be set in an application.conf file to control PdfCompare's behavior, including caching, timeouts, and parallel processing. These settings allow fine-tuning of memory usage and performance. ```APIDOC application.conf Settings: - imageCacheSizeCount: How many images are cached by PdfBox. - Default: 30 - maxImageSizeInCache: A rough maximum size of images that are cached, to prevent very big images from being cached. - Default: 100000 - mergeCacheSizeMB: Memory cache configured for the PdfBox instance that merges partially written PDFs. - Default: 100 - swapCacheSizeMB: Memory cache configured for the PdfBox instance that performs partial writes. - Default: 100 - documentCacheSizeMB: Cache size configured for the PdfBox instance that loads documents for comparison. - Default: 200 - parallelProcessing: When set to false, disables all parallel processing and processes everything in a single thread. - Default: true - overallTimeoutInMinutes: Sets the overall timeout for comparisons to detect possible deadlocks. May need to be increased for complex comparisons. - Default: 15 - executorTimeoutInSeconds: Sets the timeout to wait for executors to finish after the overallTimeout is reached. Rarely needs changing. - Default: 60 ``` -------------------------------- ### Instantiate PdfComparator with Custom Result Strategy Source: https://github.com/red6/pdfcompare/blob/master/README.md Demonstrates how to create a PdfComparator instance, specifying a custom CompareResult implementation like CompareResultWithPageOverflow to manage memory usage when comparing PDF files. ```java new PdfComparator("expected.pdf", "actual.pdf", new CompareResultWithPageOverflow()).compare(); ``` -------------------------------- ### Configure PdfCompare Programmatically with Java API Source: https://github.com/red6/pdfcompare/blob/master/README.md Demonstrates how to configure PdfCompare using its Java API, specifically by setting environment properties like expected and actual colors. The SimpleEnvironment class delegates unassigned settings to the default Environment. ```java new PdfComparator("expected.pdf", "actual.pdf") .withEnvironment(new SimpleEnvironment() .setActualColor(Color.green) .setExpectedColor(Color.blue)) .compare(); ``` -------------------------------- ### Compare PDFs using PdfCompare Library Source: https://github.com/red6/pdfcompare/blob/master/README.md Perform a basic comparison between two PDF files using the PdfComparator. The result is written to a specified output directory, highlighting differences. ```java new PdfComparator("expected.pdf", "actual.pdf").compare().writeTo("diffOutput"); ``` -------------------------------- ### Compare Encrypted PDF Files Source: https://github.com/red6/pdfcompare/blob/master/README.md Handle password-protected PDF files by providing the respective passwords using `withExpectedPassword` and `withActualPassword` methods before initiating the comparison. ```java new PdfComparator("expected.pdf", "actual.pdf") .withExpectedPassword("somePwd") .withActualPassword("anotherPwd") .compare(); ``` -------------------------------- ### Apply Ignore Areas via API Source: https://github.com/red6/pdfcompare/blob/master/README.md Programmatically define specific page areas to be ignored during comparison using the `PageArea` class and the `withIgnore` method. ```java new PdfComparator("expected.pdf", "actual.pdf") .withIgnore(new PageArea(1, 230, 350, 450, 420)) .withIgnore(new PageArea(2)) .compare(); ``` -------------------------------- ### Define PDF Comparison Ignore Areas (File) Source: https://github.com/red6/pdfcompare/blob/master/README.md Specify rectangular areas to ignore during PDF comparison by creating a HOCON/JSON configuration file. If the file is not found, it's ignored. ```json exclusions: [ { page: 2 x1: 300 // entries without a unit are in pixels. Pdfs are rendered by default at 300DPI y1: 1000 x2: 550 y2: 1300 }, { // page is optional. When not given, the exclusion applies to all pages. x1: 130.5mm // entries can also be given in units of cm, mm or pt (DTP-Point defined as 1/72 Inches) y1: 3.3cm x2: 190mm y2: 3.7cm }, { page: 7 // coordinates are optional. When not given, the whole page is excluded. } ] ``` -------------------------------- ### WriteTo Method Return Value Source: https://github.com/red6/pdfcompare/blob/master/README.md The `writeTo` method conveniently returns a boolean indicating whether the PDFs were equal after comparison, simplifying conditional logic. ```java boolean isEquals = new PdfComparator("expected.pdf", "actual.pdf").compare().writeTo("diffOutput"); if (!isEquals) { System.out.println("Differences found!"); } ``` -------------------------------- ### Add PdfCompare Maven Dependency Source: https://github.com/red6/pdfcompare/blob/master/README.md Include the PdfCompare library in your Maven project by adding the following dependency to your pom.xml. Always check Maven Central for the latest version. ```xml de.redsix pdfcompare ... ``` -------------------------------- ### Check PDF Comparison Results Source: https://github.com/red6/pdfcompare/blob/master/README.md After comparing PDFs, you can inspect the CompareResult object to determine if differences were found, if they were in excluded areas, or to retrieve specific difference locations. ```java final CompareResult result = new PdfComparator("expected.pdf", "actual.pdf").compare(); if (result.isNotEqual()) { System.out.println("Differences found!"); } if (result.isEqual()) { System.out.println("No Differences found!"); } if (result.hasDifferenceInExclusion()) { System.out.println("Differences in excluded areas found!"); } result.getDifferences(); // returns page areas, where differences were found ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.