使用小罐子
<dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>5.2.0</version></dependency><dependency> <groupId>com.itextpdf</groupId> <artifactId>itext-asian</artifactId> <version>5.2.0</version></dependency>
創建導出
軟件包com.os.core.util.file.exportpdf; import com.itextpdf.text。 Java.io.fileOutputStream;/** *由Pengsonghe於2016/10/20/20 0020創建。 fileOutputStream(“ d:/helloworld.pdf”)); writer.setpdfversion(pdfwriter.pdf_version_1_7); document.AddCreationDate(); document.AddCreator(“飛翔家族”); document.Addtitle(“導出pdf”); document.addkeywords(“ enterf”); document.AddSubject(“飛翔家族導出pdf”); document.open(); //處理中文,需要itextasian.jar支持fontSelector selector = new fontSelector(); selector.addfont(fontfactory.getfont(fontfactory.times_roman,12)); selector.addfont(fontfactory.getfont(“ stsongstd-light”,“ unigb-ucs2-h”,basefont.not_embedded));短語短語= selector.process(“ helloword !你好。/u4fdd/u5b58”); document.Add(新段落(短語)); //添加新頁//document.newpage(); //writer.setPageEmpty(False); //document.add(新段(“ new page”)); document.close(); } catch(filenotfoundException e){e.printstacktrace(); } catch(documentException e){e.printstacktrace(); }}}}以上這篇使用itextpdf操作pdf的實例講解就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。 ,也希望大家多多支持武林網。