Hi,
I’m using Aspose.pdf v.6.8 for converting a Word document to PDF (using C# .NET 3.5).
I’m having troubles with setting “named destination(s)” based on the heading style in the Word document. I’ve read that it should be supported by version 6.7.
This is my method:
public static void ConvertWordToPdf(string fileNameOfSource, string fileNameOfTarget)
{
Document doc = new Document(fileNameOfSource);
doc.Save(fileNameOfTarget);
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
bookmarkEditor.BindPdf(fileNameOfTarget);
//Find all paragraphs with style “Heading 1”.
const string paraStyle = “Heading 1”;
ArrayList paragraphs = ParagraphsByStyleName(doc, paraStyle);
foreach (Paragraph paragraph in paragraphs)
{
//create bookmark
Aspose.Pdf.Facades.Bookmark bookMark = new Aspose.Pdf.Facades.Bookmark();
bookMark.Title = paragraph.ToTxt();
bookMark.Action = “Named”;
bookMark.Destination = “???”; //Some named desination
bookmarkEditor.CreateBookmarks(bookMark);
}
//save updated document
bookmarkEditor.Save(fileNameOfTarget);
}
I’m having problems setting the bookMark.Destination property.
It should be a string but where or how do I associate the string value to the correct paragraph?
Hi Frederik,
Thank you for using our products and sharing the sample source code. I tried using your code to test your issue but due to missing variables and methods, I was unable to replicate the scenario at my end. However, to exactly replicate your issue at our end, we would appreciate, if you create a sample application and post here along with template documents you are uisng. This will help us to figure out the issue and reply back to you soon.
We apologize for your inconvenience.
Thanks & Regards,
Hello Frederik,
Thanks for contacting support.
Please note that currently when using Bookmark class under Aspose.Pdf.Facades namespace, you can specify page number as destination of BookMark and I am afraid currently the feature of specifying Heading as Bookmark destination is not supported. I have logged this requirement as PDFNEWNET-33535 in our issue tracking system. We will further look into the details of this requirement and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for your inconvenience.