Example usage for com.lowagie.text Document getPageNumber

List of usage examples for com.lowagie.text Document getPageNumber

Introduction

In this page you can find the example usage for com.lowagie.text Document getPageNumber.

Prototype


public int getPageNumber() 

Source Link

Document

Returns the current page number.

Usage

From source file:biblivre3.administration.reports.BaseBiblivreReport.java

License:Open Source License

@Override
public void onEndPage(PdfWriter writer, Document document) {
    try {/*from w  w  w  .  j  av  a  2 s .  c  om*/
        Rectangle page = document.getPageSize();

        PdfPTable head = new PdfPTable(1);
        PdfPCell cell = new PdfPCell(new Paragraph(this.getText("REPORTS_HEADER")));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setBorder(Rectangle.BOTTOM);
        head.addCell(cell);
        head.setTotalWidth((page.width() / 2) - document.leftMargin());
        head.writeSelectedRows(0, -1, document.leftMargin(),
                page.height() - document.topMargin() + head.getTotalHeight(), writer.getDirectContent());

        PdfPTable date = new PdfPTable(1);
        PdfPCell dateCell = new PdfPCell(new Paragraph(dateFormat.format(generationDate)));
        dateCell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        dateCell.setVerticalAlignment(PdfPCell.ALIGN_CENTER);
        dateCell.setBorder(Rectangle.BOTTOM);
        date.addCell(dateCell);
        date.setTotalWidth((page.width() / 2) - document.rightMargin());
        date.writeSelectedRows(0, -1, (page.width() / 2),
                page.height() - document.topMargin() + head.getTotalHeight(), writer.getDirectContent());

        PdfPTable foot = new PdfPTable(1);
        Chunk pageNumber = new Chunk(String.valueOf(document.getPageNumber()));
        pageNumber.setFont(footerFont);
        cell = new PdfPCell(new Paragraph(pageNumber));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setBorder(Rectangle.TOP);
        foot.addCell(cell);
        foot.setTotalWidth(page.width() - document.leftMargin() - document.rightMargin());
        foot.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(),
                writer.getDirectContent());
    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}

From source file:br.org.acessobrasil.silvinha.util.HeaderAndFooter.java

License:Open Source License

/**
 * @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document)
 *//*  w  w w  . j a  va  2 s .co m*/
public void onEndPage(PdfWriter writer, Document document) {

    try {
        Rectangle page = document.getPageSize();
        PdfPTable head = new PdfPTable(1);
        PdfPCell cell = new PdfPCell(new Paragraph(GERAL.RELATORIOS_ASES));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cell.setVerticalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setBorder(Rectangle.BOTTOM);
        head.addCell(cell);
        head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        head.writeSelectedRows(0, -1, document.leftMargin(),
                page.getHeight() - document.topMargin() + head.getTotalHeight(), writer.getDirectContent());
        PdfPTable foot = new PdfPTable(1);
        cell = new PdfPCell(new Paragraph(String.valueOf(document.getPageNumber())));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setVerticalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setBorder(Rectangle.TOP);
        foot.addCell(cell);
        foot.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
        foot.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(),
                writer.getDirectContent());
    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}

From source file:com.krawler.esp.servlets.ExportProjectReportServlet.java

License:Open Source License

