List of usage examples for com.lowagie.text.pdf PdfWriter getPageNumber
public int getPageNumber()
From source file:io.vertigo.dynamo.plugins.export.pdf.PDFAdvancedPageNumberEvents.java
License:Apache License
/** {@inheritDoc} */ @Override/*from w ww .java2 s. com*/ public void onEndPage(final PdfWriter writer, final Document document) { final int pageN = writer.getPageNumber(); final String text = pageN + " / "; final float len = bf.getWidthPoint(text, 8); cb.beginText(); cb.setFontAndSize(bf, 8); final float width = document.getPageSize().getWidth(); cb.setTextMatrix(width / 2, 30); cb.showText(text); cb.endText(); cb.addTemplate(template, width / 2 + len, 30); }
From source file:io.vertigo.dynamo.plugins.export.pdf.PDFAdvancedPageNumberEvents.java
License:Apache License
/** {@inheritDoc} */ @Override//from w w w .java 2 s. c om public void onCloseDocument(final PdfWriter writer, final Document document) { template.beginText(); template.setFontAndSize(bf, 8); template.showText(String.valueOf(writer.getPageNumber() - 1)); template.endText(); }
From source file:jm.web.Addons.java
License:GNU General Public License
public static void setEncabezado(PdfWriter writer, Document document, String texto) { if (writer.getPageNumber() > 1) { try {/*from w w w. j a v a 2 s . co m*/ PdfPTable encabezado = new PdfPTable(1); encabezado.setTotalWidth(document.right() - document.left() - 120); encabezado.addCell(Addons.setCeldaPDF(texto, Font.HELVETICA, 9, Font.BOLD, Element.ALIGN_LEFT, 0)); encabezado.writeSelectedRows(0, -1, 60, document.top() + 25, writer.getDirectContent()); PdfContentByte cb = writer.getDirectContent(); cb.setLineWidth(2); cb.moveTo(60, document.top() + 10); cb.lineTo(document.right() - document.left() - 58, document.top() + 10); } catch (Exception e) { throw new ExceptionConverter(e); } } }
From source file:jm.web.Addons.java
License:GNU General Public License
public static void setPie(PdfWriter writer, Document document, String rep_pie) { try {//from w w w . j av a 2s . com PdfContentByte cb = writer.getDirectContent(); /*cb.setLineWidth(2); cb.moveTo(60, document.bottomMargin()-5); cb.lineTo(document.right() - document.left()-70, document.bottomMargin()-5); */ PdfPTable pie = new PdfPTable(1); pie.setTotalWidth(document.right() - document.left() - 120); pie.addCell(Addons.setCeldaPDF(rep_pie, Font.HELVETICA, 9, Font.BOLD, Element.ALIGN_CENTER, 0)); pie.addCell(Addons.setCeldaPDF("Pg " + String.valueOf(writer.getPageNumber()), Font.HELVETICA, 9, Font.BOLD, Element.ALIGN_RIGHT, 0)); pie.addCell(Addons.setCeldaPDF( "Reporte diseado por: Jorge Mueses Cevallos. Mvil: 095204832 mail:jorge_mueses@yahoo.com", Font.HELVETICA, 5, Font.BOLD, Element.ALIGN_LEFT, 0)); pie.writeSelectedRows(0, -1, 60, document.bottomMargin() - 10, cb); } catch (Exception e) { throw new ExceptionConverter(e); } }
From source file:org.areasy.common.doclet.document.DocumentEventHandler.java
License:Open Source License
public void onCloseDocument(PdfWriter writer, Document document) { if (pageNumberType == PAGE_NUMBER_FULL) { template.beginText();//from w ww . j ava 2 s .c o m template.setFontAndSize(bf, 8); template.showText(String.valueOf(writer.getPageNumber() - 1)); template.endText(); } }
From source file:org.kuali.kfs.module.purap.pdf.PurapPdf.java
License:Open Source License
/** * Overrides the method in PdfPageEventHelper from itext to write the headerTable, compose the footer and show the * footer.//from w w w.j a v a 2 s. co m * * @param writer The PdfWriter for this document. * @param document The document. * @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document) */ @Override public void onEndPage(PdfWriter writer, Document document) { LOG.debug("onEndPage() started."); PdfContentByte cb = writer.getDirectContent(); cb.saveState(); // write the headerTable headerTable.setTotalWidth(document.right() - document.left()); headerTable.writeSelectedRows(0, -1, document.left(), document.getPageSize().height() - 10, cb); // compose the footer String text = "Page " + writer.getPageNumber() + " of "; float textSize = helv.getWidthPoint(text, 12); float textBase = document.bottom() - 20; cb.beginText(); cb.setFontAndSize(helv, 12); // show the footer float adjust = helv.getWidthPoint("0", 12); cb.setTextMatrix(document.right() - textSize - adjust, textBase); cb.showText(text); cb.endText(); cb.addTemplate(tpl, document.right() - adjust, textBase); cb.saveState(); }
From source file:org.kuali.kfs.module.purap.pdf.PurapPdf.java
License:Open Source License
/** * Overrides the method in the PdfPageEventHelper from itext to put the total number of pages into the template. * * @param writer The PdfWriter for this document. * @param document The document./* w w w . jav a 2 s.co m*/ * @see com.lowagie.text.pdf.PdfPageEventHelper#onCloseDocument(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document) */ @Override public void onCloseDocument(PdfWriter writer, Document document) { LOG.debug("onCloseDocument() started."); tpl.beginText(); tpl.setFontAndSize(helv, 12); tpl.setTextMatrix(0, 0); tpl.showText("" + (writer.getPageNumber() - 1)); tpl.endText(); }
From source file:org.kuali.kfs.module.purap.pdf.PurchaseOrderQuoteRequestsPdf.java
License:Open Source License
/** * Overrides the method in PdfPageEventHelper from itext to compose the footer and show the * footer./*from ww w. ja v a 2 s .co m*/ * * @param writer The PdfWriter for this document. * @param document The document. * @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document) */ public void onEndPage(PdfWriter writer, Document document) { LOG.debug("onEndPage() started."); PdfContentByte cb = writer.getDirectContent(); cb.saveState(); // compose the footer String text = "Page " + writer.getPageNumber() + " of "; float textSize = helv.getWidthPoint(text, 12); float textBase = document.bottom() - 20; cb.beginText(); cb.setFontAndSize(helv, 12); // show the footer float adjust = helv.getWidthPoint("0", 12); cb.setTextMatrix(document.right() - textSize - adjust, textBase); cb.showText(text); cb.endText(); cb.addTemplate(tpl, document.right() - adjust, textBase); cb.saveState(); }
From source file:org.kuali.kfs.module.purap.pdf.PurchaseOrderQuoteRequestsPdf.java
License:Open Source License
/** * Overrides the method in the PdfPageEventHelper from itext to put the total number of pages into the template. * //from w w w.j a v a 2 s . c om * @param writer The PdfWriter for this document. * @param document The document. * @see com.lowagie.text.pdf.PdfPageEventHelper#onCloseDocument(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document) */ public void onCloseDocument(PdfWriter writer, Document document) { LOG.debug("onCloseDocument() started."); tpl.beginText(); tpl.setFontAndSize(helv, 12); tpl.setTextMatrix(0, 0); tpl.showText("" + (writer.getPageNumber() - 1)); tpl.endText(); }
From source file:org.kuali.ole.module.purap.pdf.PurapPdf.java
License:Educational Community License
/** * Overrides the method in PdfPageEventHelper from itext to write the headerTable, compose the footer and show the * footer./*from ww w . j a v a 2 s. com*/ * * @param writer The PdfWriter for this document. * @param document The document. * @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document) */ public void onEndPage(PdfWriter writer, Document document) { LOG.debug("onEndPage() started."); PdfContentByte cb = writer.getDirectContent(); cb.saveState(); // write the headerTable headerTable.setTotalWidth(document.right() - document.left()); headerTable.writeSelectedRows(0, -1, document.left(), document.getPageSize().height() - 10, cb); // compose the footer String text = "Page " + writer.getPageNumber() + " of "; float textSize = helv.getWidthPoint(text, 12); float textBase = document.bottom() - 20; cb.beginText(); cb.setFontAndSize(helv, 12); // show the footer float adjust = helv.getWidthPoint("0", 12); cb.setTextMatrix(document.right() - textSize - adjust, textBase); cb.showText(text); cb.endText(); cb.addTemplate(tpl, document.right() - adjust, textBase); cb.saveState(); }