/** {@inheritDoc} */ @Override public void onCloseDocument(PdfWriter writer, Document document) { template.beginText(); template.setFontAndSize(bf, 8); template.showText(String.valueOf(writer.getPageNumber() - 1)); template.endText(); } }
private void setPagenumberToTOC(Document document){ if(templateList.size() > 0){ PdfTemplate currentPageTemplate_ = (PdfTemplate)templateList.remove(0); currentPageTemplate_.beginText(); currentPageTemplate_.setFontAndSize(PdfUtils.BASEFONT_MINCHO,10); currentPageTemplate_.showText(document.getPageNumber() + ""); currentPageTemplate_.endText(); } }
/** {@inheritDoc} */ @Override public void onCloseDocument(PdfWriter writer, Document document) { template.beginText(); template.setFontAndSize(bf, 8); template.showText(String.valueOf(writer.getPageNumber() - 1)); template.endText(); } }
public void onCloseDocument(PdfWriter writer, Document document) { // fill template with the total page number of this document. template_.beginText(); template_.setFontAndSize(PdfUtils.BASEFONT_MINCHO, size_); template_.showText(String.valueOf(writer.getPageNumber() - 1)); template_.endText(); }
/** * 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. * @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(); }
/** * 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. * @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(); }
template.beginText(); template.setFontAndSize(this.baseFont, 12); template.setTextMatrix(50 - this.baseFont.getWidthPoint(String.valueOf(this.writer.getPageNumber()), 12), 0);
/** * Draw text in the center of the specified box. * * @param text text * @param font font * @param box box to put text int * @param fontColor colour */ public void drawText(String text, Font font, Rectangle box, Color fontColor) { template.saveState(); // get the font DefaultFontMapper mapper = new DefaultFontMapper(); BaseFont bf = mapper.awtToPdf(font); template.setFontAndSize(bf, font.getSize()); // calculate descent float descent = 0; if (text != null) { descent = bf.getDescentPoint(text, font.getSize()); } // calculate the fitting size Rectangle fit = getTextSize(text, font); // draw text if necessary template.setColorFill(fontColor); template.beginText(); template.showTextAligned(PdfContentByte.ALIGN_LEFT, text, origX + box.getLeft() + 0.5f * (box.getWidth() - fit.getWidth()), origY + box.getBottom() + 0.5f * (box.getHeight() - fit.getHeight()) - descent, 0); template.endText(); template.restoreState(); }
tmp.beginText(); tmp.setFontAndSize(bf, 12); tmp.moveText(0, 7);