public void getHeaderFooter(Document document) throws JSONException {
    java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16));
    fontSmallRegular.setColor(tColor);//from w  ww  .  j  a va2s  . c  om

    java.util.Date dt = new java.util.Date();
    String dformat = "yyyy-MM-d";
    java.text.SimpleDateFormat dtf = new java.text.SimpleDateFormat(dformat);
    String DateStr = dtf.format(dt);

    // -------- header ----------------
    header = new PdfPTable(3);
    String HeadDate = "";
    if (config.getBoolean("headDate"))
        HeadDate = DateStr;
    PdfPCell headerDateCell = new PdfPCell(new Phrase(HeadDate, fontSmallRegular));
    headerDateCell.setBorder(0);
    headerDateCell.setPaddingBottom(4);
    header.addCell(headerDateCell);

    PdfPCell headerNotecell = new PdfPCell(new Phrase(config.getString("headNote"), fontSmallRegular));
    headerNotecell.setBorder(0);
    headerNotecell.setPaddingBottom(4);
    headerNotecell.setHorizontalAlignment(PdfCell.ALIGN_CENTER);
    header.addCell(headerNotecell);

    String HeadPager = "";
    if (config.getBoolean("headPager"))
        HeadPager = String.valueOf(document.getPageNumber());//current page no
    PdfPCell headerPageNocell = new PdfPCell(new Phrase(HeadPager, fontSmallRegular));
    headerPageNocell.setBorder(0);
    headerPageNocell.setPaddingBottom(4);
    headerPageNocell.setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
    header.addCell(headerPageNocell);

    PdfPCell headerSeparator = new PdfPCell(new Phrase(""));
    headerSeparator.setBorder(PdfPCell.BOX);
    headerSeparator.setPadding(0);
    headerSeparator.setColspan(3);
    header.addCell(headerSeparator);
    // -------- header end ----------------

    // -------- footer  -------------------
    footer = new PdfPTable(3);
    PdfPCell footerSeparator = new PdfPCell(new Phrase(""));
    footerSeparator.setBorder(PdfPCell.BOX);
    footerSeparator.setPadding(0);
    footerSeparator.setColspan(3);
    footer.addCell(footerSeparator);

    String PageDate = "";
    if (config.getBoolean("footDate"))
        PageDate = DateStr;
    PdfPCell pagerDateCell = new PdfPCell(new Phrase(PageDate, fontSmallRegular));
    pagerDateCell.setBorder(0);
    footer.addCell(pagerDateCell);

    PdfPCell footerNotecell = new PdfPCell(new Phrase(config.getString("footNote"), fontSmallRegular));
    footerNotecell.setBorder(0);
    footerNotecell.setHorizontalAlignment(PdfCell.ALIGN_CENTER);
    footer.addCell(footerNotecell);

    String FootPager = "";
    if (config.getBoolean("footPager"))
        FootPager = String.valueOf(document.getPageNumber());//current page no
    PdfPCell footerPageNocell = new PdfPCell(new Phrase(FootPager, fontSmallRegular));
    footerPageNocell.setBorder(0);
    footerPageNocell.setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
    footer.addCell(footerPageNocell);
    // -------- footer end   -----------
}

From source file:com.krawler.esp.servlets.ExportServlet.java

License:Open Source License

public void getHeaderFooter(Document document) throws JSONException {
    java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16));
    fontSmallRegular.setColor(tColor);//w  ww . j  a  va2  s .  c o  m
    java.util.Date dt = new java.util.Date();
    String date = "yyyy-MM-dd";
    java.text.SimpleDateFormat dtf = new java.text.SimpleDateFormat(date);
    String DateStr = dtf.format(dt);

    // -------- header ----------------
    header = new PdfPTable(3);
    String HeadDate = "";
    if (config.getBoolean("headDate"))
        HeadDate = DateStr;
    PdfPCell headerDateCell = new PdfPCell(new Phrase(HeadDate, fontSmallRegular));
    headerDateCell.setBorder(0);
    headerDateCell.setPaddingBottom(4);
    header.addCell(headerDateCell);

    PdfPCell headerNotecell = new PdfPCell(new Phrase(config.getString("headNote"), fontSmallRegular));
    headerNotecell.setBorder(0);
    headerNotecell.setPaddingBottom(4);
    headerNotecell.setHorizontalAlignment(PdfCell.ALIGN_CENTER);
    header.addCell(headerNotecell);

    String HeadPager = "";
    if (config.getBoolean("headPager"))
        HeadPager = String.valueOf(document.getPageNumber());//current page no
    PdfPCell headerPageNocell = new PdfPCell(new Phrase(HeadPager, fontSmallRegular));
    headerPageNocell.setBorder(0);
    headerPageNocell.setPaddingBottom(4);
    headerPageNocell.setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
    header.addCell(headerPageNocell);

    PdfPCell headerSeparator = new PdfPCell(new Phrase(""));
    headerSeparator.setBorder(PdfPCell.BOX);
    headerSeparator.setPadding(0);
    headerSeparator.setColspan(3);
    header.addCell(headerSeparator);
    // -------- header end ----------------

    // -------- footer  -------------------
    footer = new PdfPTable(3);
    PdfPCell footerSeparator = new PdfPCell(new Phrase(""));
    footerSeparator.setBorder(PdfPCell.BOX);
    footerSeparator.setPadding(0);
    footerSeparator.setColspan(3);
    footer.addCell(footerSeparator);

    String PageDate = "";
    if (config.getBoolean("footDate"))
        PageDate = DateStr;
    PdfPCell pagerDateCell = new PdfPCell(new Phrase(PageDate, fontSmallRegular));
    pagerDateCell.setBorder(0);
    footer.addCell(pagerDateCell);

    PdfPCell footerNotecell = new PdfPCell(new Phrase(config.getString("footNote"), fontSmallRegular));
    footerNotecell.setBorder(0);
    footerNotecell.setHorizontalAlignment(PdfCell.ALIGN_CENTER);
    footer.addCell(footerNotecell);

    String FootPager = "";
    if (config.getBoolean("footPager"))
        FootPager = String.valueOf(document.getPageNumber());//current page no
    PdfPCell footerPageNocell = new PdfPCell(new Phrase(FootPager, fontSmallRegular));
    footerPageNocell.setBorder(0);
    footerPageNocell.setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
    footer.addCell(footerPageNocell);
    // -------- footer end   -----------
}

From source file:com.krawler.spring.exportFunctionality.exportDAOImpl.java

License:Open Source License

public void getHeaderFooter(Document document) throws ServiceException {
    try {//from ww  w.  j  av  a2 s  .c o m
        java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16));
        java.util.Date dt = new java.util.Date();
        String date = "yyyy-MM-dd";
        java.text.SimpleDateFormat dtf = new java.text.SimpleDateFormat(date);
        dtf.setTimeZone(TimeZone.getTimeZone("GMT" + this.tdiff));
        String DateStr = dtf.format(dt);

        // -------- header ----------------
        header = new PdfPTable(3);
        header.setWidthPercentage(100);
        header.setWidths(new float[] { 20, 60, 20 });
        String HeadDate = "";
        if (config.getBoolean("headDate")) {
            HeadDate = DateStr;
        }
        PdfPCell headerDateCell = new PdfPCell(
                fontFamilySelector.process(HeadDate, FontContext.SMALL_TEXT, tColor));//fontSmallRegular));
        headerDateCell.setBorder(0);
        headerDateCell.setPaddingBottom(4);
        headerDateCell.setHorizontalAlignment(PdfCell.ALIGN_LEFT);
        header.addCell(headerDateCell);

        PdfPCell headerNotecell = new PdfPCell(
                fontFamilySelector.process(config.getString("headNote"), FontContext.HEADER_NOTE, tColor));
        headerNotecell.setBorder(0);
        headerNotecell.setPaddingBottom(4);
        headerNotecell.setHorizontalAlignment(PdfCell.ALIGN_CENTER);
        header.addCell(headerNotecell);

        String HeadPager = "";
        if (config.getBoolean("headPager")) {
            HeadPager = String.valueOf(document.getPageNumber());//current page no
        }
        PdfPCell headerPageNocell = new PdfPCell(
                fontFamilySelector.process(HeadPager, FontContext.HEADER_NOTE, tColor));// fontSmallRegular));
        headerPageNocell.setBorder(0);
        headerPageNocell.setPaddingBottom(4);
        headerPageNocell.setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
        header.addCell(headerPageNocell);

        PdfPCell headerSeparator = new PdfPCell(new Phrase(""));
        headerSeparator.setBorder(PdfPCell.BOX);
        headerSeparator.setPadding(0);
        headerSeparator.setColspan(3);
        header.addCell(headerSeparator);
        // -------- header end ----------------

        // -------- footer  -------------------
        footer = new PdfPTable(3);
        PdfPCell footerSeparator = new PdfPCell(new Phrase(""));
        footerSeparator.setBorder(PdfPCell.BOX);
        footerSeparator.setPadding(0);
        footerSeparator.setColspan(3);
        footer.addCell(footerSeparator);
        footer.setWidthPercentage(100);
        footer.setWidths(new float[] { 20, 60, 20 });
        String PageDate = "";
        if (config.getBoolean("footDate")) {
            PageDate = DateStr;
        }
        PdfPCell pagerDateCell = new PdfPCell(
                fontFamilySelector.process(PageDate, FontContext.SMALL_TEXT, tColor));//fontSmallRegular));
        pagerDateCell.setBorder(0);
        pagerDateCell.setHorizontalAlignment(PdfCell.ALIGN_LEFT);
        footer.addCell(pagerDateCell);

        PdfPCell footerNotecell = new PdfPCell(
                fontFamilySelector.process(config.getString("footNote"), FontContext.FOOTER_NOTE, tColor));// fontSmallRegular));
        footerNotecell.setBorder(0);
        footerNotecell.setHorizontalAlignment(PdfCell.ALIGN_CENTER);
        footer.addCell(footerNotecell);

        String FootPager = "";
        if (config.getBoolean("footPager")) {
            FootPager = String.valueOf(document.getPageNumber());//current page no
        }
        PdfPCell footerPageNocell = new PdfPCell(
                fontFamilySelector.process(FootPager, FontContext.SMALL_TEXT, tColor));// fontSmallRegular));
        footerPageNocell.setBorder(0);
        footerPageNocell.setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
        footer.addCell(footerPageNocell);
        // -------- footer end   -----------
    } catch (Exception e) {
        throw ServiceException.FAILURE("exportDAOImpl.getHeaderFooter", e);
    }
}

From source file:com.krawler.spring.exportFunctionality.exportMPXDAOImpl.java

License:Open Source License

public void getHeaderFooter(Document document) throws ServiceException {
    try {//  w w w .  ja v a  2 s  .  c  om
        java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16));
        //            fontSmallRegular.setColor(tColor);
        java.util.Date dt = new java.util.Date();
        String date = "yyyy-MM-dd";
        java.text.SimpleDateFormat dtf = new java.text.SimpleDateFormat(date);
        String DateStr = dtf.format(dt);

        // -------- header ----------------
        header = new PdfPTable(3);
        String HeadDate = "";
        if (config.getBoolean("headDate")) {
            HeadDate = DateStr;
        }
        PdfPCell headerDateCell = new PdfPCell(
                new Phrase(fontFamilySelector.process(HeadDate, FontContext.FOOTER_NOTE, tColor)));
        headerDateCell.setBorder(0);
        headerDateCell.setPaddingBottom(4);
        header.addCell(headerDateCell);

        PdfPCell headerNotecell = new PdfPCell(new Phrase(
                fontFamilySelector.process(config.getString("headNote"), FontContext.FOOTER_NOTE, tColor)));
        headerNotecell.setBorder(0);
        headerNotecell.setPaddingBottom(4);
        headerNotecell.setHorizontalAlignment(PdfCell.ALIGN_CENTER);
        header.addCell(headerNotecell);

        String HeadPager = "";
        if (config.getBoolean("headPager")) {
            HeadPager = String.valueOf(document.getPageNumber());//current page no
        }
        PdfPCell headerPageNocell = new PdfPCell(
                new Phrase(fontFamilySelector.process(HeadPager, FontContext.FOOTER_NOTE, tColor)));
        headerPageNocell.setBorder(0);
        headerPageNocell.setPaddingBottom(4);
        headerPageNocell.setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
        header.addCell(headerPageNocell);

        PdfPCell headerSeparator = new PdfPCell(new Phrase(""));
        headerSeparator.setBorder(PdfPCell.BOX);
        headerSeparator.setPadding(0);
        headerSeparator.setColspan(3);
        header.addCell(headerSeparator);
        // -------- header end ----------------

        // -------- footer  -------------------
        footer = new PdfPTable(3);
        PdfPCell footerSeparator = new PdfPCell(new Phrase(""));
        footerSeparator.setBorder(PdfPCell.BOX);
        footerSeparator.setPadding(0);
        footerSeparator.setColspan(3);
        footer.addCell(footerSeparator);

        String PageDate = "";
        if (config.getBoolean("footDate")) {
            PageDate = DateStr;
        }
        PdfPCell pagerDateCell = new PdfPCell(
                new Phrase(fontFamilySelector.process(PageDate, FontContext.FOOTER_NOTE, tColor)));
        pagerDateCell.setBorder(0);
        footer.addCell(pagerDateCell);

        PdfPCell footerNotecell = new PdfPCell(new Phrase(
                fontFamilySelector.process(config.getString("footNote"), FontContext.FOOTER_NOTE, tColor)));
        footerNotecell.setBorder(0);
        footerNotecell.setHorizontalAlignment(PdfCell.ALIGN_CENTER);
        footer.addCell(footerNotecell);

        String FootPager = "";
        if (config.getBoolean("footPager")) {
            FootPager = String.valueOf(document.getPageNumber());//current page no
        }
        PdfPCell footerPageNocell = new PdfPCell(
                new Phrase(fontFamilySelector.process(FootPager, FontContext.FOOTER_NOTE, tColor)));
        footerPageNocell.setBorder(0);
        footerPageNocell.setHorizontalAlignment(PdfCell.ALIGN_RIGHT);
        footer.addCell(footerPageNocell);
        // -------- footer end   -----------
    } catch (Exception e) {
        throw ServiceException.FAILURE("exportDAOImpl.getHeaderFooter", e);
    }
}

From source file:CPS.Core.TODOLists.PDFExporter.java

License:Open Source License

private Document prepareDocument(String filename, final String title, final String author, final String creator,
        final Rectangle pageSize) {

    System.out.println("DEBUG(PDFExporter): Creating document: " + filename);

    Document d = new Document();

    d.setPageSize(pageSize);/*from   ww w  .  j a  v a  2s  .c o m*/
    // TODO alter page orientation?  maybe useful for seed order worksheet

    d.addTitle(title);
    d.addAuthor(author);
    //        d.addSubject( );
    //        d.addKeywords( );
    d.addCreator(creator);

    // left, right, top, bottom - scale in points (~72 points/inch)
    d.setMargins(35, 35, 35, 44);

    try {
        PdfWriter writer = PdfWriter.getInstance(d, new FileOutputStream(filename));
        // add header and footer
        writer.setPageEvent(new PdfPageEventHelper() {
            public void onEndPage(PdfWriter writer, Document document) {
                try {
                    Rectangle page = document.getPageSize();

                    PdfPTable head = new PdfPTable(3);
                    head.getDefaultCell().setBorderWidth(0);
                    head.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
                    head.addCell(new Phrase(author, fontHeadFootItal));

                    head.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                    head.addCell(new Phrase(title, fontHeadFootReg));

                    head.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                    head.addCell("");

                    head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
                    head.writeSelectedRows(0, -1, document.leftMargin(),
                            page.getHeight() - document.topMargin() + head.getTotalHeight(),
                            writer.getDirectContent());

                    PdfPTable foot = new PdfPTable(3);

                    foot.getDefaultCell().setBorderWidth(0);
                    foot.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
                    foot.addCell(new Phrase(creator, fontHeadFootItal));

                    foot.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                    foot.addCell("");

                    foot.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                    foot.addCell(new Phrase("Page " + document.getPageNumber(), fontHeadFootReg));

                    foot.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
                    foot.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(),
                            writer.getDirectContent());
                } catch (Exception e) {
                    throw new ExceptionConverter(e);
                }
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }

    return d;
}

From source file:nl.knaw.dans.common.lang.pdf.PdfPageLayouter.java

License:Apache License

public void onStartPage(final PdfWriter writer, final Document document) {
    if (headerImage == null)
        return;/*from  ww  w  .ja  va2  s  .c om*/

    final float top = document.top();
    final PdfContentByte canvas = writer.getDirectContent();
    float resizeFactor = // TODO make calculation logic clearer
            headerImage.getHeight() / (MARGIN_TOP - HEADER_PADDING);
    final float width = headerImage.getWidth() / resizeFactor;
    final float height = headerImage.getHeight() / resizeFactor;

    try {
        canvas.addImage(headerImage, width, 0, 0, height, MARGIN_LEFT, top - HEADER_POSITION);
    } catch (final Exception cause) {
        logger.error("can't add header image to PDF page " + document.getPageNumber(), cause);
    }

}

From source file:nl.knaw.dans.common.lang.pdf.PdfPageLayouter.java

License:Apache License

public void onEndPage(final PdfWriter writer, final Document document) {
    final float bottom = document.bottom();
    final float centerX = getCenterX(document);
    final PdfContentByte canvas = writer.getDirectContent();
    final int rotation = 0;

    final PdfPTable table = new PdfPTable(5);
    table.setTotalWidth(PAGE_NUMBER_TABLE_WIDTH);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setBorder(0);

    table.addCell(TO_FIRST);/*from   w w  w  . j  a va  2  s  .c o  m*/
    table.addCell(TO_PREV);
    table.addCell(new Phrase(new Chunk("" + document.getPageNumber(), FONT)));
    table.addCell(TO_NEXT);
    table.addCell(TO_LAST);

    table.writeSelectedRows(0, -1, centerX - (table.getTotalWidth() / 2), bottom - FOOTER_POSITION, canvas);
    if (footerPhrase == null)
        return;
    showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase(footerPhrase), centerX, bottom - FOOTER_POSITION,
            rotation);
}

From source file:org.areasy.common.doclet.document.DocumentEventHandler.java

License:Open Source License

/**
 * At the end of each page, index information is collected
 * and footer and headers are inserted.//from w ww.j  av  a 2s.  c om
 *
 * @param document The current PDF document.
 * @param writer   The writer used to create the document.
 */
public void onEndPage(PdfWriter writer, Document document) {
    currentPage = document.getPageNumber();
    State.setCurrentPage(currentPage);

    if (State.getCurrentHeaderType() != HEADER_DEFAULT) {
        float len;

        if (State.isContinued() && !State.isLastMethod()) {
            String cont = "(continued on next page)";
            len = bf.getWidthPoint(cont, 7);
            cb.beginText();
            cb.setFontAndSize(bf, 7);
            cb.setTextMatrix(300 - (len / 2), 56);
            cb.showText(cont);
            cb.endText();
        }

        if (State.getCurrentHeaderType() != HEADER_DETAILS) {
            // add lines
            cb.setLineWidth(1f);
            cb.moveTo(LEFT_MARGIN, 812);
            cb.lineTo(RIGHT_MARGIN, 812);
        }

        cb.moveTo(LEFT_MARGIN, 42);
        cb.lineTo(RIGHT_MARGIN, 42);
        cb.stroke();

        // page footer with number of pages
        float textX = (float) 0.0;
        float templateX = (float) 0.0;
        float textWidth = (float) 0.0;
        float numWidth = (float) 0.0;
        int currPageNumberAlign;

        if (pageNumberAlign == PAGE_NUMBER_ALIGN_SWITCH) {
            if ((currentPage % 2) == 0)
                currPageNumberAlign = PAGE_NUMBER_ALIGN_LEFT;
            else
                currPageNumberAlign = PAGE_NUMBER_ALIGN_RIGHT;
        } else
            currPageNumberAlign = pageNumberAlign;

        String text = DefaultConfiguration.getString(ARG_PGN_PREFIX, "Page ") + currentPage;
        if (pageNumberType == PAGE_NUMBER_FULL)
            text = text + " of ";

        textWidth = bf.getWidthPoint(text, 8);
        numWidth = bf.getWidthPoint("999", 8);

        if (currPageNumberAlign == PAGE_NUMBER_ALIGN_LEFT)
            textX = LEFT_MARGIN;

        if (currPageNumberAlign == PAGE_NUMBER_ALIGN_CENTER)
            textX = (float) (DOCUMENT_WIDTH / 2) - (textWidth / 2);

        if (currPageNumberAlign == PAGE_NUMBER_ALIGN_RIGHT)
            textX = RIGHT_MARGIN - textWidth - numWidth;

        templateX = textX + textWidth;

        cb.beginText();
        cb.setFontAndSize(bf, 8);

        if (currPageNumberAlign == PAGE_NUMBER_ALIGN_LEFT) {
            cb.showTextAligned(PdfContentByte.ALIGN_LEFT, text, textX, FOOTER_BASELINE, 0);
        }

        if (currPageNumberAlign == PAGE_NUMBER_ALIGN_CENTER) {
            cb.showTextAligned(PdfContentByte.ALIGN_LEFT, text, textX, FOOTER_BASELINE, 0);
        }

        if (currPageNumberAlign == PAGE_NUMBER_ALIGN_RIGHT) {
            cb.showTextAligned(PdfContentByte.ALIGN_LEFT, text, textX, FOOTER_BASELINE, 0);
        }

        cb.endText();

        if (pageNumberType == PAGE_NUMBER_FULL) {
            // add template for total page number
            cb.addTemplate(template, templateX, FOOTER_BASELINE);
        }

        // headers (left, right, center)
        // temporary solution: handling of first page of package
        // not correct yet, so use fix heading configuration now
        if (State.getCurrentHeaderType() == HEADER_API) {
            leftHeader = "";
            centerHeader = "$CLASS";
            rightHeader = "";
        }

        if (State.getCurrentHeaderType() == HEADER_INDEX) {
            leftHeader = "";
            centerHeader = "Index";
            rightHeader = "";
        }

        if (State.getCurrentHeaderType() == HEADER_DETAILS) {
            leftHeader = "";
            centerHeader = "";
            rightHeader = "";
        }

        cb.beginText();
        cb.setFontAndSize(bf, 8);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, parseHeader(centerHeader), DOCUMENT_WIDTH / 2,
                HEADER_BASELINE, 0);
        cb.endText();

        cb.beginText();
        cb.setFontAndSize(bf, 8);
        cb.showTextAligned(PdfContentByte.ALIGN_LEFT, parseHeader(leftHeader), LEFT_MARGIN, HEADER_BASELINE, 0);
        cb.endText();

        cb.beginText();
        cb.setFontAndSize(bf, 8);
        cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, parseHeader(rightHeader), RIGHT_MARGIN, HEADER_BASELINE,
                0);
        cb.endText();
    }
}