Compare 2 PDF Documents via C++

Hello!
I compared 2 Word documents using C++ Qt.
I need to compare 2 pdf documents
How to do it?

QString sourseFileA = u8"Input1.pdf";
QString sourseFileB = u8"Input2.pdf";
QString destinationFile = u8"Compare.pdf";
auto docA = System::MakeObject<Aspose::Pdf::Document>( System::String( sourseFileA.toStdString() ) );
auto docB = System::MakeObject<Aspose::Pdf::Document>( System::String( sourseFileB.toStdString() ) );

docA->Compare(docB, u"Author Name", time(0));
docA->Save( System::String( destinationFile.toStdString() ) );

no function: Compare()?

There is code for C# in the example

using Aspose.Words;

var docA = new Document("Input1.pdf");
var docB = new Document("Input2.pdf");

// Перед сравнением не должно быть ревизий.
docA.AcceptAllRevisions();
docB.AcceptAllRevisions();

docA.Compare(docB, "Author Name", DateTime.Now);
docA.Save("Output.pdf");

@PiterG In your code you are using Aspose.Pdf.Document, but in the C# example Aspose.Words.Document is used. Aspose.PDF and Aspose.Words are different products.
Unfortunately, C++ version of Aspose.Words does not support PDF as load format. This feature is supported only in .NET and Python versions of Aspose.Words.

OK. I thought so. Thank you.

1 Like

Aspose.Words does not support PDF as an upload format in .net. ??? The example does not work in .net.
String var docA = new Document("Input1.pdf"); - reads incorrectly.
It is enough to check:

var docA = new Document("Input1.pdf");
docA.Save("Output.pdf");]

Other formats work correctly in .net.

@PiterG Please note, Aspose.Words is designed to work with MS Word documents. MS Word documents are flow documents and they have structure very similar to Aspose.Words Document Object Model. On the other hand PDF documents are fixed page format documents . While loading PDF document, Aspose.Words converts Fixed Page Document structure into the Flow Document Object Model. Unfortunately, such conversion does not guaranty 100% fidelity. So it is not always possible to retain PDF document layout after processing it using Aspose.Words.

But these documents compare:
https://products.aspose.app/pdf/comparison

I am conducting an assessment of the library for the customer. I have to offer a library that allows you to compare PDF files.

@PiterG Aspose.Words for .NET and Python allows comparing PDF documents, but with the above mentioned limitations.
Regarding https://products.aspose.app/pdf/comparison app, my colleagues from Aspose.PDF team will answer you shortly.

The problem is solved. Thanks for the tips and keeping the conversation going)

I would be grateful for the hint. Maybe I’ll improve my solution.

@PiterG

Its good to know that you were able to implement the solution. Furthermore, please note that free online Aspose Apps are mixture of different Aspose Products and in order to get the code snippet or hints about the approach implemented behind them, you can please create an inquiry in the respective forums. You will be assisted there accordingly.

Thanks for the answer.