If you want to export a PDF file, the first choice is itext. You have also found some information from the Internet, and there are a lot of things.
I made an example by myself, and it seems that it is still very simple, and the in-depth content is still hard to be studied. Download the official jar package. I wanted to see it.
In the demo, only the API documentation is returned. The information is really hard to find.
Today, we found that there are still many examples of code on the official website.
: Http://itextpdf.com/examples/
Itext Official Website: http://itextpdf.com/
There is an online resources under the Home Page
Below is a link to example code. After clicking it, we found that it was a very gorgeous tutorial with instance code!
Http://itextpdf.com/book/examples.php
This is more authoritative than the blogs written by others on the Internet. I 'd like to share this with you.
There are 16 chapters in it, the content is quite complete, and there are Demo videos.
This is an example of helloword. Let's study it by yourself:
/* * 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 1 Document document = new Document(); // step 2 PdfWriter.getInstance(document, new FileOutputStream(filename)); // step 3 document.open(); // step 4 document.add(new Paragraph("Hello World!")); // step 5 document.close(); }}