1// Create a PdfDocument instance
2PdfDocument doc = new PdfDocument();
3
4try {
5 // Write some text on page 1
6 doc.writeText("Hello, World!"); // automatically creates a blank page
7
8 // Save document to file
9 doc.save("sample_doc1.pdf");
10 doc.close();
11} catch (IOException | PdfException e) {
12 // TODO Auto-generated catch block
13 e.printStackTrace();
14}