【问题标题】:How to insert an image in a word document and maintain the original size using openxml如何在word文档中插入图片并使用openxml保持原始大小
【发布时间】:2015-09-02 18:40:24
【问题描述】:

我试过这样做Inserting Image into DocX using OpenXML and setting the size,但我没有找到“new BitmapImage”的参考

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

【问题讨论】:

    标签: c# image ms-word openxml


    【解决方案1】:

    看看这个: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));
    

    【讨论】:

      猜你喜欢
      • 2017-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多