Headings in docx appear as Bookmarks on pdf

Hi,

I tried the following code to generate pdf from the docx file. My requirement is to generate pdf with bookmarks.

code:

Document doc = new Document("input.doc");
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.HeadingsOutlineLevels = 3;
pdfOptions.ExpandedOutlineLevels = 1;
doc.SaveToPdf(0, doc.PageCount, "output.pdf", pdfOptions);

It works correctly when there is a table of contents page on the docx file. They appear as links and also they appear in bookmarks tab on pdf reader.
When I used a word document without table of contents page, I want to main headings and sub headings appear as bookmarks on pdf reader. But they doesn’t appear as bookmarks with the above code.( Please look on following attachments.)

If there is a way to appear those headings in pdf bookmarks tab with Aspose please let me know.

Thanks

Hi

Thanks for your request. As I can see the PDF document, you attached, was not produced by Aspose.Words. I used the following code for testing and the output PDF looks as expected.

Document doc = new Document(@"Test001\3.docx");
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.HeadingsOutlineLevels = 3;
pdfOptions.ExpandedOutlineLevels = 1;
doc.SaveToPdf(0, doc.PageCount, @"Test001\3.pdf", pdfOptions);

I sent the output document to your e-mail.
Best regards,

Hi,

I’m very sorry that I have attached the wrong pdf file.I have attached the correct pdf file with this.

Issued is that the main heading of the attached docx “Making Preparations Procedure” doesn’t appear in the bookmarks tab. All other subheadings appear correctly in pdf.

If there is a solution for this please inform me.

Thanx,
Sameera

Hi

Thanks for your request. Headings are paragraphs with Heading1-HeadingN style or style based on Heading1-HeadingN styles. In your case “Making Preparations Procedure” is paragraph with “Title Heading” style, which is not based on Heading styles, it is based on Normal style. That is why it does not appear in bookmarks.
Best regards.

Hi,

Thanks for your response.

Regards,
Sameera