Show / Hide Table of Contents

Class PDFComparer

Compares two different PDFs.

Inheritance
System.Object
PDFComparer
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: ComparePDF
Assembly: ComparePDF.dll
Syntax
public class PDFComparer

Constructors

| Improve this Doc View Source

PDFComparer(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.

| Improve this Doc View Source

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 Source

Hash

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 Source

ComparePDFByHash()

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.

| Improve this Doc View Source

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

True if the embedded files hash matches.

| Improve this Doc View Source

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

True if the embedded files hash matches.

| Improve this Doc View Source

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
true
if the PDF texts are the same.
  • Improve this Doc
  • View Source
Back to top Generated by DocFX