Exporting Outlines from Bookmarks and Headings in Output PDF

I am using following code to export bookmarks/Headings from word to PDF

public static void ConvertWordToPDF(String FileIn, String FileOut)
    Aspose.Words.Document d = new Aspose.Words.Document(FileIn);
    Aspose.Words.Saving.PdfSaveOptions opt = new Aspose.Words.Saving.PdfSaveOptions();
    opt.OutlineOptions.DefaultBookmarksOutlineLevel = 1;
    d.Save(FileOut, opt);

But in output PDF, bookmarks are not exported. Please find sample input and output files
testconverstion.zip (46.2 KB)

@crshekharam There are no bookmarks in your document. You should use OutlineOptions.HeadingsOutlineLevels to get the desired output:

Document doc = new Document(@"C:\Temp\in.docx");

PdfSaveOptions opt = new PdfSaveOptions();
// Heading1, Heading2 and Heading3 levels will be included
opt.OutlineOptions.HeadingsOutlineLevels = 3;

doc.Save(@"C:\Temp\out.pdf", opt);

Thank you @alexey.noskov . Now bookmarks are generated from Headings.

1 Like