import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.Font; import com.itextpdf.text.FontFactory; import com.itextpdf.text.PageSize; import com.itextpdf.text.Paragraph; import com.itextpdf.text.pdf.CMYKColor; import com.itextpdf.text.pdf.PdfWriter; public class OutputPdf { private static final String URL = "d:/HelloWorld.pdf"; public static void main(String[] args) throws IOException { Document document = new Document(PageSize.A4, 20, 20, 20, 20); try { BufferedReader in = null; String b ; in = new BufferedReader(new InputStreamReader( new FileInputStream("D:/SGPREPORT.SGD071D1.20120812.txt"),"UTF-8")); PdfWriter.getInstance(document, new FileOutputStream(URL)); document.open(); while((b = in.readLine()) != null) { System.out.println(b); document.add(new Paragraph(b,FontFactory.getFont(FontFactory.COURIER, 5, Font.BOLD ,new CMYKColor(16, 244, 15, 89)))); } document.close(); in.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } } }