Aspose.word:添加pdf附件到word文件

本文关键字:word 文件 pdf 添加 Aspose | 更新日期: 2023-09-27 18:08:59

我是新人。

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

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

谢谢,快乐

Aspose.word:添加pdf附件到word文件

将数据绑定到适当的字段后,将其转换为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);
}

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

使用DocumentBuilder插入文档元素

我是Aspose的开发者布道师

你可以使用InsertOleObject


try this:

 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);