Example usage for com.itextpdf.text.pdf PdfWriter getVerticalPosition

List of usage examples for com.itextpdf.text.pdf PdfWriter getVerticalPosition

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfWriter getVerticalPosition.

Prototype

public float getVerticalPosition(final boolean ensureNewLine) 

Source Link

Document

Use this method to get the current vertical page position.

Usage

From source file:com.kohmiho.mpsr.export.PDFGenerator.java

private PdfOutline addOutline(PdfOutline parent, PdfWriter writer, String title) {

    return new PdfOutline(parent,
            new PdfDestination(PdfDestination.XYZ, 0, writer.getVerticalPosition(true), 0), title, true);
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void addFooter(LebData lebData, PdfWriter writer) throws DocumentException, PdfFormatierungsException {
    int footerMargin = 0;
    if (lebData.getSchulhalbjahr().isErstesHalbjahr()) {
        footerMargin = bottomMargin + 85;
    } else {/*from  ww w. j  a  v a  2  s .c  om*/
        footerMargin = bottomMargin + 170;
    }
    alertLonelyFooter(writer, footerMargin);
    while (writer.getVerticalPosition(false) > (footerMargin + 20)) {
        document.add(Chunk.NEWLINE);
    }
    float footerBegin = writer.getVerticalPosition(false);
    Paragraph footerTopParagraph = new Paragraph();
    footerTopParagraph.setLeading(1, 0.4f);
    footerTopParagraph.add(Chunk.NEWLINE);
    footerTopParagraph.add(Chunk.NEWLINE);

    Paragraph footerBottompParagraph = new Paragraph();
    footerBottompParagraph.setLeading(1, 0.4f);

    if (lebData.getSchulhalbjahr().isErstesHalbjahr()) {
        footerTopParagraph
                .add(PdfFormatHelper.buildFooterHalbjahrDatumLine(lebData.getDatumString(), footerFont));
        footerTopParagraph.add(PdfFormatHelper.buildFooterHalbjahrDatumKlassenleiterLine(footerFont));
    } else {
        footerTopParagraph.add(
                PdfFormatHelper.buildFooterVersetzungsvermerkLine(lebData.getVersetzungsvermerk(), footerFont));
        footerTopParagraph.add(Chunk.NEWLINE);
        footerTopParagraph.add(PdfFormatHelper.buildFooterDatumLine(lebData.getDatumString(), footerFont));
        document.add(footerTopParagraph);
        while (writer.getVerticalPosition(false) > (footerBegin - 82)) {
            document.add(Chunk.NEWLINE);
        }
        footerBottompParagraph.add(PdfFormatHelper.buildFooterDienstsiegelLine(footerFont));
        footerBottompParagraph.add(Chunk.NEWLINE);
        footerBottompParagraph.add(PdfFormatHelper.buildFooterUnterschriftenLine(footerFont));
    }
    footerBottompParagraph.add(Chunk.NEWLINE);
    footerBottompParagraph.add(Chunk.NEWLINE);
    footerBottompParagraph.add(Chunk.NEWLINE);
    footerBottompParagraph.add(PdfFormatHelper.buildFooterKenntnisLine(footerFont));
    document.add(footerBottompParagraph);
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void breakSchusterjunge(PdfWriter writer) {
    if (writer.getVerticalPosition(false) < getSchusterjungenCriticalDistance()) {
        document.newPage();//w ww  .  j a  v  a  2s  .  com
    }
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void alertHurenkind(PdfWriter writer) throws PdfFormatierungsException {
    if (writer.getVerticalPosition(false) > getHurenkindCriticalDistance()
            && lebCreator.getHurenkindCount() < HURENKIND_MAX) {
        lebCreator.getHurenkinderMarker().put(sectionCount, true);
        throw new PdfFormatierungsException(PdfFormatierungsException.TYPE_HURENKIND);
    }// w  w w. j a  v a  2s.  c o  m
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void alertLonelyHeader(PdfWriter writer) throws PdfFormatierungsException {
    if (writer.getVerticalPosition(false) > getHurenkindCriticalDistance()
            && lebCreator.getHurenkindCount() < HURENKIND_MAX) {
        throw new PdfFormatierungsException(PdfFormatierungsException.TYPE_LONELY_HEADER_OR_FOOTER);
    }//from ww  w.j a  va  2 s  .  c o  m
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void alertLonelyFooter(PdfWriter writer, float footerMargin) throws PdfFormatierungsException {
    if ((writer.getVerticalPosition(false) < footerMargin
            || writer.getVerticalPosition(false) > getHurenkindCriticalDistance())
            && lebCreator.getDummyLineCount() < DUMMY_LINE_MAX) {
        throw new PdfFormatierungsException(PdfFormatierungsException.TYPE_LONELY_HEADER_OR_FOOTER);
    }//from   w w w . j  a  va 2 s .c  om
}

From source file:org.fossa.rolp.util.PdfStreamSource.java

License:Open Source License

private void insertDummyLineIfNecessary(PdfWriter writer) throws DocumentException {
    int countNewLines = 0;
    while (countNewLines < lebCreator.getDummyLineCount()) {
        countNewLines += 1;//from  w  w w .  j  av a 2 s  . c om
        if (writer.getVerticalPosition(false) < getSchusterjungenCriticalDistance()) {
            break;
        }
        document.add(Chunk.NEWLINE);
    }
}