Class PDFComparer
Compares two different PDFs.
Inheritance
Inherited Members
Namespace: ComparePDF
Assembly: ComparePDF.dll
Syntax
public class PDFComparer
Constructors
| Improve this Doc View SourcePDFComparer(String, String)
Initializes a new instance of the PDFComparer class.
Declaration
public PDFComparer(string pdfFilePath1, string pdfFilePath2)
Parameters
Type | Name | Description |
---|---|---|
System.String | pdfFilePath1 | Sets the file path to the first PDF. |
System.String | pdfFilePath2 | Sets the file path to the second PDF. |
PDFComparer(String, String, ILogger)
Initializes a new instance of the PDFComparer class.
Declaration
public PDFComparer(string pdfFilePath1, string pdfFilePath2, ILogger logger)
Parameters
Type | Name | Description |
---|---|---|
System.String | pdfFilePath1 | Sets the file path to the first PDF. |
System.String | pdfFilePath2 | Sets the file path to the second PDF. |
Microsoft.Extensions.Logging.ILogger | logger | The logger to use throughout the class. |
Properties
| Improve this Doc View SourceHash
Gets or sets the HashAlgorithmName to be used to compare extracted files. Default is set to MD5 hash.
Declaration
public HashAlgorithmName Hash { get; set; }
Property Value
Type | Description |
---|---|
System.Security.Cryptography.HashAlgorithmName |
Methods
| Improve this Doc View SourceComparePDFByHash()
Compares two PDFS by the set hash algorithm name.
Declaration
public bool ComparePDFByHash()
Returns
Type | Description |
---|---|
System.Boolean | True if the hash are the same. |
ComparePDFEmbeddedFiles(String)
Compares the embedded files inside the PDF through extraction and hashing.
Declaration
public bool ComparePDFEmbeddedFiles(string resultZipFile)
Parameters
Type | Name | Description |
---|---|---|
System.String | resultZipFile | Zip file that contains the extracted files. |
Returns
Type | Description |
---|---|
System.Boolean |
|
ComparePDFImages(String)
Compares the images inside the PDF through extraction and hashing.
Declaration
public bool ComparePDFImages(string resultZipFile)
Parameters
Type | Name | Description |
---|---|---|
System.String | resultZipFile | The zip file representing the images extracted. |
Returns
Type | Description |
---|---|
System.Boolean |
|
ComparePDFText(String, (String regex, String replacement), Boolean, Boolean)
We extract the text from the PDFs provided. We compare the text based on the arguements provided. We ignore whitespaces by default.
Declaration
public bool ComparePDFText(string resultFilePath, (string regex, string replacement) regexReplacement = default((string regex, string replacement)), bool caseInsensitive = false, bool ignoreWhitespace = true)
Parameters
Type | Name | Description |
---|---|---|
System.String | resultFilePath | Name of the file for PDF text comparison. |
System.ValueTuple<System.String, System.String> | regexReplacement | (REGEX, REPLACEMENT) -> A 2-Tuple string for the regex and replacement. |
System.Boolean | caseInsensitive | Toggle when comparing extracted text. Default to be false. |
System.Boolean | ignoreWhitespace | Toggle when comparing extracted text. Default to be true. |
Returns
Type | Description |
---|---|
System.Boolean | if the PDF texts are the same.
|