From d9e7dc4a87af4357cd9f39c8214c38ac9535e056 Mon Sep 17 00:00:00 2001 From: Tatchai Russameroj Date: Tue, 17 Oct 2017 02:42:22 +0700 Subject: [PATCH] Formatted codes --- .../src/main/java/com/hmkcode/HelloWorld.java | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/itext-create-pdf/src/main/java/com/hmkcode/HelloWorld.java b/itext-create-pdf/src/main/java/com/hmkcode/HelloWorld.java index 650ad0cc..6c1c8098 100644 --- a/itext-create-pdf/src/main/java/com/hmkcode/HelloWorld.java +++ b/itext-create-pdf/src/main/java/com/hmkcode/HelloWorld.java @@ -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(); - } - } + } + } }