We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Does not show images within the file

I'm trying to open document with editor, but image is not rendered and the text that follows it too.

I implemented the solution reported here, but to no avail: https://www.syncfusion.com/feedback/6127/preserve-vector-images-emf-wmf-tiff-using-asp-net-core-server-side


public string GetSFDTfromBase64(string base64, string extension, Hashtable documentInfos)


            FormatType documentFormatType = extension.ToUpper().Equals("DOC") ? FormatType.Doc : FormatType.Docx;



                WordDocument.MetafileImageParsed += OnMetafileImageParsed;

                WordDocument document = WordDocument.Load(new MemoryStream(Convert.FromBase64String(base64)), documentFormatType);

                WordDocument.MetafileImageParsed -= OnMetafileImageParsed;

                string sdft = Newtonsoft.Json.JsonConvert.SerializeObject(document);


                return sdft;


            catch (Exception e)


                Console.WriteLine("Erro em processo de conversão de DOCX to SFDT: " + e);


            return null;


//Converts Metafile to raster image.

        private static void OnMetafileImageParsed(object sender, MetafileImageParsedEventArgs args)


            //You can write your own method definition for converting metafile to raster image using any third-party image converter.

            args.ImageStream = ConvertMetafileToRasterImage(args.MetafileStream);


        private static Stream ConvertMetafileToRasterImage(Stream metafileStream)


            var imageConverted = new MemoryStream();

            var image = Aspose.Imaging.Image.Load(metafileStream);

            EmfRasterizationOptions emfRasterizationOptions = new EmfRasterizationOptions();

            emfRasterizationOptions.BackgroundColor = Aspose.Imaging.Color.WhiteSmoke;

            emfRasterizationOptions.PageWidth = image.Width;

            emfRasterizationOptions.PageHeight = image.Height;

            image.Save(imageConverted, new PngOptions()


                VectorRasterizationOptions = emfRasterizationOptions


            return imageConverted;


8 Replies 1 reply marked as answer

DQ Daniel Queiroz da Silva November 16, 2022 08:27 AM

There is another problem, when trying to convert file it does not pass the line:

PdfDocument pdfDocument = render.ConvertToPDF(document);

DS Dhanush Sekar Syncfusion Team November 16, 2022 09:50 AM

Could you please share with us the actual input word document that you used to convert the metafile image? It will be beneficial to validate this further and provide you with a solution as soon as possible.

DQ Daniel Queiroz da Silva November 16, 2022 09:56 AM

Yes. Another point I realized is that the error only occurs in DOCX

Attachment: Documents_cafe673f.zip

SM Suriya Murugan Syncfusion Team November 17, 2022 11:11 PM

Daniel, We will check the provided document and update details shortly.

DQ Daniel Queiroz da Silva November 23, 2022 02:08 PM

Any updates ?

AA Akash Arul Syncfusion Team November 24, 2022 01:07 PM

On further analyzing the issue in-depth, we found that the image bytes for the image present in given DOCX document is different from usual structure. While opening a document internally we get some image properties from the image bytes. Due to this difference in image structure the properties of images are not gathered properly. The difference in image structure leads to hanging in PDF conversion and not preserved in DOCX resaving.

To resolve this issue, we suggest you to use a normal jpeg image(by saving jpeg image again) in the input document to preserve properly in the output.

We have modified the Word document and converted the modified document to DOCX and PDF in DocIO and attached it in this.

Attachment: TESTE_IMAGEM_Modified_docs_934c6ea9.zip

DQ Daniel Queiroz da Silva November 25, 2022 07:15 AM

I understood. But why does this error only happen with the DOCX file and in the DOC it works correctly?

AA Akash Arul Syncfusion Team November 28, 2022 12:36 PM

The file level specification for DOC and DOCX both are completely different. The DOC format document is a binary format level, but the DOCX format document is compressed XML file level. While opening a DOC format document we parse and uses the image sizes directly mentioned in file level so it does not rises any issue in image size calculations. But in DOCX format document, as per specification the image sizes are not directly mentioned in file level. While opening a document in the Microsoft word viewer, it calculates the image size based file level value and original image size value. While retrieving the image size from image bytes, the image bytes structure are different in this rare scenario.
As we mentioned earlier, we suggest you to use the modified document with proper image structure to resolve the issue.

Marked as answer
Live Chat Icon For mobile
Up arrow icon