【问题标题】:Aspose.word :Add pdf attachment to word fileAspose.word : 添加pdf附件到word文件
【发布时间】:2016-09-26 05:26:55
【问题描述】:

我是 .Net 中 aspose.word 的新手。

我有一个模板文档,我需要用附件替换 word 文档中的文本字段。我有 excel 和 pdf 文档作为附件。

哪天可以帮我在word文档中添加附件吗?

谢谢, 欢乐

【问题讨论】:

标签: c# .net aspose.words


【解决方案1】:

将数据绑定到适当的字段后,将其转换为 PDF。然后您可以将两个 PDF 合并在一起。

using (var ms = new MemoryStream())
{
    // save Aspose doc to stream as pdf
    doc.Save(ms, SaveFormat.Pdf);
    ms.Position = 0;

    // append doc
    var pdf = new PdfDocument(ms);
    pdf.Append(doc);
    pdf.Save(fileName);
}

【讨论】:

    【解决方案2】:

    我建议您请使用 Aspose.Words 的find and replace 功能查找文本并将其替换为图像和 OLE 对象。您可以使用 DocumentBuilder.InsertImage 将图像插入到文档中,并使用 DocumentBuilder.InsertOleObject 方法将文件中的嵌入或链接的 OLE 对象插入到文档中。请参考以下文章。

    Use DocumentBuilder to Insert Document Elements

    我与 Aspose 合作,担任开发人员传道者。

    【讨论】:

      【解决方案3】:

      你可以使用 InsertOleObject


      试试这个:

       doc = new Document();
          DocumentBuilder builder = new DocumentBuilder(doc);
          Stream memStream = File.OpenRead("addreess+file.xls");
          Shape oleObject = builder.InsertOleObject(memStream, "AcroExch.Document.7"", false, null);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-03-01
        • 2017-11-15
        • 1970-01-01
        • 1970-01-01
        • 2017-09-17
        • 1970-01-01
        相关资源
        最近更新 更多