Word格式处理控件Spire.Doc功能演示:将外部文件插入Java中的Word文档

*这么优秀的国产工具怎能错过呢!在线下单专享“一口价”,查看优惠价格!想要获取更多福利的朋友可以咨询在线客服哦~

示例代码如下:

import com.spire.doc.Document;import com.spire.doc.FileFormat;import com.spire.doc.Section;import com.spire.doc.documents.OleObjectType;import com.spire.doc.documents.Paragraph;import com.spire.doc.fields.DocOleObject;import com.spire.doc.fields.DocPicture;public class InsertOLE {    public static void main(String[] args) {        //Create a Document object and load a Word document        Document doc = new Document();        doc.loadFromFile("C:\Users\Administrator\Desktop\source.docx");        //Get the last section        Section section = doc.getLastSection();        //Add a paragraph        Paragraph par = section.addParagraph();        //Load an image which will be inserted to Word document representing the embedded file        DocPicture pdfIcon = new DocPicture(doc);        pdfIcon.loadImage("C:\Users\Administrator\Desktop\pdf-icon.jpg");        //Insert a PDF file to the Word document as an OLE object        par.appendOleObject("C:\Users\Administrator\Desktop\report.pdf", pdfIcon, OleObjectType.Adobe_Acrobat_Document);        //Save to another file        doc.saveToFile("EmbedDocument.docx", FileFormat.Docx_2013);    }}

Word格式处理控件Spire.Doc功能演示:将外部文件插入Java中的Word文档让人兴奋的是整合所有格式API处理套包Spire.office for Java正在 火热销售中!联系客服立马1分钟了解全部咨询!
标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年10月17日
下一篇 2020年10月17日

相关推荐

发表回复

登录后才能评论