Note that there are some explanatory texts on larger screens.

plurals
  1. POImages are not coming after creating word Document through Open XML
    text
    copied!<p>I am Creating a word document through the c# with the use of OpenXMl sdk. I am converting all my html page to word document but while converting i am giving a absolute address for my images and after converting it is coming perfectly in my system but when i am trying to take this document to other system the Images are Not Coming there.</p> <p>I checked the media Directory all images are there but with different Name.</p> <p>my document is converted but I am Using this mathod.</p> <pre><code> using (WordprocessingDocument myDoc = WordprocessingDocument.Open(documentPath, true)) { XNamespace w = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"; XNamespace r = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"; string altChunkId = "AltChunkId1"; MainDocumentPart mainPart = myDoc.MainDocumentPart; AlternativeFormatImportPart chunk = mainPart.AddAlternativeFormatImportPart("application/xhtml+xml", altChunkId); using (Stream chunkStream = chunk.GetStream(FileMode.Create, FileAccess.Write)) using (StreamWriter stringStream = new StreamWriter(chunkStream)) stringStream.Write(html); XElement altChunk = new XElement(w + "altChunk", new XAttribute(r + "id", altChunkId) ); XDocument mainDocumentXDoc = GetXDocument(myDoc); mainDocumentXDoc.Root .Element(w + "body") .Elements(w + "p") .Last() .AddAfterSelf(altChunk); SaveXDocument(myDoc, mainDocumentXDoc); } private static XDocument GetXDocument(WordprocessingDocument myDoc) { // Load the main document part into an XDocument XDocument mainDocumentXDoc; using (Stream str = myDoc.MainDocumentPart.GetStream()) using (XmlReader xr = XmlReader.Create(str)) mainDocumentXDoc = XDocument.Load(xr); return mainDocumentXDoc; } private static void SaveXDocument(WordprocessingDocument myDoc, XDocument mainDocumentXDoc) { // Serialize the XDocument back into the part using (Stream str = myDoc.MainDocumentPart.GetStream( FileMode.Create, FileAccess.Write)) using (XmlWriter xw = XmlWriter.Create(str)) mainDocumentXDoc.Save(xw); } </code></pre> <p>and this will generate a <strong>afchunk.dat</strong> file which is showing in the content and the Absolute path.</p> <p>Basically i doesn't want to create a file through all coding i just want to convert the .html to .docx file . </p> <p>so can any one tell me how can i convert without getting error in html.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload