We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Set pdf trailer contents in pdf export of Aspose.Word

Hi,

I recently upgraded to the latest Aspose.Words library and noticed that the \ID section was added to the pdf trailer when I save a document as pdf. This ID is a unique value at every save/export. Since I am comparing generated documents with expected documents in a regression test, this is annoying.
Is there a way to skip or modify the ID in the trailer?

@chrisv

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output PDF file that shows the undesired behavior.
  • Please attach the expected output PDF file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Dear Tahir,

Thanks for your quick response. I do not think this is a bug, but a feature.
Until recently we used version 14.4.0.0 of Aspose.Words, and generated the attached file Test (Version 14.4.0.0).pdf with it.
We upgraded to version 21.8.0.0, with file Test(Version 21.8.0.0).pdf as a result.

If I open this file in a text editor, I notice that:

  • the pdf version is updated from 1.5 to 1.7
  • in the trailer, the following code was added:

<</Type /XRef/W [1 4 2]/Size 15/Info 1 0 R/Root 2 0 R/ID []/Length 105>>

, where ID changes everytime I create a new document. And exactly this feature makes my regression test not working, since I want to compare the new document with an expected document (with a set ID, that differs by default). I do this comparison with a string compare of base64 strings of both documents.

Now my question is whether it is possible to skip the generation/inclusion of the ID in the document, or (otherwise) override it by setting my own ID.pdf.zip (24.2 KB)

@chrisv

PDF version 1.5 is outdated and will be removed in future releases. If you save the document to PDF using MS Word 2019, the PDF version will be 1.7.

Unfortunately, Aspose.Words does not provide APIs to set the ID. Aspose.Words mimics the behavior of MS Word. If you save the same document to PDF multiple times, the ID will not be same.