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);
catch (Exception e)
Console.WriteLine("Erro em processo de conversão de DOCX to SFDT: " + e);
//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
There is another problem, when trying to convert file it does not pass the line:
PdfDocument pdfDocument = render.ConvertToPDF(document);
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.
Yes. Another point I realized is that the error only occurs in DOCX
Daniel, We will check the provided document and update details shortly.
Any updates ?
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.
I understood. But why does this error only happen with the DOCX file and in the DOC it works correctly?
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.