Example usage for com.itextpdf.text.pdf PdfContentByte setFontAndSize

List of usage examples for com.itextpdf.text.pdf PdfContentByte setFontAndSize

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfContentByte setFontAndSize.

Prototype

public void setFontAndSize(final BaseFont bf, final float size) 

Source Link

Document

Set the font and the size for the subsequent text writing.

Usage

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();//from   w w w  .  ja  v  a  2 s .c o  m
        content.setFontAndSize(bf, 8);
        content.showTextAligned(PdfContentByte.ALIGN_LEFT, "Page " + i + "/" + pageCount, 5, pageHeight - 15,
                0);
        content.endText();
    }
    pdfStamper.close();
    pdfReader.close();
}