Saving a word document Contains EMF image as PDF - ASPOSE.WORDS

Hi,
i used aspose.words v13.7 .NET to Save a word document as PDF the document contains EMF image file and the emf image file have some text in RTL direction. when i saved the pdf file the EMF image RTL texts has been messed up. but when i save the document file as PDF by ms-word the output file generated perfectly.
could you please help me to find a solution?

Hi Masoud,

Thanks for your inquiry. Please note that Aspose.Words
requires TrueType fonts when rendering documents to fixed-page formats
(JPEG, PDF or XPS). Make sure you have all the Fonts installed on your
machine you’re using to convert Docx to Pdf format. I would suggest you please read the
following article:
https://docs.aspose.com/words/net/using-truetype-fonts/

I would suggest you please upgrade to the latest version (v15.8.0) from here and let us know how it goes on your side. If the problem still remains, please attach the fonts used in your document e.g B Yekan, WeblogmaYekan, B Nazanin, Adobe Arabic etc. I will investigate the issue on my side and provide you more information.

Hi Tahir,
Thanks for your reply. i checked the document with Aspose.Words 15.8.0.0
as you mentioned but the output still makes the RTL words messed up in
emf image . i attached the fonts i used in new document.
could you please test it on your side?

Hi Masoud,

Thanks for sharing the detail. I
have tested the scenario and have managed to reproduce the same issue
at my side. For the sake of correction, I have logged this problem in
our issue tracking system as WORDSNET-12395. I have linked this forum
thread to the same issue and you will be notified via this forum thread
once this issue is resolved.

We apologize for your inconvenience.

I had this problem too, I use bellow link to resolve my problem
EMF to PDF conversion produces garbled document

Hi Freydoon,

Thanks for sharing the workaround. Yes, following code example can be used to workaround this issue.

Document doc = new Document(MyDir + "EMF.docx");
// Get all shapes in the document.
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
// Loop through all shapes.
foreach (Shape shape in shapes)
{
    // If shape contains a vector image, convert it to raster image.
    if (shape.HasImage && (shape.ImageData.ImageType == ImageType.Wmf || shape.ImageData.ImageType == ImageType.Emf))
    {
        using (MemoryStream vectorImageStream = new MemoryStream(shape.ImageData.ImageBytes))
        using (Image image = Image.FromStream(vectorImageStream))
        using (MemoryStream resterImageStream = new MemoryStream())
        {
            image.Save(resterImageStream, ImageFormat.Png);
            shape.ImageData.SetImage(resterImageStream);
        }
    }
}
doc.Save(MyDir + "output.pdf");
1 Like

The issues you have found earlier (filed as WORDSNET-12395) have been fixed in this Aspose.Words for .NET 23.6 update also available on NuGet.