How to insert Visio file into DOCX

@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.

@alexey.noskov Thanks for your elaboration. I think the “appropriate size” you mentioned may be related to "dxaOrig " and “dyaOrig” i said before. About how to decide the appropriate EMF size from the Visio file, do you have any suggestion?

@space_chang Unfortunately, it is hard to say what is the appropriate size. I would suggest you to try creating Visio OLE object using MS Word and investigate what size of the presentation image MS Word uses for the particular OLE object. Then you can try creating the similar image using Aspose.Diagrams.

@alexey.noskov This won’t be a available method to calculate the size for my use cases becuase my Visio diagram will vary by input data.
And if i use MS Word in my application manually, i can insert Visio into DOCX directly instead of only creating OLE object with appropriate size and using your library to insert it into DOCX.
What i want is to find a solution to implement it without any manual work on Linux.

@space_chang I mean not to use MS Word to calculate image size permanently. I mean to use MS Word to determine MS Word logic to calculate the image size, i.e. for investigation purposes, and then use the same logic in your code to generate presentation images.

@alexey.noskov Unfortunately, i ever tried this method. but it cannot work well. for different size of visio file, the generated emf size vary without stable logic when using MS word. And I cannot figure out any specific reason to that.

@space_chang Unfortunately, Aspose.Words does not control creation of the presentation images. So, I am afraid, we cannot help you in determining the algorithm MS Word uses for creating these images upon insertion of OLE objects.

@alexey.noskov it’s a pity that both of us cannot find any availble solution to that. If it is like that, i think this issue cannot be fixed though i use both aspose.words and aspose.diagram in my application.
because we cannot figure out exact behavior of MS word to that.

@space_chang I think that both MS Word and Visio are involved in the process. But how there are interaction with each other is a black box.

@alexey.noskov Thanks for your elaborate explanation and I get your opinion.

1 Like