日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

iText官方教程

發布時間:2023/12/14 编程问答 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 iText官方教程 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

如果要導出PDF文件,首選當然是iText,從網上也找了些資料,有很多,也有些亂。

自己做了個例子,感覺還是很淺,深入的內容還是研究不透。下載了官方的jar包,本來想看看

里面的Demo,結果只有api文檔。資料還真是不好找。

今天發現官方還是有很多例子代碼的。

下載地址:http://itextpdf.com/examples/

iText官網: http://itextpdf.com/

在首頁下面有個Online resources

下面有個 example code 的鏈接,點擊進入后,發現里面是個很華麗的教程,配備實例代碼!

http://itextpdf.com/book/examples.php

這比網上其他人寫的博客要權威多了,發現這個好東西,和大家分享一下。

里面有16章,內容相當全,還有演示視頻。

這是HelloWord例子,其他自己研究吧:

/** This class is part of the book "iText in Action - 2nd Edition"* written by Bruno Lowagie (ISBN: 9781935182610)* For more info, go to: http://itextpdf.com/examples/* This example only works with the AGPL version of iText.*/package part1.chapter01;import java.io.FileOutputStream; import java.io.IOException;import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.Paragraph; import com.itextpdf.text.pdf.PdfWriter;/*** First iText example: Hello World.*/ public class HelloWorld {/** Path to the resulting PDF file. */public static final String RESULT= "results/part1/chapter01/hello.pdf";/*** Creates a PDF file: hello.pdf* @param args no arguments needed*/public static void main(String[] args)throws DocumentException, IOException {new HelloWorld().createPdf(RESULT);}/*** Creates a PDF document.* @param filename the path to the new PDF document* @throws DocumentException * @throws IOException */public void createPdf(String filename)throws DocumentException, IOException {// step 1Document document = new Document();// step 2PdfWriter.getInstance(document, new FileOutputStream(filename));// step 3document.open();// step 4document.add(new Paragraph("Hello World!"));// step 5document.close();} }


總結

以上是生活随笔為你收集整理的iText官方教程的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。