Compare two PDFs

Product:
pdfnet-node
Product Version:
9.2

Does PDFTron provide a way to compare two PDF documents to programmatically determine if they are identical? I have read the documentation on the semantic compare feature that generates PDFs that visually highlight differences - PDFTron - but I am just looking for a simple way to load two PDFs in a test and determine if their content is identical.

One approach I have tried is simply loading two files using fs.readFileSync, and then using Buffer.compare. If I take a PDF and make a copy of it with a different name, and use this approach Buffer.compare returns 0 indicating the two files are identical. However, this is not the case if I use PDFTron to convert the same Word doc to a PDF twice, and then compare the buffers using the following technique. Why is that? Shouldn’t the two files be identical?

    const docx = fs.readFileSync(inputPath);
    const pdf = await PDFNet.Convert.office2PDFBuffer(docx);
    const pdfBuffer = Buffer.from(pdf);
    
    const pdf2 = await PDFNet.Convert.office2PDFBuffer(docx);
    const pdfBuffer2 = Buffer.from(pdf2);
    
    console.log(Buffer.compare(pdfBuffer, pdfBuffer2)); // never 0 as expected

Thanks, Dan

Can anyone help me to integrate with angularJS compare PDF.Please provide steps

Just discovered that the highlightTextDiff function returns a count of differences, so am giving that a try. Unfortunately it doesn’t seem to provide accurate results. When I compare two completely different documents I only get a diff count of 1. I also tried comparing two documents that have their page order reversed, and I get 0 differences.