How to insert Visio file into DOCX

@alexey.noskov This code works well to present the proper figure size after inserting the visio file into DOCX. but it cannot fix the size consistantly. that is to say the figure size will change to be large after i edit the visio diagram(Open DOCX->right click on the visio figure->Open) and save it.

@space_chang I am afraid further processing the document is out of Aspose.Words control. When you edit Visio object and save it MS Word updates the presentation image, which is provided by the consumer application used to edit the object.

@alexey.noskov Maybe~~~, but i tried it using MS word. when i insert the visio diagram into docx and adjust the visio figure size to be proper, i open the visio file from docx to edit it and save it. the size of visio figure is still fixed. I’am not sure what is the difference between MS word and aspose.words for that.

@space_chang Could you please attach your documents produced by Aspose.Words and MS Word here for our reference? We will check the documents and provide you more information.

@alexey.noskov below are the documents you want. the emf used for ASPOSE.docx is produced by MS visio from the corresponding visio file instead of aspose.diagram. please have a check!

MS.docx (62.6 KB)
ASPOSE.docx (61.6 KB)

@space_chang
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-26907

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@alexey.noskov Thanks for your confirmation. I think it is related to some DOCX settings.
Is there alternative solution to fix this issue by using aspose.word to change corresponding setting before you fix it?

@space_chang I compared internal OLE object representation in MS Word and Aspose.Words created documents and they look almost the same. So, unfortunately, I did not manage to find what causes this behavior. Our development team will analyze the issue deeper. We will keep you update and let you know once the issue is resolved or we have more information for you.

@alexey.noskov I analyzed the raw DOCX data and found below difference may cause the above issue.


I’m not experienced in DOCX meta data, so could you help to verify it and provide potential solution?

@space_chang There are w:dxaOrig and w:dyaOrig attributes that Aspose.Words do not write. They seem to be optional. Unfortunately, our development team have not analyzed the issue yet. So currently we do not have any additional information we can share. Please accept our apologies for your inconvenience.

2 posts were merged into an existing topic: 怎么查询docx表格内容以及合并规则

@alexey.noskov That’s OK. do you know how to determine the value of dxaOrig and dyaOrig based on EMF figure or Visio diagram. If i know the method, i think i can use aspose to search for the object node and set the values.

@space_chang There is no way to set dxaOrig and dyaOrig values using Aspose.Words. These values are not written by Aspose.Words.

@alexey.noskov Thanks for your explanation. In these days, I analyzed the data further and have a puzzle about the differences to size of EMF figure between MS and ASPOSE when inserting same visio diagram into DOCX like below:


MS.docx (45.5 KB)
ASPOSE.docx (36.5 KB)
MS.docx: inerting the visio diagram by MS office directly.
ASPOSE.docx:generate the EMF figure by aspose.diagram, then using it as the presentation figure to insert the visio diagram into DOCX without setting the figure size(width&height).

@space_chang Most likely the difference is caused by the difference in the presentation image size generated by Aspose.Diagram and MS Word.

@alexey.noskov How is going about the issue? i see it is still new status.
Besides, i have another question, when i use your diagram library generated EMF from visio and insert it into DOCX by aspose.words. if found the font of the EMF figure will distort when i zoom in the DOCX.
Also, i used another linux tool ‘inkscape’ to build a EMF figure, it will still distort when zooming in. I thinks this issue is related to aspose.words. please help to check it.
Visio.docx (36.8 KB) this is original Visio file. i cannot upload it directly due to some security policy. so i change the appendix to docx, you can change back to vsdx after downloading.
ASPOSE_orig.docx (12.3 KB)
ASPOSE.docx (436.7 KB)

@space_chang

The issue is still in the queue for analysis. So there are no news regarding it yet. Please accept our apologies for your inconvenience.

I do not think the problem is related to Aspose.Words. Actually I cannot see the problem in the attached documents. I tried to zoom-in and zoom-out the document in MS Word and do not see any distortion. Have you tried inserting EMF images produced by Aspose.Diagram and inkscape into the document using MS Word? Does the problem occurs on your side in such case?

@alexey.noskov MS word works well for zooming in when using it to insert the same Visio into docx.
MS.docx (75.5 KB)
MS.png (21.5 KB)
ASPOSE.png (13.9 KB)

Have you tried inserting EMF images produced by Aspose.Diagram and inkscape into the document using MS Word?

Yes. ASPOSE.docx is from Aspose.words and aspose.diagram. and if i use inkscape, it will also distort.
And i checked the EMF figure using inkscape on Linux, its font displays well.

Does the problem occurs on your side in such case?

It seems that it works well on small diagram. but font will distort when the diagram is larger.

@space_chang
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-27044

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@space_chang We have completed analyzing the issue. The reason for the distorted text after inserting a Visio OLE object is that the presentation image is too large. In the resulting document OLEObject and Shape are grouped together, with Shape stored in VML format, which explains the visual defects that appear only when the document is zoomed out. In out.docx document, Shape inserted without an OLE object is saved in DML format, so no defects are observed when zooming. In ms.docx document (which is described as having been saved using MS Word), another Visio document is inserted (which differs both in appearance and in size from the one attached to the ticket), as well as a presentation image of a completely different size. If we place the presentation image from ms.docx into Aspose.Words output, then no visual distortions are observed, just as in case with ms.docx.
By the way, the attached ‘presentation.emf’, which used as the presentation image, does not open at all with an error message, and if we export EMF from the attached VSDX document using Microsoft Visio, then we get the presentation image similar to the one in ms.docx in terms of size and dimensions, and if it is added as the presentation image, no visual defects are observed as well.

Solution.
You need to select a presentation image of the appropriate size. No Aspose.Words code changes are required.