Bug: LinkDuplcateStreams links streams that are not duplicates

See the attached PDFs. The document was optimized with LinkDuplicateStreams = false and saved as FDB3000278_3244779.pdf. It was then optimized with LinkDuplicateStreams = true and saved as FDB3000278_3244779_1.pdf

Page 19 of the PDFs came out different. In the PDF saved with LinkDuplicateStreams = true page 19 is a replica of page 17. However, the names that should have been listed on page 17 and 19 are not the same (“TEST ONE” and “TEST TWO”).

Edit: For reference, I’m using version 18.1.

 pdfDocument.OptimizeResources(new Document.OptimizationOptions()
        {
            LinkDuplcateStreams = false,
            RemoveUnusedObjects = true,
            RemoveUnusedStreams = true
        });
pdfDocument.Save(destination);


 pdfDocument.OptimizeResources(new Document.OptimizationOptions()
        {
            LinkDuplcateStreams = true,
            RemoveUnusedObjects = true,
            RemoveUnusedStreams = true
        });
pdfDocument.Save(destination.ToUpper().Replace(".PDF","_1.PDF"));`

FDB3000278_3244779.pdf (826.5 KB)
FDB3000278_3244779_1.PDF (777.9 KB)

@bstover

Thanks for contacting support.

Would you kindly share the original source PDF document which was not optimized and from which you generated FDB3000278_3244779.pdf file. We will test the scenario in our environment and address it accordingly.

Here is the document before applying OptimizeResources.

FDB3000278_3244779_ORIG.PDF (1.0 MB)

@bstover

Thanks for sharing requested PDF.

We have tested the scenario in our environment using Aspose.PDF for .NET 19.2 and following code snippet. We were unable to notice the issue that you have mentioned. For you kind reference, output PDFs are also attached.

var pdfDocument = new Document(dataDir + "FDB3000278_3244779_ORIG.pdf");
Optimization.OptimizationOptions options = new Optimization.OptimizationOptions();
options.LinkDuplcateStreams = true;
options.RemoveUnusedObjects = true;
options.RemoveUnusedStreams = true;
options.ImageCompressionOptions.CompressImages = true;
options.ImageCompressionOptions.ImageQuality = 70;
pdfDocument.OptimizeResources(options);
pdfDocument.Save(dataDir + "optimized.19.2_duplicateStreamTrue.pdf");

optimized.19.2_duplicateStreamTrue.pdf (780.1 KB)
optimized.19.2_duplicateStreamFalse.pdf (1.0 MB)

Would you please try using latest version of the API and in case you still face any issue, please feel free to let us know.