Part of our PDF generation process uses xslt and xml data. We are finding that we have issues when the PDF that this generates contains local links that point to other pages within the document (rather than the same page the link is on).
Using version 11.5.0 this results in an Object reference not set to an instance of an object exception.
Note this all worked fine in versions prior to 11.5.0 (e.g 11.4.0 and 9.4.0 - 9.4.0 was the original version we were using until we decided to upgrade recently).
I have created a small test example that is just a link to some text that is on another page to show the problem. The error occurs during converting the Aspose.Pdf.Generator.Pdf to a Aspose.Pdf.Document.Document and then adding those pages to an in-progress document.
i.e.:
using (var contentDocument = newDocument(pdf))
{
outputDocument.Pages.Add(contentDocument.Pages); // Error thrown here
contentPages = contentDocument.Pages.Count;
}
The full test code to show this issue is below. If you force the Footnote link and Footnote text to be on the same page (e.g. change it to be in the 1 Section) then there is no error.
Note that in our actual code the link and text are all in the same Section and it is just the content that is pushing them to different pages.
publicvoidFootnoteErrorExample()
{ var license = newLicense();
license.SetLicense(“Aspose.Pdf.lic”);
Thanks for your inquriy. Please note we have introduced new XSD schema of Aspose.Pdf(new generator), so we will appreciate it if you please change your xml and xslt as per new schema and use following code snippet for the conversion. Hopefully it will help you to resolve the issue.
Regardless of what XML/XSLT generator is used there still seems to be a fundamental issue with Aspose 11.5.0 that causes it to fail when loading a PDF with hyperlinks across pages.
The following code loading the Test.pdf attached crashes at outputDocument.Pages.Add(contentDocument.Pages); attached ConvertedTest.pdf is blank.
In Test.pdf the Footnote link is a link to the 2nd page to Footnote text.
This worked fine in 11.4.0 and earlier.
using (var outputDocument = newDocument())
{ try
{ using (var contentDocument = newDocument(@“D:\temp\Test.pdf”))
{
contentDocument.Save(@“D:\temp\ConvertedTest.pdf”); // This ends up as a blank PDF
outputDocument.Pages.Add(contentDocument.Pages); // Crashes here
}
} catch (Exception e)
{ Assert.Fail(e.Message);
}
}
Regardless of what XML/XSLT generator is used there still seems to be a fundamental issue with Aspose 11.5.0 that causes it to fail when loading a PDF with hyperlinks across pages.
The following code loading the Test.pdf attached crashes at outputDocument.Pages.Add(contentDocument.Pages); attached ConvertedTest.pdf is blank.
In Test.pdf the Footnote link is a link to the 2nd page to Footnote text.
This worked fine in 11.4.0 and earlier.
using (var outputDocument = newDocument())
{
try
{
using (var contentDocument = newDocument(@"D:\temp\Test.pdf"))
{
contentDocument.Save(@"D:\temp\ConvertedTest.pdf"); // This ends up as a blank PDF
outputDocument.Pages.Add(contentDocument.Pages); // Crashes here
}
}
catch (Exception e)
{
Assert.Fail(e.Message);
}
}
Thanks for sharing your findings. I have
tested your scenario with shared document using Aspose.Pdf for .NET 11.5.0 and
managed to observe the reported issue. For further investigation, I have logged
an issue in our issue tracking system asPDFNEWNET-40623and also linked your request to it. We
will keep you updated via this thread regarding the issue status.
The new XSD has too much missing compared to the older one used in Aspose.Pdf.Generator. e.g.:
MarginTop/Bottom/Left/Right for Text and Segments (TextFragment and TextSegment in the new XSD)
IsKeptWithNext for Text (TextFragment in the new XSD)
Can't see anyway to create bulleted lists that aren't numbered lists - used to use UserLabel on a Heading element
No TargetId and Id for Segments so can't link to them in the PDF
plus others
Thanks for feedback. We have logged an enhancement ticket PDFNEWNET-40624 in our issue tracking system. Our product team will investigate it and will rectify accordingly. We will keep you updated about the issue resolution progress in this forum thread.