Coordinates of XYZExplicitDestination not nullable

We have an issue with a PDF file which contains XYZ destinations with the coordinates (null, null). If we try to change the zoom level we need to recreate the destination with the new zoom level. Aspose.Pdf converts all null values to 0.0. Unfortunately, this causes the new destination to point to the bottom left of the page, which effectively is the top left of the next page.

According to the PDF specification most destinations allow null for all values (except for page). Therefore, the corresponding attributes in Aspose.Pdf should be nullable as well.

We are currently using Aspose.PDF 11.

@Stefan.Schroth,
You can retrieve the rectangle height of the target page from a Page class object and do not pass null values. Please refer to this help topic: Specify PDF Page when Viewing Document.

We are aware of this workaround. We already create new destinations with this method whenever it’s clear, that we want to reference the top left corner.

However, we process existing PDF files from our customers. And these PDF files may contain destinations with (null, null) and destinations with (0.0, 0.0) actually referencing the bottom of the page.

For fixing this issue with the current version of Aspose.PDF we have to assume (null null) == (0.0 0.0) and point to the upper left corner of the document. But as stated this violates the PDF specification and will cause issues if a destination actually points to (0.0, 0.0).

@Stefan.Schroth,
How did you find that the PDF specifications are being violated? Kindly share the complete details of the use case, including a sample PDF document, code and any other handy information which could help us to replicate the problem in our environment. We will investigate and share our findings with you. Your response is awaited.

http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf
Chapter 12.3.2.2 Explicit Destinations, Page 366

XYZDestination for example:
“A null value for any of the parameters left, top, or zoom specifies that the current value of that parameter shall be retained unchanged.”

The issue is evident by looking at the class definitions. For example:
https://reference.aspose.com/net/pdf/aspose.pdf.annotations/xyzexplicitdestination


The use case is, we have PDF documents from various sources. This documents must conform to certain guidelines. In this case we tried to remove the zoom factor from the OpenAction without altering the position information. Since the document contains confidential information, we created a substitute document for testing.


Testfile and testcode:
testdoc.pdf (30.3 KB)
static void testfunc(string inputfile, string outputfile)
{
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(inputfile);
Aspose.Pdf.Annotations.GoToAction action = (Aspose.Pdf.Annotations.GoToAction)doc.OpenAction;
Aspose.Pdf.Annotations.XYZExplicitDestination dest = action.Destination as Aspose.Pdf.Annotations.XYZExplicitDestination;
action.Destination = new Aspose.Pdf.Annotations.XYZExplicitDestination(dest.PageNumber, dest.Left, dest.Top, 1.5);
doc.Save(outputfile);
}

The Acrobat Reader will open the original file on the top left, the modified file on the bottom left.

@Stefan.Schroth,
Thank you for the details. We have logged an enhancement ticket ID PDFNET-43323 in our issue tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.