Hi,
When converting a .docx file to a .pdf file using Aspose.Words, I noticed a formatting issue when my EMF table is converted see screenshot attached.
Code:
var saveOptions = new PdfSaveOptions();
saveOptions.UseHighQualityRendering = true;
saveOptions.CustomPropertiesExport = Aspose.Words.Saving.PdfCustomPropertiesExport.Metadata;
saveOptions.OutlineOptions.HeadingsOutlineLevels = 9;
saveOptions.OutlineOptions.DefaultBookmarksOutlineLevel = 0;
saveOptions.ExportDocumentStructure = true;
saveOptions.FontEmbeddingMode = PdfFontEmbeddingMode.EmbedAll;
saveOptions.OptimizeOutput = false;
saveOptions.Compliance = Aspose.Words.Saving.PdfCompliance.Pdf17;
Document convertedDocument = DocumentHelper.OpenReadOnly(@"input.docx");
convertedDocument.FieldOptions.FieldUpdateCultureSource =FieldUpdateCultureSource.FieldCode;
convertedDocument.UpdateFields();
convertedDocument.Save(@"output.pdf", saveOptions);
The output has a formatting error shown in the screenshot attached. Note this issues persists of docx to html also.
I am using Aspose.Words 25.1.0
Please find attached the problematic docx file
emf problematic table .docx (18.8 KB)
Thanks
@ServerSide527
Hi,
Thank you for reaching out and providing the necessary details. We appreciate your patience as we investigate the issue you’re experiencing with the formatting of your EMF table during the conversion from .docx to .pdf using Aspose.Words.
To better understand and address the problem, could you please confirm the following details:
-
Aspose.Words Version: Which version of Aspose.Words are you currently using? This will help us ensure that we’re testing with the same environment.
-
Error Details: Apart from the visual discrepancy, are there any specific errors or exceptions being thrown during the conversion process?
-
Conversion to HTML: You mentioned that there is also a formatting issue when converting to HTML. Could you provide the snippet of your HTML conversion code, along with an example of the output where the issue occurs?
Once we have this information, we can delve deeper into the issue. Additionally, please refer to our documentation for converting DOCX to PDF to ensure you’re using the latest recommended practices.
We will be stand by to assist you further!
@ServerSide527 To get the output closer to MS Word it is required to enable open type features. Aspose.Words.Shaping.Harfbuzz package provides support for OpenType features in Aspose.Words using the HarfBuzz text shaping engine. You should enabling open type features to get the expected result. To achieve this you should add reference to Aspose.Words Shaping Harfbuzz
plugin and use the following code to convert your document:
Document doc = new Document(@"C:\Temp\in.docx");
doc.LayoutOptions.TextShaperFactory = Aspose.Words.Shaping.HarfBuzz.HarfBuzzTextShaperFactory.Instance;
doc.Save(@"C:\Temp\out_HarfBuzz.pdf");
out_HarfBuzz.pdf (16.7 KB)
Thank you this has solved it
1 Like