List of usage examples for com.itextpdf.text Document bottom
public float bottom()
From source file:fll.util.SimpleFooterHandler.java
License:Open Source License
@Override public void onEndPage(final PdfWriter writer, final Document document) { final PdfContentByte cb = writer.getDirectContent(); cb.saveState();// w ww .j a va 2 s . co m // compose the footer final String text = "Page " + writer.getPageNumber() + " of "; final float textSize = _headerFooterFont.getWidthPoint(text, 12); final float textBase = document.bottom() - 20; cb.beginText(); cb.setFontAndSize(_headerFooterFont, 12); final float adjust = _headerFooterFont.getWidthPoint("0", 12); cb.setTextMatrix(document.right() - textSize - adjust, textBase); cb.showText(text); cb.endText(); cb.addTemplate(_tpl, document.right() - adjust, textBase); cb.restoreState(); }
From source file:net.digitstar.vanadio.AbstractReportPdf.java
License:Apache License
protected void writeHeaderFooter(Document document, PdfReader reader, PdfStamper writer, int pag, int totalPages, ReportOptions reportOptions) { if (reportOptions.isShowHeader()) { if (pag != 1 || reportOptions.isShowHeaderOnFirstPage()) { PdfPTable header = createHeader(document, pag, totalPages, reportOptions); header.writeSelectedRows(0, -1, document.left(), document.top() + header.getTotalHeight(), writer.getOverContent(pag)); }/*from w ww . j av a 2 s . c o m*/ } if (reportOptions.isShowFooter()) { if (pag != 1 || reportOptions.isShowFooterOnFirstPage()) { PdfPTable footer = createFooter(document, pag, totalPages, reportOptions); footer.writeSelectedRows(0, -1, document.left(), document.bottom() - footer.getTotalHeight(), writer.getOverContent(pag)); } } }
From source file:org.openlmis.web.view.pdf.PdfPageEventHandler.java
License:Open Source License
private void writeCurrentDate(Document document, PdfContentByte contentByte) { contentByte.setTextMatrix(document.left() + textAdjustment, document.bottom()); String dateText = DATE_FORMAT.format(new Date()); contentByte.showText(dateText);// w w w .j ava 2 s.c o m }
From source file:org.openlmis.web.view.pdf.PdfPageEventHandler.java
License:Open Source License
private void writePageNumber(PdfWriter writer, Document document, PdfContentByte contentByte) { String pageNumberText = messageService.message("label.page.of", writer.getPageNumber()) + " "; float pageNumberTextSize = baseFont.getWidthPoint(pageNumberText, FOOTER_TEXT_SIZE); contentByte.setTextMatrix(document.right() - pageNumberTextSize - textAdjustment, document.bottom()); contentByte.showText(pageNumberText); contentByte.addTemplate(pageNumberTemplate, document.right() - textAdjustment, document.bottom()); }
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 w ww. j a va2 s .c om 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./*from w w w.j a v a 2 s. c om*/ * * @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); } }