List of usage examples for com.itextpdf.text.pdf PdfContentByte showTextAligned
public void showTextAligned(final int alignment, final String text, final float x, final float y, final float rotation)
From source file:printInv.GenerateInvoice.java
public void printPageNumber(PdfContentByte cb) { cb.beginText();//from www . j a v a 2 s.c o m cb.setFontAndSize(bfBold, 8); cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Page No. " + (pageNumber + 1), 570, 20, 0); cb.endText(); pageNumber++; }
From source file:ryerson.daspub.artifact.PublishQRTagSheetTask.java
License:Open Source License
/** * Draw a text label on the current page. * @param Writer PDF writer/* w ww .j a v a 2 s .c om*/ * @param Text * @param x * @param y * @param alignment * @throws DocumentException * @throws IOException */ private void drawLabel(PdfWriter Writer, String Text, int x, int y, int alignment) throws DocumentException, IOException { PdfContentByte cb = Writer.getDirectContent(); BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.saveState(); cb.beginText(); cb.setFontAndSize(bf, 9); cb.showTextAligned(alignment, Text, x, y, 0); cb.endText(); cb.restoreState(); }
From source file:valstreamtools.ValStrSplitPage.java
private void createPageNo(String inputFileName, String outputFileName, float pageHeight) throws IOException, DocumentException { PdfReader pdfReader = new PdfReader(inputFileName); PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileOutputStream(outputFileName)); int pageCount = pdfReader.getNumberOfPages(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED); for (int i = 1; i <= pageCount; i++) { PdfContentByte content = pdfStamper.getOverContent(i); content.beginText();//w w w . j a v a 2 s. com content.setFontAndSize(bf, 8); content.showTextAligned(PdfContentByte.ALIGN_LEFT, "Page " + i + "/" + pageCount, 5, pageHeight - 15, 0); content.endText(); } pdfStamper.close(); pdfReader.close(); }