open a pdf file and write to it in java

Solutions on MaxInterview for open a pdf file and write to it in java by the best coders in the world

showing results for - "open a pdf file and write to it in java"
Henry
01 Feb 2020
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}