Hi,
We’ve been using PdfBookmarkEditor.ExportBookmarkToXml with previous Aspose.Pdf.Kit package without any problems. After you released Aspose.Pdf, we updated our code to use the latest dll and we have some errors on PdfBookmarkEditor.ExportBookmarkToXml for different pdf files.
You can find attached only 2 pdf files used for testing (I was unable to upload input1.pdf):
- input1.pdf works fine
- input2.pdf has the following exception: Can’t create destination becase of invalid original data
- input3.pdf has the following exception: Object reference not set to an instance of an object.
In our project we are using some custom generated pdf files and have also this error: Object reference not set to an instance of an object. when the ExportBookmarkToXml is called.
Since I was unable to upload the test project I’ll put here the code that you need to paste in a console application in order to reproduce this issue:
class Program
{
static void Main(string[] args)
{
try
{
string inputFileName = “input3.pdf”;<span style="color:green;">//ExportBookmarksWithPdfKit(inputFileName);</span> ExportBookmarksWithPdfFacades(inputFileName); } <span style="color:blue;">catch</span> (<span style="color:#2b91af;">Exception</span> ex) { <span style="color:#2b91af;">Console</span>.WriteLine(ex.Message); } } <span style="color:blue;">private</span> <span style="color:blue;">static</span> <span style="color:blue;">void</span> ExportBookmarksWithPdfKit(<span style="color:blue;">string</span> inputFileName) { <span style="color:green;">//set the Aspose.Pdf license using the Aspose.Pdf.Kit one</span> <span style="color:green;">//Aspose.Pdf.Kit.License asposePdfLicense = new Aspose.Pdf.Kit.License();</span> <span style="color:green;">//asposePdfLicense.SetLicense("AsposePdf.Licenses.Aspose.Pdf.Kit.lic");</span> <span style="color:green;">//create PdfBookmarkEditor object</span> Aspose.Pdf.Kit.<span style="color:#2b91af;">PdfBookmarkEditor</span> bookmarkEditor = <span style="color:blue;">new</span> Aspose.Pdf.Kit.<span style="color:#2b91af;">PdfBookmarkEditor</span>(); <span style="color:green;">//open PDF file</span> bookmarkEditor.BindPdf(inputFileName); <span style="color:green;">//export bookmarks</span> bookmarkEditor.ExportBookmarksToXML(<span style="color:#a31515;">"bookmarks.xml"</span>); } <span style="color:blue;">private</span> <span style="color:blue;">static</span> <span style="color:blue;">void</span> ExportBookmarksWithPdfFacades(<span style="color:blue;">string</span> inputFileName) { <span style="color:green;">//set the Aspose.Pdf license using the Aspose.Pdf.Kit one</span> <span style="color:green;">//Aspose.Pdf.License asposePdfLicense = new Aspose.Pdf.License();</span> <span style="color:green;">//asposePdfLicense.SetLicense("AsposePdf.Licenses.Aspose.Pdf.Kit.lic");</span> <span style="color:green;">//create PdfBookmarkEditor object</span> Aspose.Pdf.Facades.<span style="color:#2b91af;">PdfBookmarkEditor</span> bookmarkEditor = <span style="color:blue;">new</span> Aspose.Pdf.Facades.<span style="color:#2b91af;">PdfBookmarkEditor</span>(); <span style="color:green;">//open PDF file</span> bookmarkEditor.BindPdf(inputFileName); <span style="color:green;">//export bookmarks</span> bookmarkEditor.ExportBookmarksToXML(<span style="color:#a31515;">"bookmarks.xml"</span>); } }</pre>Just add the pdf files to bin/Debug folder and run the application.<br><br>Can you please let me know if there is some work around to these exceptions?<br><br>Thanks,<br><br>Mirela<br>