繁体   English   中英

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

[英]Aspose.word :Add pdf attachment to word file

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

我有一个模板文档,我需要通过附件替换word文档中的文本字段。我有excel和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.Words的查找和替换功能来查找文本并将其替换为图像和OLE对象。 您可以使用DocumentBuilder.InsertImage将图像插入到文档中,并使用DocumentBuilder.InsertOleObject方法将文件中的嵌入或链接OLE对象插入到文档中。 请参阅以下文章。

使用DocumentBuilder插入文档元素

我和Aspose一起担任开发人员传道人。

您可以使用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);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM