Convert document into .pdf. and see/parse the Bookmarks

Hi Team,

I am using Aspose word java to convert document into .pdf. But i am not able to see/parse the Bookmark
in PDF file although these bookmarks are there in document(.docx/.doc).

Please do let me know how can i retain the bookmark in PDF as well.

@Pintutrnt,

Please try using the following code:

Document document = new Document();
DocumentBuilder builder = new DocumentBuilder(document);

builder.insertBreak(BreakType.PAGE_BREAK);

builder.startBookmark("MyBookmark");
builder.writeln("Text inside a bookmark.");
builder.endBookmark("MyBookmark");

PdfSaveOptions options = new PdfSaveOptions();
options.getOutlineOptions().setDefaultBookmarksOutlineLevel(1);

document.save("E:\\Temp\\awjava-19.7.pdf", options); 

Hope, this helps.

Hello Hafeez,

Awesome. it worked.

Thank you…

Hi Hafeez,

Do we have any methods or way to get all the content of a docx file as HTML format without using below process.

document.save(“d:/test.htm”,SaveFormat.HTML);

Means, can we get the all content from document object as html .

Thanks in Advance…

@Pintutrnt,

You can build logic on the following code to get the desired output:

Document doc = new Document("E:\\Temp\\in1.docx");

HtmlSaveOptions opts = new HtmlSaveOptions(SaveFormat.HTML);
opts.setPrettyFormat(true);
opts.setExportImagesAsBase64(true);

String str = doc.toString(opts);