Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions itext-create-pdf/src/main/java/com/hmkcode/HelloWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,27 @@
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;

public class HelloWorld {
public static void main(String[] args) {
try {

public class HelloWorld
{
public static void main( String[] args )
{
try {

// 1. create the document
Document document = new Document();
// 2. get PdfWriter
// 1. create the document
Document document = new Document();
// 2. get PdfWriter
PdfWriter.getInstance(document, new FileOutputStream("helloworld.pdf"));
// 3. open the document
document.open();
// 4. add the content
document.add(new Paragraph("Hello World!"));
// 5. close the document
document.close();
System.out.println("Document created!");
document.open();
// 4. add the content
document.add(new Paragraph("Hello World!"));
// 5. close the document
document.close();

System.out.println("Document created!");

} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}
}
}
}
}