List of usage examples for com.itextpdf.text.pdf PdfContentByte setLineWidth
public void setLineWidth(final double w)
From source file:se.billes.pdf.renderer.model.Line.java
License:Open Source License
@Override public void onRender(PdfContentByte cb) throws PdfRenderException { Integer[] pageSizes = getPage().getPdfDocument().getSize(); float[] pos = getPosition(); float[] moveTo = getMoveTo(); cb.setLineWidth(getThickness()); cb.setColorStroke(getBaseColor());/*from w w w. ja v a2 s .c om*/ float y1 = pageSizes[1] + SizeFactory.CUT_MARK - pos[1]; // seams strange but pdf starts bottom and up. float y2 = pageSizes[1] + SizeFactory.CUT_MARK - moveTo[1]; // x , y. y is backward in pdf so start pos is the entire page height cb.moveTo(SizeFactory.millimetersToPostscriptPoints(pos[0] + SizeFactory.CUT_MARK), SizeFactory.millimetersToPostscriptPoints(y1)); cb.lineTo(SizeFactory.millimetersToPostscriptPoints(moveTo[0] + SizeFactory.CUT_MARK), SizeFactory.millimetersToPostscriptPoints(y2)); cb.stroke(); }
From source file:se.billes.pdf.renderer.process.CutmarksRenderer.java
License:Open Source License
public void render(PdfWriter writer, Document document) { Cutmarks cutmarks = request.getCutmarks(); if (cutmarks != null && !cutmarks.isIgnoreCutStroke()) { float width = SizeFactory.CUT_MARK; float height = SizeFactory.CUT_MARK; float lineWidth = SizeFactory.CUT_MARK_LINE; float lineHeight = SizeFactory.CUT_MARK_LINE; Rectangle rect = document.getPageSize(); PdfContentByte cb = writer.getDirectContent(); cb.setLineWidth(0.1f); cb.moveTo(SizeFactory.millimetersToPostscriptPoints(width), 0); cb.lineTo(SizeFactory.millimetersToPostscriptPoints(width), SizeFactory.millimetersToPostscriptPoints(lineHeight)); cb.stroke();/*from ww w . j a va2s.c om*/ cb.moveTo(0, SizeFactory.millimetersToPostscriptPoints(height)); cb.lineTo(SizeFactory.millimetersToPostscriptPoints(lineWidth), SizeFactory.millimetersToPostscriptPoints(height)); cb.stroke(); // Upper left cut mark cb.moveTo(SizeFactory.millimetersToPostscriptPoints(width), rect.getHeight()); cb.lineTo(SizeFactory.millimetersToPostscriptPoints(width), rect.getHeight() - SizeFactory.millimetersToPostscriptPoints(lineHeight)); cb.stroke(); cb.moveTo(0, rect.getHeight() - SizeFactory.millimetersToPostscriptPoints(height)); cb.lineTo(SizeFactory.millimetersToPostscriptPoints(lineWidth), rect.getHeight() - SizeFactory.millimetersToPostscriptPoints(height)); cb.stroke(); /** * Upper right cut mark */ cb.moveTo(rect.getWidth(), rect.getHeight() - SizeFactory.millimetersToPostscriptPoints(height)); cb.lineTo(rect.getWidth() - SizeFactory.millimetersToPostscriptPoints(lineWidth), rect.getHeight() - SizeFactory.millimetersToPostscriptPoints(height)); cb.stroke(); cb.moveTo(rect.getWidth() - SizeFactory.millimetersToPostscriptPoints(width), rect.getHeight()); cb.lineTo(rect.getWidth() - SizeFactory.millimetersToPostscriptPoints(width), rect.getHeight() - SizeFactory.millimetersToPostscriptPoints(lineHeight)); cb.stroke(); /** * Lower right cut mark */ cb.moveTo(rect.getWidth() - SizeFactory.millimetersToPostscriptPoints(width), 0); cb.lineTo(rect.getWidth() - SizeFactory.millimetersToPostscriptPoints(width), SizeFactory.millimetersToPostscriptPoints(lineHeight)); cb.stroke(); cb.moveTo(rect.getWidth(), SizeFactory.millimetersToPostscriptPoints(height)); cb.lineTo(rect.getWidth() - SizeFactory.millimetersToPostscriptPoints(lineWidth), SizeFactory.millimetersToPostscriptPoints(height)); cb.stroke(); } }
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();/*from ww w.j a v a 2s . com*/ 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(); 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(); }