簡體   English   中英

如何在word文檔中插入圖片並使用openxml保持原始大小

[英]How to insert an image in a word document and maintain the original size using openxml

我嘗試這樣做使用 OpenXML 將圖像插入 DocX 並設置大小,但我沒有找到“new BitmapImage”的參考

我在 ASP.NET MVC 應用程序中的 Visual Studio 2013 上使用框架 .NET 4.5

看看這個: MSDN基本上你必須使用這個:注意 ImagePartType

MainDocumentPart mainPart = wordprocessingDocument.MainDocumentPart;
ImagePart imagePart = mainPart.AddImagePart(ImagePartType.Jpeg);
using (FileStream stream = new FileStream(fileName, FileMode.Open))
{
   imagePart.FeedData(stream);
}
AddImageToBody(wordprocessingDocument, mainPart.GetIdOfPart(imagePart));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM