List of usage examples for com.itextpdf.text.pdf PdfContentByte fillStroke
public void fillStroke()
From source file:PrefichaPDF.java
public static void drawRectangle(PdfContentByte content, float x, float y, float width, float height) { content.saveState();// w w w . j av a 2 s . c o m PdfGState state = new PdfGState(); content.setGState(state); content.setRGBColorFill(232, 232, 232); content.setColorStroke(BaseColor.LIGHT_GRAY); // content.setr content.setLineWidth((float) .5); content.rectangle(x, y, width, height); content.fillStroke(); content.restoreState(); }
From source file:PrefichaPDF.java
public static void drawRectangleSC(PdfContentByte content, float x, float y, float width, float height) { content.saveState();//from www. ja va 2 s. c o m PdfGState state = new PdfGState(); // state.setFillOpacity(0.6f); content.setGState(state); content.setRGBColorFill(0xFF, 0xFF, 0xFA); content.setColorStroke(BaseColor.LIGHT_GRAY); content.setLineWidth((float) .5); content.rectangle(x, y, width, height); content.fillStroke(); content.restoreState(); }
From source file:PrefichaPDF.java
public static void drawRectangleText(PdfContentByte content, float x, float y, float width, float height) { content.saveState();/*from www. j a v a 2s . c o m*/ PdfGState state = new PdfGState(); content.setGState(state); content.setRGBColorFill(0, 230, 255); content.setColorStroke(BaseColor.LIGHT_GRAY); content.setLineWidth((float) .5); content.rectangle(x, y, width, height); content.fillStroke(); content.restoreState(); }
From source file:adams.flow.transformer.pdfproclet.Circle.java
License:Open Source License
/** * The actual processing of the document. * * @param generator the context/*from w w w. jav a 2 s . co m*/ * @param file the file to add * @return true if successfully added * @throws Exception if something goes wrong */ protected boolean doProcess(PDFGenerator generator, File file) throws Exception { PdfContentByte cb; cb = generator.getWriter().getDirectContent(); cb.saveState(); cb.setColorStroke(new BaseColor(m_Color.getRGB())); cb.setColorFill(new BaseColor(m_Color.getRGB())); cb.setLineWidth(m_LineWidth); cb.circle(m_X, m_Y, m_Radius); if (m_Fill) cb.fillStroke(); else cb.stroke(); cb.restoreState(); return true; }
From source file:adams.flow.transformer.pdfproclet.Rectangle.java
License:Open Source License
/** * The actual processing of the document. * * @param generator the context/* w w w . j av a 2 s .c om*/ * @param file the file to add * @return true if successfully added * @throws Exception if something goes wrong */ protected boolean doProcess(PDFGenerator generator, File file) throws Exception { PdfContentByte cb; cb = generator.getWriter().getDirectContent(); cb.saveState(); cb.setColorStroke(new BaseColor(m_Color.getRGB())); cb.setColorFill(new BaseColor(m_Color.getRGB())); cb.setLineWidth(m_LineWidth); cb.rectangle(m_X, m_Y, m_X + m_Width, m_Y + m_Height); if (m_Fill) cb.fillStroke(); else cb.stroke(); cb.restoreState(); return true; }
From source file:ConexionBD.CreaPrefichaPDF.java
public static void drawRectangle(PdfContentByte content, float x, float y, float width, float height) { content.saveState();//ww w. j av a 2 s .c o m PdfGState state = new PdfGState(); content.setGState(state); content.setRGBColorFill(232, 232, 232); content.setColorStroke(BaseColor.BLUE); content.setLineWidth((float) .5); content.rectangle(x, y, width, height); content.fillStroke(); content.restoreState(); }
From source file:ConexionBD.CreaPrefichaPDF.java
public static void drawRectangleSC(PdfContentByte content, float x, float y, float width, float height) { content.saveState();/*from w w w .ja v a2 s . co m*/ PdfGState state = new PdfGState(); content.setGState(state); content.setRGBColorFill(0xFF, 0xFF, 0xFA); content.setColorStroke(BaseColor.BLUE); content.setLineWidth((float) .5); content.rectangle(x, y, width, height); content.fillStroke(); content.restoreState(); }
From source file:ConexionBD.CreaPrefichaPDF.java
public static void drawRectangleText(PdfContentByte content, float x, float y, float width, float height) { content.saveState();//w w w . j a va 2s . c om PdfGState state = new PdfGState(); content.setGState(state); content.setRGBColorFill(0, 230, 255); content.setColorStroke(BaseColor.BLUE); content.setLineWidth((float) .5); content.rectangle(x, y, width, height); content.fillStroke(); content.restoreState(); }
From source file:EplanPrinter.PDFPrint.java
License:Open Source License
public String insertSketch(String points, String color, String opac, int pageNum, int masterHeight, int masterWidth, int lineWeight, String lineStyle) throws DocumentException, IOException { float f = Float.valueOf(opac); PdfGState gs1 = new PdfGState(); int t = points.indexOf("POLYGON"); gs1.setFillOpacity(f);/* w w w .j av a2 s . c o m*/ PdfContentByte fg = pds.getOverContent(pageNum); fg.setGState(gs1); float[] pointsSt = shatterSketches(points); color = "0x" + color.substring(1); Color c = Color.decode(color); fg.setLineWidth(lineWeight * getRatio(masterHeight, masterWidth, pageNum)); if (lineStyle.equals("dash")) { fg.setLineDash(lineWeight * 4f, lineWeight); } else { fg.setLineDash(0); } //fg.setLineWidth(5); fg.setColorStroke(new BaseColor(c.getRGB())); fg.setColorFill(new BaseColor(c.getRGB())); float[] prefl = scaleShape(pointsSt, masterHeight, masterWidth, pageNum); float[] fl = sketchTrans(prefl, pageNum); /* Addition. ftorres - 7/22/2015 - Added to account for rotated pages * with the origin (0,0) not set to the bottom-left of the page. [1400] */ float flTrans[] = translateRotation(fl[0], fl[1], pageNum); if (points.indexOf("LINEPOINT") != -1) { fg.circle(flTrans[0], flTrans[1], 5); fg.fillStroke(); if (t == -1) { gs1.setFillOpacity(0f); } else { gs1.setFillOpacity(f); } fg.setGState(gs1); } fg.moveTo(flTrans[0], flTrans[1]); for (int i = 2; i < pointsSt.length; i = i + 2) { flTrans = translateRotation(fl[i], fl[i + 1], pageNum); fg.lineTo(flTrans[0], flTrans[1]); } if (t != -1) { fg.closePathFillStroke(); fg.fill(); } else { fg.stroke(); } return ""; }
From source file:EplanPrinter.PDFPrint.java
License:Open Source License
private void insertPinnedComment(float xCoord, float yCoord, String id, String comment, int pageNum, int masterHeight, int masterWidth) throws DocumentException, IOException { int standardHeight = 38; int standardWidth = 130; int lineHeight = 7; if (fontSize == 8) { standardHeight = 48;//from w w w.j av a 2 s.c o m standardWidth = 180; lineHeight = 10; } else if (fontSize == 10) { standardHeight = 70; standardWidth = 210; lineHeight = 12; } // comment box position defines lower-left corner xCoord += 41; // x-coordinate of comment text box yCoord -= 7; // lower offset moves box up float f = (float) 0.4; PdfGState gs1 = new PdfGState(); gs1.setFillOpacity(f); PdfContentByte fg = pds.getOverContent(pageNum); fg.setGState(gs1); fg.setLineWidth(.5f * getRatio(masterHeight, masterWidth, pageNum)); // Calculate additional needed height for the comment, based on length of comment. List<String> lines = createComment(cleanupComment(comment)); int numLines = lines.size(); int commentHeight = (numLines - 1) * lineHeight; // Draw the comment box String color = "0xF2F3E4"; Color c = Color.decode(color); color = "0xFAFAF4"; Color c2 = Color.decode(color); fg.setLineWidth(1f); fg.setColorStroke(new BaseColor(c.getRGB())); fg.setColorFill(new BaseColor(c2.getRGB())); float newCoords[] = pinnedCoords(xCoord, yCoord, standardWidth, standardHeight + commentHeight); fg.roundRectangle(xCoord, newCoords[1], standardWidth, standardHeight + commentHeight, 2f); fg.fillStroke(); //BaseFont bf = BaseFont.createFont(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, true); BaseFont bfb = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, true); fg.setColorFill(BaseColor.RED); gs1.setFillOpacity(0.8f); fg.setGState(gs1); // Adding comment title text Phrase phrase = new Phrase("Comment", new Font(bfb, fontSize)); ColumnText.showTextAligned(fg, Element.ALIGN_LEFT, phrase, xCoord + 3, yCoord - 7, 0); // Adding comment number phrase = new Phrase(id, new Font(bf, fontSize)); float offset = xCoord + 35; if (fontSize == 8) offset = xCoord + 45; else if (fontSize == 10) offset = xCoord + 55; ColumnText.showTextAligned(fg, Element.ALIGN_LEFT, phrase, offset, yCoord - 7, 0); /* Remove 10/27/2015 Jon Changkachith // Adding 'comment' label text phrase = new Phrase("Comment", new Font(bfb, fontSize)); ColumnText.showTextAligned(fg, Element.ALIGN_LEFT, phrase, xCoord + 3, yCoord - 20f, 0); */ // Adding comment text int commentYOffset = 32; for (int i = 0; i < lines.size(); i++) { //phrase = new Phrase(lines.get(i), new Font(bf, fontSize)); phrase = composePhrase(lines.get(i), bf, bfb); ColumnText.showTextAligned(fg, Element.ALIGN_LEFT, phrase, xCoord + 3, yCoord - commentYOffset, 0); commentYOffset += lineHeight; } }