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

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

Introduction

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

Prototype

public void saveState() 

Source Link

Document

Saves the graphic state.

Usage

From source file:se.inera.intyg.intygstyper.fk7263.pdf.PdfAbstractGenerator.java

License:Open Source License

protected void createSignatureNotRequiredField(PdfStamper pdfStamper, int lastPage)
        throws DocumentException, IOException {
    PdfContentByte addOverlay;
    addOverlay = pdfStamper.getOverContent(lastPage);
    addOverlay.saveState();
    addOverlay.setColorFill(SIGNATURE_NOT_REQUIRED_COLOR);
    addOverlay.setColorStroke(CMYKColor.BLACK);
    addOverlay.rectangle(SIGNATURE_NOT_REQUIRED_START_X, SIGNATURE_NOT_REQUIRED_START_Y,
            SIGNATURE_NOT_REQUIRED_WIDTH, SIGNATURE_NOT_REQUIRED_HEIGHT);
    addOverlay.setLineWidth(LINE_WIDTH);
    addOverlay.fillStroke();//from  w w  w .j  a v  a2s .c  o m
    addOverlay.restoreState();
    // Do text
    addOverlay = pdfStamper.getOverContent(lastPage);
    addOverlay.saveState();
    BaseFont bf = BaseFont.createFont();
    addOverlay.beginText();
    addOverlay.setFontAndSize(bf, SIGNATURE_NOT_REQUIRED_FONT_SIZE);
    addOverlay.setTextMatrix(SIGNATURE_NOT_REQUIRED_START_X + SIGNATURE_NOT_REQUIRED_PADDING_LEFT,
            SIGNATURE_NOT_REQUIRED_START_Y + SIGNATURE_NOT_REQUIRED_PADDING_BOTTOM);
    addOverlay.showText(SIGNATURE_NOT_REQUIRED_TEXT);
    addOverlay.endText();
    addOverlay.restoreState();
}

From source file:se.inera.intyg.intygstyper.fk7263.pdf.PdfAbstractGenerator.java

License:Open Source License

protected void maskSendToFkInformation(PdfStamper pdfStamper) {
    PdfContentByte addOverlay;
    addOverlay = pdfStamper.getOverContent(1);
    addOverlay.saveState();
    addOverlay.setColorFill(CMYKColor.WHITE);
    addOverlay.setColorStroke(CMYKColor.WHITE);
    addOverlay.rectangle(MASK_START_X, MASK_START_Y, MASK_WIDTH, MASK_HEIGTH);
    addOverlay.fillStroke();/*w  w  w  .  ja v  a  2s.  co m*/
    addOverlay.restoreState();
}

From source file:se.inera.intyg.intygstyper.fk7263.pdf.PdfAbstractGenerator.java

License:Open Source License

protected void mark(PdfStamper pdfStamper, String watermarkText, int startX, int startY, int height, int width)
        throws DocumentException, IOException {
    PdfContentByte addOverlay;
    addOverlay = pdfStamper.getOverContent(1);
    addOverlay.saveState();
    addOverlay.setColorFill(CMYKColor.WHITE);
    addOverlay.setColorStroke(CMYKColor.RED);
    addOverlay.rectangle(startX, startY, width, height);
    addOverlay.stroke();//w w  w.  j a v  a 2 s  .c  o m
    addOverlay.restoreState();

    // Do text
    addOverlay = pdfStamper.getOverContent(1);
    ColumnText ct = new ColumnText(addOverlay);
    BaseFont bf = BaseFont.createFont();
    Font font = new Font(bf, WATERMARK_FONTSIZE);
    int llx = startX + WATERMARK_TEXT_PADDING;
    int lly = startY + WATERMARK_TEXT_PADDING;
    int urx = llx + width - 2 * WATERMARK_TEXT_PADDING;
    int ury = lly + height - 2 * WATERMARK_TEXT_PADDING;
    Phrase phrase = new Phrase(watermarkText, font);
    ct.setSimpleColumn(phrase, llx, lly, urx, ury, WATERMARK_FONTSIZE, Element.ALIGN_LEFT | Element.ALIGN_TOP);
    ct.go();
}

From source file:se.inera.intyg.intygstyper.fk7263.pdf.PdfAbstractGenerator.java

License:Open Source License

protected void createRightMarginText(PdfStamper pdfStamper, int numberOfPages, String id, String text)
        throws DocumentException, IOException {
    PdfContentByte addOverlay;
    BaseFont bf = BaseFont.createFont();
    // Do text//from www .  j av a 2 s.  co m
    for (int i = 1; i <= numberOfPages; i++) {
        addOverlay = pdfStamper.getOverContent(i);
        addOverlay.saveState();
        addOverlay.beginText();
        addOverlay.setFontAndSize(bf, MARGIN_TEXT_FONTSIZE);
        addOverlay.setTextMatrix(0, 1, -1, 0, MARGIN_TEXT_START_X, MARGIN_TEXT_START_Y);
        addOverlay.showText(String.format("Intygs-ID: %s. %s", id, text));
        addOverlay.endText();
        addOverlay.restoreState();
    }
}

From source file:se.inera.intyg.intygstyper.ts_bas.pdf.PdfGeneratorImpl.java

License:Open Source License

private void createLeftMarginText(PdfStamper pdfStamper, int numberOfPages, String id, String text)
        throws DocumentException, IOException {
    PdfContentByte addOverlay;
    BaseFont bf = BaseFont.createFont();
    // Do text//from ww w  .  j a va2  s.c om
    for (int i = 1; i <= numberOfPages; i++) {
        addOverlay = pdfStamper.getOverContent(i);
        addOverlay.saveState();
        addOverlay.beginText();
        addOverlay.setFontAndSize(bf, MARGIN_TEXT_FONTSIZE);
        addOverlay.setTextMatrix(0, 1, -1, 0, MARGIN_TEXT_START_X, MARGIN_TEXT_START_Y);
        addOverlay.showText(String.format("Intygs-ID: %s. %s", id, text));
        addOverlay.endText();
        addOverlay.restoreState();
    }
}