List of usage examples for com.itextpdf.text.pdf PdfContentByte restoreState
public void 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();/*from w w w. ja v a 2s .co m*/ addOverlay.setColorFill(CMYKColor.WHITE); addOverlay.setColorStroke(CMYKColor.WHITE); addOverlay.rectangle(MASK_START_X, MASK_START_Y, MASK_WIDTH, MASK_HEIGTH); addOverlay.fillStroke(); 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();// w ww . j a v a 2s.co m addOverlay.setColorFill(CMYKColor.WHITE); addOverlay.setColorStroke(CMYKColor.RED); addOverlay.rectangle(startX, startY, width, height); addOverlay.stroke(); 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/* w w w .j a va 2s .c o 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 w w w .ja v a 2 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(); } }