List of usage examples for com.itextpdf.layout Document close
@Override public void close()
From source file:Utils.PdfUtil.java
public void writeDocument() { try {/*from w w w .j a va2 s . co m*/ PdfWriter writer = new PdfWriter(createDestination()); PdfDocument pdf = new PdfDocument(writer); Document document = new Document(pdf); mCommonFont = PdfFontFactory.createFont(FontConstants.TIMES_ROMAN); addTitle(document); addContent(document); addFooter(document); document.close(); } catch (Exception ex) { Logger.getLogger(PdfUtil.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:wbs.jsf1.pdf.LottoReceiptBean0.java
public byte[] createPdfFrom(Lottoschein lottoschein) { try {//from ww w . j a v a 2 s.co m zahlen = lottoschein; ByteArrayOutputStream pdfStream = new ByteArrayOutputStream(); PdfWriter writer = new PdfWriter(pdfStream); PdfDocument pdf = new PdfDocument(writer); PageSize pageSize = new PageSize(PageSize.A6); Document document = new Document(pdf, pageSize); document.setMargins(20, 20, 40, 20); PdfFont font = PdfFontFactory.createFont(FontConstants.HELVETICA); PdfFont bold = PdfFontFactory.createFont(FontConstants.HELVETICA_BOLD); // Header document.add(getHeaderTable()); // Lottozahlen auflisten document.add(getZiehungsDatenTable(font, bold)); // Losnummer document.add(getLosnummerTable(font, bold)); // Spieltage document.add(getSpieltageTable(font, bold)); // Laufzeit document.add(getLaufzeitTable(font, bold)); // Betrag document.add(getBetragTable(font, bold)); document.close(); LOG.log(Level.INFO, "PDF succesfully created."); return pdfStream.toByteArray(); } catch (IOException ex) { Logger.getLogger(LottoReceiptBean0.class.getName()).log(Level.SEVERE, "pdf creation problem", ex); } return null; }