List of usage examples for com.itextpdf.text ExceptionConverter ExceptionConverter
public ExceptionConverter(Exception ex)
From source file:jdbreport.model.io.pdf.itext5.ReportFontMapper.java
License:Apache License
public BaseFont awtToPdf(String fontName) { try {/*from w ww . ja v a 2s . co m*/ BaseFontParameters p = getBaseFontParameters(fontName); if (p != null) { return BaseFont.createFont(p.fontName, BaseFont.IDENTITY_H, p.embedded, p.cached, p.ttfAfm, p.pfb); } } catch (DocumentException | IOException e) { throw new ExceptionConverter(e); } return null; }
From source file:net.atomique.ksar.export.FilePDF.java
License:Open Source License
public void onEndPage(PdfWriter writer, Document document) { try {/*from www . j av a 2 s. co m*/ int pageNumber = writer.getPageNumber(); String text = "Page " + pageNumber + "/" + total_pages; String hostName = mysar.myparser.gethostName(); String date = mysar.myparser.getDate(); pdfcb.beginText(); pdfcb.setFontAndSize(bf, 10); pdfcb.setColorFill(new BaseColor(0x00, 0x00, 0x00)); if (pageNumber > 1) { pdfcb.showTextAligned(PdfContentByte.ALIGN_LEFT, hostName, pdfmargins, pdfheight - pdfmargins, 0); pdfcb.showTextAligned(PdfContentByte.ALIGN_RIGHT, date, pdfwidth - pdfmargins, pdfheight - pdfmargins, 0); } pdfcb.showTextAligned(PdfContentByte.ALIGN_RIGHT, text, pdfwidth - pdfmargins, pdfmargins - 5, 0); pdfcb.endText(); } catch (Exception e) { throw new ExceptionConverter(e); } }
From source file:pdf.FooterHeader.java
License:Open Source License
@Override public void onEndPage(PdfWriter writer, Document document) { PdfPTable table = new PdfPTable(3); try {/*from ww w . j ava2 s . co m*/ if (document.getPageNumber() > 1) { table.setWidths(new int[] { 24, 24, 2 }); table.setTotalWidth(527); table.setLockedWidth(true); table.getDefaultCell().setFixedHeight(20); table.getDefaultCell().setBorder(Rectangle.BOTTOM); table.addCell(header); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(String.format("Seite %d von", writer.getPageNumber())); PdfPCell cell = new PdfPCell(Image.getInstance(total)); cell.setBorder(Rectangle.BOTTOM); table.addCell(cell); table.writeSelectedRows(0, -1, 34, 803, writer.getDirectContent()); } } catch (DocumentException de) { throw new ExceptionConverter(de); } PdfContentByte cb = writer.getDirectContent(); if (document.getPageNumber() > 1) { footer = new Phrase(document.getPageNumber() - 2); ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, footer, (document.right() - document.left() - 30) / 2 + document.leftMargin(), document.bottom() + 10, 0); } }
From source file:se.inera.intyg.rehabstod.service.export.pdf.PageNumberingEventHandler.java
License:Open Source License
/** * Adds a header to every page.//w w w . j av a 2 s . com * * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(com.itextpdf.text.pdf.PdfWriter, * com.itextpdf.text.Document) */ @Override public void onEndPage(PdfWriter writer, Document document) { try { PdfPTable table = new PdfPTable(2); table.setTotalWidth(document.getPageSize().getWidth()); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.addCell(new Phrase(String.valueOf(writer.getPageNumber()), PdfExportConstants.TABLE_CELL_NORMAL)); PdfPCell cell = new PdfPCell(Image.getInstance(total)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); table.writeSelectedRows(0, -1, document.left(), document.bottom(), writer.getDirectContent()); } catch (DocumentException de) { throw new ExceptionConverter(de); } }