Hi,
I tried using the below code. But the formatting is not correct. Can you please help me? Attached the pdf document. I can see the below fonts are not embedded.
Aspose.Words.Saving.PdfSaveOptions opt;
opt = new Aspose.Words.Saving.PdfSaveOptions();
opt.ExportDocumentStructure = true;
opt.CustomPropertiesExport = Aspose.Words.Saving.PdfCustomPropertiesExport.Standard;
opt.SaveFormat = Aspose.Words.SaveFormat.Pdf;
opt.Compliance = Aspose.Words.Saving.PdfCompliance.Pdf20;
opt.EmbedAttachments = true;
FontSettings.DefaultInstance.SetFontsSources(new Aspose.Words.Fonts.FontSourceBase[] { new SystemFontSource(), new Aspose.Words.Fonts.FolderFontSource(@"C:\MyFonts\", true) });
FontSettings.DefaultInstance.SubstitutionSettings.TableSubstitution.AddSubstitutes("VCEFIJ+FrutigerLTPro-Condensed", "FrutigerLTPro-Condensed");
FontSettings.DefaultInstance.SubstitutionSettings.TableSubstitution.AddSubstitutes("JLNNHU+FrutigerLTPro-LightCn", "FrutigerLTPro-LightCn");
FontSettings.DefaultInstance.SubstitutionSettings.TableSubstitution.AddSubstitutes("ETMKLU+FrutigerLTPro-Bold", "FrutigerLTPro-Bold");
FontSettings.DefaultInstance.SubstitutionSettings.TableSubstitution.AddSubstitutes("LVNWRS+FrutigerLTPro-BoldCn", "FrutigerLTPro-BoldCn");
FontSettings.DefaultInstance.SubstitutionSettings.TableSubstitution.AddSubstitutes("FAPVWH+FrutigerLTPro-Light", "FrutigerLTPro-Light");
FontSettings.DefaultInstance.SubstitutionSettings.TableSubstitution.AddSubstitutes("WIPSPU+FrutigerLTPro-LightCn", "FrutigerLTPro-LightCn");
doc.Save(filepath, opt);
TestDoc.pdf (557.9 KB)
Thanks
Jithin V P
@jithin.p Please try using IWarningCallback
as shown in my code example and check whether there are any warnings.
Hi,
I have a Word document with bookmarks. But while converting the document to pdf, it is missing. is there any option to include those bookmarks in PDF while converting from word?
Thanks
Jithin V P
@jithin.p Sure you can specify outline level where the bookmarks will be exported to PDF using OutlineOptions
properties.
Hi,
Thanks. I tried the below code, and the bookmark is coming now in PDF. But while selecting “Go to bookmark”, the cursor is not pointing to the bookmark point in PDF. Can you please help me to sort this?
Aspose.Words.Saving.PdfSaveOptions opt;
opt = new Aspose.Words.Saving.PdfSaveOptions();
opt.PageMode = PdfPageMode.UseOutlines;
opt.OutlineOptions.DefaultBookmarksOutlineLevel = 1;
opt.HeaderFooterBookmarksExportMode = HeaderFooterBookmarksExportMode.All;
Thanks
Jithin V P
@jithin.p Could you please attach your problematic input and output documents here for testing? We will check the issue and provide you more information.
Hi,
Due to company instructions, I am not able to share the documents. The only thing pending is the bookmark in converted PDF is not navigating to the destination. We have a licensed version of ASPOSE too.
Thanks
Jithin V P
@jithin.p If possible please create a simplified document without real data that will allow us to reproduce the problem. Unfortunately, it is impossible to tell what the problem is and how to resolve it without an ability to reproduce it on our side.
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