Saving to PDF breaks bookmark structure and names

Hello, I am using Aspose words for converting a HTML document to docx and PDF, but I’m having trouble with the bookmarks when saving the document as PDF. The bookmarks have correct names and hierarchy when exported to word, but when saving as PDF, the hierarchy is lost (all bookmarks are on the same level), and the bookmark names are not the same as the h-tags text.

I have tried the different OutlineOptions in PdfSaveOptions, but they don’t make any difference. Is there any other settings I should try?

We have a Aspose.Total license. Would it be better to use Aspose.PDF when saving the document as PDF?

Attachments (zipped, because html must be in a zip):
  • The exported PDF file which contains the broken bookmarks
  • The exported Docx file where the bookmarks work correctly
  • The source HTML
Hi Lasse,

Thanks for your inquiry. Please use OutlineOptions.HeadingsOutlineLevels property to specify how many levels of headings (paragraphs formatted with the Heading styles) to include in the document outline. Specify 0 for no headings in the outline; specify 1 for one level of headings in the outline and so on.

Unfortunately, this property does not work properly for your case. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-14256. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Thank you for investigating this

Hello, I still need help with this issue, as we want to enable PDF bookmarks on our export feature.
I can’t seem to get the bookmarks to work when exporting to PDF, even though they work perfectly when saving as docx. I have now tried to make the bookmarks work in a very simple document, but I still can’t get it to work.

I have created this method which creates a test document with a few headers and text paragraphs:

private static MemoryStream SaveDocumentToStream(SaveFormat saveFormat)
    var outStream = new MemoryStream();

    const string html = "<h1>First header</h1>" +
                        "<h2>First h2</h2>" +
                        "<p>Some text</p>" +
                        "<h2>Another h2</h2>" +
                        "<h3>h3</h3>" +
                        "<p>Some more text</p>";

    var htmlStream = new MemoryStream(Encoding.UTF8.GetBytes(html));
    var loadOptions = new LoadOptions(LoadFormat.Html, null, null);
    var document = new Document(htmlStream, loadOptions);

    if (saveFormat == SaveFormat.Pdf)
        var saveOptions = new PdfSaveOptions
            SaveFormat = SaveFormat.Pdf,
            OutlineOptions = { HeadingsOutlineLevels = 1 }

        document.Save(outStream, saveOptions);
        document.Save(outStream, saveFormat);
    outStream.Seek(0, SeekOrigin.Begin);

    return outStream;

When saving as PDF with Aspose, no bookmarks are created. However, if I save as docx, and use Word 2017 to export to PDF (using these settings: word pdf settings.png (6.4 KB)), the bookmarks works as expected: Expected result.jpg (22.7 KB).
How can I get bookmarks to work when exporting to PDF? I suspect that I’m using wrong OutlineOptions, but I think I have tried every combination of every setting now, without succcess.

Attached: exports from Aspose as docx and pdf, and pdf exported from Aspose-generated docx.
pdf from Aspose.pdf (32.1 KB)
docx from (4.7 KB)
pdf from docx from Aspose (with bookmarks).pdf (7.8 KB)


Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-15719. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Thank you for your fast reply. I’m looking forward to a fix

Hello, I was looking throught the release notes for Aspose Words 17.9, and noticed it contains this bugfix:
“WORDSNET-15701 Heading bookmarks are not created after conversion from DOCX to PDF.”
This looks like the same issue as I’m having, so I tried updating to 17.9. Sadly, the bug I’ve reported still occurs.
We are otherwise happy with Aspose, and have just bought a new license. Our customers are requesting heading outlines from our PDF exports, but this bug prevents that.
I hope you can take the time to provide a fix or a workaround for this issue.


Thanks for your inquiry. Your issue is related to HTML import and is not related to WORDSNET-15701. We have asked for the ETA of this issue from our product team. As soon as any information is shared by them, we will be more than happy to share that with you.

Thanks for your patience.

The issues you have found earlier (filed as WORDSNET-14256) have been fixed in this Aspose.Words for .NET 18.10 update and this Aspose.Words for Java 18.10 update.