void makePDF() { File f = new File(pdf); f.delete(); Rectangle pageSize = new Rectangle(400, 400); pageSize.setBackgroundColor(new java.awt.Color(0x77, 0x00, 0xff)); Document document = new Document(pageSize); try { PdfWriter.getInstance(document, new FileOutputStream(pdf)); document.open(); Chunk myLogo = new Chunk(Image.getInstance(logo), 0, -45); Paragraph p = new Paragraph(myLogo); p.setAlignment(Image.MIDDLE); p.add(" The big deal site"); document.add(new Paragraph("\n\n")); document.add(p); document.add(new Paragraph("\n\n\n\n")); document.add(new Paragraph("Dear ${name_here}")); document.add(new Paragraph("Thank you for buying this ticket: " + "0320090001")); document.add(new Paragraph("\n")); document.add(new Paragraph( "The draw ends on ${date} and the prize will be notified on ${date+182 days}" + " (the reason for the delay is to prevent credit card fraud.)")); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } document.close();
Monday, July 26, 2010
A quick pdf using iText and Java
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment