Issue with Doc conversion to PDF with Embedded Document

Hi,
Sorry. I attached a simple document and the converted pdf file. Please check.

Thanks
Jithin V P
Input.pdf (118.1 KB)

Input.docx (12.1 KB)

@jithin.p Thank you for additional information. As I can see navigation work fine in PDF produced by the following simple code:

Document doc = new Document(@"C:\Temp\in.docx");
PdfSaveOptions opt = new PdfSaveOptions();
opt.OutlineOptions.DefaultBookmarksOutlineLevel = 1;
doc.Save(@"C:\Temp\out.pdf", opt);

out.pdf (16.0 KB)

As I can see your PDF is postprocessed by Aspose.PDF. Could you please check PDF produced by Aspose.Words before postprocessing it?

Hi,
I got the issue. While commenting the code //opt.ExportDocumentStructure = true; it is working fine. How will it affect the document if I am removing this line of code? Can you please tell me?

Aspose.Words.Saving.PdfSaveOptions opt;
opt = new Aspose.Words.Saving.PdfSaveOptions();
//opt.ExportDocumentStructure = true;
opt.CustomPropertiesExport = Aspose.Words.Saving.PdfCustomPropertiesExport.Metadata;
opt.SaveFormat = Aspose.Words.SaveFormat.Pdf;
opt.Compliance = Aspose.Words.Saving.PdfCompliance.Pdf20;
opt.EmbedAttachments = true;
opt.OutlineOptions.DefaultBookmarksOutlineLevel = 1;                
doc.Save(filepath, opt);

@jithin.p This option enables exporting document structure for accessibility.
I tested the scenario with the following code and still navigation works fine:

Document doc = new Document(@"C:\Temp\in.docx");
PdfSaveOptions opt = new PdfSaveOptions();
opt.ExportDocumentStructure = true;
opt.CustomPropertiesExport = Aspose.Words.Saving.PdfCustomPropertiesExport.Metadata;
opt.SaveFormat = Aspose.Words.SaveFormat.Pdf;
opt.Compliance = Aspose.Words.Saving.PdfCompliance.Pdf20;
opt.EmbedAttachments = true;
opt.OutlineOptions.DefaultBookmarksOutlineLevel = 1;
doc.Save(@"C:\Temp\out.pdf", opt);

out.pdf (16.6 KB)

Hi,
I used exactly the same code that you gave above. But the bookmark navigation is still missing. While making “opt.ExportDocumentStructure = false;” it is working. I am using ASPOSE.Words dll 24.8.0.0 in 4.7.2 .Net framework. Can you please tell me what is wrong from my side? Below is my code.

Document doc = new Document(@"C:\Projects\Jithin\ASPOSE\Input Files\Input.docx");
PdfSaveOptions opt = new PdfSaveOptions();
opt.ExportDocumentStructure = false;
opt.CustomPropertiesExport = Aspose.Words.Saving.PdfCustomPropertiesExport.Metadata;
opt.SaveFormat = Aspose.Words.SaveFormat.Pdf;
opt.Compliance = Aspose.Words.Saving.PdfCompliance.Pdf20;
opt.EmbedAttachments = true;
opt.OutlineOptions.DefaultBookmarksOutlineLevel = 1;
doc.Save(@"C:\Projects\Jithin\ASPOSE\Input Files\Input.pdf", opt);

Thanks
Jithin V P

@jithin.p I used the latest 24.12 version of Aspose.Words for testing. So please try using the latest version on your side. In addition, please attach PDF document produced on your side.

Hi,
Thanks. Let me check. Attached is the output pdf document.

Input.pdf (45.4 KB)

Thanks
Jithin V P

Hi,
I upgraded the Word dll to 24.9 and it worked. Thanks for the quick support. Thank you very much.

Thanks
Jithin V P

1 Like

Hi,
Is there any option in ASPOSE to convert word headings and subheadings to bookmarks while converting from Word to PDF? Please guide me.

Thanks
Jithin V P

@jithin.p You can specify this in OutlineOptions:

Document doc = new Document("in.docx");
PdfSaveOptions options = new PdfSaveOptions();
// The output PDF document will contain an outline, which is a table of contents that lists headings in the document body.
// Clicking on an entry in this outline will take us to the location of its respective heading.
// Set the "HeadingsOutlineLevels" property to "4" to exclude all headings whose levels are above 4 from the outline.
options.OutlineOptions.HeadingsOutlineLevels = 4;
doc.Save("out.pdf", options);

Hi,

Thank you very much. It worked. Thanks a lot.

Thanks
Jithin V P

1 Like