Word to Pdf Conversion - Empty heading in word adds a empty outline in converted pdf

Word to Pdf Conversion - Empty heading in word adds a empty outline in converted pdf


Hi,

I am trying to convert a word document with headings to pdf. If word document contains a heading with empty line(no text in that line), followed by valid text in next line, then the converted pdf contains empty bookmark. Please refer the screenshot attached.

Code used:
Document msword = new Document(f.getPath());
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setCompliance(PdfCompliance.PDF_A_1_B);
saveOptions.setBookmarksOutlineLevel(OutlineLevel.LEVEL_8);
saveOptions.setHeadingsOutlineLevels(OutlineLevel.LEVEL_8);
saveOptions.setExpandedOutlineLevels(OutlineLevel.LEVEL_4);
msword.save(file.getPath(), saveOptions);

Version used: aspose-words-15.6.0

Please suggest if there is a way to set the text in the source document (available in the next line) to be displayed for the converted bookmark in pdf instead of displaying a empty pdf bookmark?

Thanks in advance.

Hi Manohar,

Thanks
for your inquiry. It would be great if you please share your input word document here for testing. I will investigate the issue on my side and provide you
more information.

Hi Tahir Manzoor,

Thanks a lot for the quick reply. There was mistake in my previous post (the version of aspose mentioned in the post was wrong).
The screenshot attahced in my previous post was simulated in the older version of the aspose(words-13.5.0.0,pdf-4.0.0).
In
the latest version, the empty bookmark is not displayed. But is there a
way to insert that bookmark with the text from its next line in source
document?

Please find the attached zip document containing the word and converted pdf and the code used for conversion.

Thanks and Regards,
Manohar

Hi Manohar,

Thanks

for your inquiry.

manohar.n.gowda:

In the latest version, the empty bookmark is not displayed. But is there a way to insert that bookmark with the text from its next line in source document?

The text “TABLE OF CONTENTS” have not heading style and this should not be visible in bookmark panel of output Pdf. See the attached output Pdf. Please set the style of this text to heading styles.

Moreover, please note that Aspose.Words mimics the same behavior as MS Word does. If you convert the same document using MS Word with options (create bookmark using heading) to Pdf, you will get the same output.

Please let us know if you have any more queries.

Hi Tahir Manzoor,

We will proceed with valid word documents for pdf conversion and this use case of empty heading not being inserted in pdf bookmarks should be fine.

Thanks for the quick reply and all your support.

Best Regards,
Manohar G.N.

Hi Manohar,

Thanks

for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.