如何使用docx dll保存图像 [英] How to save Images using docx dll
问题描述
我必须使用docx dll创建一个文档,在顶部我需要向文档添加四个文本值。在这里我可以将这些文本添加到docx中,然后使用doc.Save()进行保存;方法。
之后,我需要将一些图像添加到同一文档中,我可以根据我的要求添加这些图像。之后我使用doc.SaveAs(Path);保存最终文档的方法。但在执行另存为方法时,上面添加的文本会自动删除。即在最终文件中,我的图像不是文字。
C#:使用DocX以编程方式创建和处理Word文档 [ ^ ]
提前致谢
I have to create a document using docx dll, in the top section i need to add four text values to the document. here i can add those text to the docx and i save using doc.Save(); method.
after that i need to add some images to same document and i can add those images based on my requirement. after that am using doc.SaveAs("Path"); method to save the final document.but while doing the save as method the above added text is removing automatically. ie in the final document i have onlt the image not the text.
C#: Create and Manipulate Word Documents Programmatically Using DocX[^]
Thanks in advance
推荐答案
为什么不问你引用文章的作者?找到评论和讨论部分,点击添加评论或问题并提出您的问题。作者将收到通知并进行更改以回答您的问题。只需点击以下链接:
http://www.codeproject.com/script/Forums/Edit.aspx?fid=1843475&floc=/Articles/660478/Csharp-Create-and-Manipulate -Word-Documents-Progra [ ^ ]。
-SA
Why not asking the author of the article you referenced? Locate "Comments and Discussion" section at the end, click "Add a Comment or Question" and ask your question. The author will receive a notification and get a change to answer you. Just click in the link below:
http://www.codeproject.com/script/Forums/Edit.aspx?fid=1843475&floc=/Articles/660478/Csharp-Create-and-Manipulate-Word-Documents-Progra[^].
—SA
您可能覆盖了同一个文件。修改时,加载文件并进行修改并保存。例如:
you may have overwrite the same file. when you modify, load the file and do the modification and save it. for example :
//create new document and add some text
using (DocX doc= DocX.Create(filename))
{
doc.InsertParagraph("This is my first paragraph");
// save the document in given path
doc.SaveAs(path)
}
// load from your path
using (DocX document = DocX.Load(path))
{
//and modify it
document.InsertParagraph("This is my second paragraph");
document.Save();
}
这篇关于如何使用docx dll保存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!