Embedded Object to Image/Vision VDX file
Home › Forums › WordprocessingML › Embedded Object to Image/Vision VDX file
This topic contains 1 reply, has 2 voices, and was last updated by Eric White 8 years, 2 months ago.
-
AuthorPosts
-
July 13, 2016 at 12:45 pm #3564
Hi,
I have a Content Control inside the Word document(High Level Design Template) where users will insert the Visio VDX file(Architecture Design Diagram) as object.We are scanning and parsing the document and we need to display the embedded object in the below mentioned Word Processing ML as JPEG/PNG in ASP.NET Web Page(.aspx).
If this is not possible is there way to convert the Embedded Object to VDX/VSDX file so that we can store in a network share and display the URL for the VDX file in ASP.NET Web Page(.aspx).
I have looked into several blogs for inserting the embedded object and Image Part in the Word Document.But i need to read the embedded object and Image Part and need to convert the same.
Couple of blogs are indicting that it is not possible.Please let me know how to acheive this use case.
Embedding Any File Type, Like PDF, in an Open XML File
Code Used:
` try
{
using (WordprocessingDocument myDoc = WordprocessingDocument.Open(@”\\Msad\root\NA\NY\USERS\vijayaru\Downloads\DataDiagrammingML.docx”, true))
{
MainDocumentPart mainDocumentPart = myDoc.MainDocumentPart;// locate content control collection
List<SdtBlock> sdtblocks = mainDocumentPart.Document.Descendants<SdtBlock>().ToList();foreach (var sdt in sdtblocks)
{
List<SdtContentBlock> sdtctblocks = sdt.Descendants().Where(x => x.LocalName == “sdtContent”).Cast<SdtContentBlock>().ToList();string contentCtrlData = string.Empty;
var sdtbpr = sdt.SdtProperties.Elements().Where(x => x.LocalName == “alias”).Cast<SdtAlias>().First().Val;
var sdtbpr1 = sdt.SdtProperties.Elements().Where(x => x.LocalName == “tag”).Cast<Tag>().First().Val;
// Iterate through the content control blocks and append data to a string object
foreach (var sdtb in sdtctblocks)
{
List<Run> runparagraphs = sdtb.Descendants().Where(x => x.LocalName == “r”).Cast<Run>().ToList();foreach (var run in runparagraphs)
{
EmbeddedObject embdobj = run.Descendants().Where(x => x.LocalName == “object”).Cast<EmbeddedObject>().FirstOrDefault();EmbeddedObjectPart imagePart = (EmbeddedObjectPart)myDoc.MainDocumentPart.GetPartById(“rId6″);
}
}
}
}
}
catch (Exception ex)
{}
WordProcessingML:
<?xml version=”1.0″ encoding=”UTF-8″ standalone=”yes” ?>
– <w:document xmlns:wpc=”http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas” xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006″ xmlns:o=”urn:schemas-microsoft-com:office:office” xmlns:r=”http://schemas.openxmlformats.org/officeDocument/2006/relationships” xmlns:m=”http://schemas.openxmlformats.org/officeDocument/2006/math” xmlns:v=”urn:schemas-microsoft-com:vml” xmlns:wp14=”http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing” xmlns:wp=”http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing” xmlns:w10=”urn:schemas-microsoft-com:office:word” xmlns:w=”http://schemas.openxmlformats.org/wordprocessingml/2006/main” xmlns:w14=”http://schemas.microsoft.com/office/word/2010/wordml” xmlns:wpg=”http://schemas.microsoft.com/office/word/2010/wordprocessingGroup” xmlns:wpi=”http://schemas.microsoft.com/office/word/2010/wordprocessingInk” xmlns:wne=”http://schemas.microsoft.com/office/word/2006/wordml” xmlns:wps=”http://schemas.microsoft.com/office/word/2010/wordprocessingShape” mc:Ignorable=”w14 wp14″>
– <w:body>
– <w:p w:rsidR=”000B3BFD” w:rsidRDefault=”00E16F41″>
– <w:r>
<w:t>This is a Test for checking Visio Object</w:t>
</w:r>
</w:p>
<w:p w:rsidR=”008A4123″ w:rsidRDefault=”008A4123″ />
<w:p w:rsidR=”008A4123″ w:rsidRDefault=”008A4123″ />
– <w:p w:rsidR=”008A4123″ w:rsidRDefault=”00A828F0″ w:rsidP=”00A828F0″>
– <w:pPr>
– <w:tabs>
<w:tab w:val=”left” w:pos=”3997″ />
</w:tabs>
</w:pPr>
– <w:r>
<w:tab />
</w:r>
</w:p>
– <w:sdt>
– <w:sdtPr>
<w:alias w:val=”Test” />
<w:tag w:val=”Test1″ />
<w:id w:val=”493915431″ />
– <w:placeholder>
<w:docPart w:val=”DefaultPlaceholder_1082065158″ />
</w:placeholder>
</w:sdtPr>
– <w:sdtContent>
– <w:p w:rsidR=”000B3BFD” w:rsidRDefault=”00A268B6″>
– <w:r>
– <w:object w:dxaOrig=”1531″ w:dyaOrig=”991″>
– <v:shapetype id=”_x0000_t75″ coordsize=”21600,21600″ o:spt=”75″ o:preferrelative=”t” path=”m@4@5l@4@11@9@11@9@5xe” filled=”f” stroked=”f”>
<v:stroke joinstyle=”miter” />
– <v:formulas>
<v:f eqn=”if lineDrawn pixelLineWidth 0″ />
<v:f eqn=”sum @0 1 0″ />
<v:f eqn=”sum 0 0 @1″ />
<v:f eqn=”prod @2 1 2″ />
<v:f eqn=”prod @3 21600 pixelWidth” />
<v:f eqn=”prod @3 21600 pixelHeight” />
<v:f eqn=”sum @0 0 1″ />
<v:f eqn=”prod @6 1 2″ />
<v:f eqn=”prod @7 21600 pixelWidth” />
<v:f eqn=”sum @8 21600 0″ />
<v:f eqn=”prod @7 21600 pixelHeight” />
<v:f eqn=”sum @10 21600 0″ />
</v:formulas>
<v:path o:extrusionok=”f” gradientshapeok=”t” o:connecttype=”rect” />
<o:lock v:ext=”edit” aspectratio=”t” />
</v:shapetype>
– <v:shape id=”_x0000_i1025″ type=”#_x0000_t75″ style=”width:76.6pt;height:49.55pt” o:ole=””>
<v:imagedata r:id=”rId5″ o:title=”” />
</v:shape>
<o:OLEObject Type=”Embed” ProgID=”Package” ShapeID=”_x0000_i1025″ DrawAspect=”Icon” ObjectID=”_1529833613″ r:id=”rId6″ />
</w:object>
</w:r>
</w:p>
</w:sdtContent>
</w:sdt>
<w:p w:rsidR=”00150F3A” w:rsidRDefault=”00150F3A” />
+ <w:p w:rsidR=”00150F3A” w:rsidRDefault=”00150F3A”>
<w:bookmarkStart w:id=”0″ w:name=”_GoBack” />
<w:bookmarkEnd w:id=”0″ />
</w:p>
– <w:sectPr w:rsidR=”00150F3A”>
<w:pgSz w:w=”12240″ w:h=”15840″ />
<w:pgMar w:top=”1440″ w:right=”1440″ w:bottom=”1440″ w:left=”1440″ w:header=”720″ w:footer=”720″ w:gutter=”0″ />
<w:cols w:space=”720″ />
<w:docGrid w:linePitch=”360″ />
</w:sectPr>
</w:body>
</w:document>August 25, 2016 at 5:52 pm #3689Hi,
I have no experience with this scenario, so unfortunately, don’t have any advice for you.
I have never looked at how embedded Visio objects are stored. I always presumed that the approach is similar to that of embedded spreadsheets and so on, but don’t know about the format of what is in the Visio file, or if in the WordprocessingML, there is a cached image for the embedded object. But it should be relatively straight-forward to figure out.
Best, Eric
-
AuthorPosts
You must be logged in to reply to this topic.