Word to Pdf. How to create bookmarks from Word in Pdf

Good day.

We use aspose to programmatically generate a word document
and in some case convert it to PDF. Moustly all OK.

What are correct way to create a bookmarks in PDF by data from word file?
Now we are convert doc to PDF ,then parse each pages text by regexp and add pdf bookmarks.

I am expecting that exist another way, like set word style to string/row
that on conversion will be translated to pdf bookmarks
Or list /collection in word items of that will be converted to pdf bookmarks.

Konstantin

Hi Konstantin,
Thanks for using our products.
As your request is related to Aspose.Words, I am moving your request in Aspose.Words forum. My colleagues from Aspose.Words component team will answer you shortly.
We apologize for your inconvenience.
Thanks & Regards,

Hi Konstantin,
Thanks for your inquiry. Please find below code snippet to retain bookmarks while rendering Word document to PDF. Hopefully it will resolve your issue. Kindly check following link for more helpful properties of PdfSaveOption Class.
https://reference.aspose.com/words/net/aspose.words.saving/pdfsaveoptions/

public static void wordToPdfBm()
{
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);
    BookmarkStart start = builder.StartBookmark("MyBookmark");
    builder.Writeln("Text of bookmark.");
    builder.EndBookmark("MyBookmark");
    PdfSaveOptions saveOption = new PdfSaveOptions();
    saveOption.SaveFormat = SaveFormat.Pdf;
    // To retain Bookmark
    saveOption.BookmarksOutlineLevel = 1;
    doc.Save(MyDir + "out.pdf", saveOption);
}

Please feel free to contact us for any further assistance,

Best Regards,

Grate it’s work.
Thank you for quick and precise help.
Konstantin