我是 .Net 中 aspose.word 的新手。
我有一个模板文档,我需要用附件替换 word 文档中的文本字段。我有 excel 和 pdf 文档作为附件。
哪天可以帮我在word文档中添加附件吗?
谢谢,乔伊
我是 .Net 中 aspose.word 的新手。
我有一个模板文档,我需要用附件替换 word 文档中的文本字段。我有 excel 和 pdf 文档作为附件。
哪天可以帮我在word文档中添加附件吗?
谢谢,乔伊
你可以使用 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);
将数据绑定到适当的字段后,将其转换为 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 对象插入到文档中。请参考以下文章。
我与 Aspose 合作,担任开发人员传道者。