简体   繁体   English

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

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

I am new to aspose.word in .Net. 我是.Net中aspose.word的新手。

I have a template document where I need to replace text fields from a word document by the attachment.I have excel and pdf documents as attachments. 我有一个模板文档,我需要通过附件替换word文档中的文本字段。我有excel和pdf文档作为附件。

Can someday help me to add attachment to the word document? 有一天可以帮我添加word文档的附件吗?

Thanks, Joy 谢谢,乔伊

Once you've bound your data to the appropriate fields, convert it to a PDF. 将数据绑定到相应字段后,将其转换为PDF。 Then you can join the two PDFs together. 然后,您可以将两个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);
}

I suggest you please use find and replace feature of Aspose.Words to find a text and replace it with image and OLE object. 我建议你使用Aspose.Words的查找和替换功能来查找文本并将其替换为图像和OLE对象。 You can insert an image into document using DocumentBuilder.InsertImage and insert an embedded or linked OLE object from a file into the document using DocumentBuilder.InsertOleObject method. 您可以使用DocumentBuilder.InsertImage将图像插入到文档中,并使用DocumentBuilder.InsertOleObject方法将文件中的嵌入或链接OLE对象插入到文档中。 Please refer to the following article. 请参阅以下文章。

Use DocumentBuilder to Insert Document Elements 使用DocumentBuilder插入文档元素

I work with Aspose as Developer evangelist. 我和Aspose一起担任开发人员传道人。

you can use InsertOleObject 您可以使用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);

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

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