List of usage examples for com.itextpdf.text.pdf PdfContentByte setLineDash
public final void setLineDash(final double[] array, final double phase)
From source file:com.softwaremagico.tm.pdf.complete.elements.CellDottedBorderEvent.java
License:Open Source License
public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { PdfContentByte canvas = canvases[PdfPTable.LINECANVAS]; canvas.setLineDash(3f, 3f); canvas.moveTo(position.getLeft(), position.getTop()); canvas.lineTo(position.getRight(), position.getTop()); canvas.moveTo(position.getLeft(), position.getBottom()); canvas.lineTo(position.getRight(), position.getBottom()); canvas.stroke();/* w ww.ja v a2s .com*/ }
From source file:com.vectorprint.report.itext.debug.DebugHelper.java
License:Open Source License
public static void debugRect(PdfContentByte canvas, Rectangle rect, float[] dash, float borderWidth, EnhancedMap settings, LayerManager layerAware) { layerAware.startLayerInGroup(DEBUG, canvas); debugFont(canvas, settings);/*from w w w . j a va 2s. c om*/ canvas.setLineWidth(borderWidth); canvas.setLineDash(dash, 0); canvas.moveTo(rect.getLeft(), rect.getBottom()); canvas.lineTo(rect.getRight(), rect.getBottom()); canvas.lineTo(rect.getRight(), rect.getTop()); canvas.lineTo(rect.getLeft(), rect.getTop()); canvas.closePathStroke(); ItextHelper.resetLineDash(canvas); canvas.endLayer(); }
From source file:com.vectorprint.report.itext.debug.DebugHelper.java
License:Open Source License
/** * This method will append to the pdf a legend explaining the visual feedback in the pdf, an overview of the styles * used and an overview of the properties used. * * @throws DocumentException/*from www . j a v a 2 s.c o m*/ */ public static void appendDebugInfo(PdfWriter writer, Document document, EnhancedMap settings, StylerFactory stylerFactory) throws DocumentException, VectorPrintException { PdfContentByte canvas = writer.getDirectContent(); canvas.setFontAndSize(FontFactory.getFont(FontFactory.COURIER).getBaseFont(), 8); canvas.setColorFill( itextHelper.fromColor(settings.getColorProperty(Color.MAGENTA, ReportConstants.DEBUGCOLOR))); canvas.setColorStroke( itextHelper.fromColor(settings.getColorProperty(Color.MAGENTA, ReportConstants.DEBUGCOLOR))); Font f = FontFactory.getFont(FontFactory.COURIER, 8); f.setColor(itextHelper.fromColor(settings.getColorProperty(Color.MAGENTA, ReportConstants.DEBUGCOLOR))); float top = document.getPageSize().getTop(); document.add(new Phrase(new Chunk("table: ", f).setLocalDestination(DEBUGPAGE))); document.add(Chunk.NEWLINE); document.add(new Phrase("cell: ", f)); document.add(Chunk.NEWLINE); document.add(new Phrase("image: ", f)); document.add(Chunk.NEWLINE); document.add(new Phrase("text: ", f)); document.add(Chunk.NEWLINE); document.add(new Phrase("background color is shown in a small rectangle", f)); document.add(Chunk.NEWLINE); canvas.setLineWidth(2); canvas.setLineDash(new float[] { 0.3f, 5 }, 0); float left = document.leftMargin(); canvas.rectangle(left + 80, top - 25, left + 80, 8); canvas.closePathStroke(); canvas.setLineWidth(0.3f); canvas.setLineDash(new float[] { 2, 2 }, 0); canvas.rectangle(left + 80, top - 37, left + 80, 8); canvas.closePathStroke(); canvas.setLineDash(new float[] { 1, 0 }, 0); canvas.rectangle(left + 80, top - 50, left + 80, 8); canvas.closePathStroke(); canvas.setLineDash(new float[] { 0.3f, 5 }, 0); canvas.rectangle(left + 80, top - 63, left + 80, 8); canvas.closePathStroke(); document.add(Chunk.NEWLINE); document.add(new Phrase("fonts available: " + FontFactory.getRegisteredFonts(), f)); document.add(Chunk.NEWLINE); if (settings.getBooleanProperty(false, DEBUG)) { document.add(new Phrase("OVERVIEW OF STYLES FOR THIS REPORT", f)); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); } Font b = new Font(f); b.setStyle("bold"); Set<Map.Entry<String, String>> entrySet = stylerFactory.getStylerSetup().entrySet(); for (Map.Entry<String, String> styleInfo : entrySet) { String key = styleInfo.getKey(); document.add(new Chunk(key, b).setLocalDestination(key)); document.add(new Chunk(": " + styleInfo.getValue(), f)); document.add(Chunk.NEWLINE); document.add(new Phrase(" styling configured by " + key + ": ", f)); for (BaseStyler st : (Collection<BaseStyler>) stylerFactory.getBaseStylersFromCache((key))) { document.add(Chunk.NEWLINE); document.add(new Chunk(" ", f)); document.add(new Chunk(st.getClass().getSimpleName(), DebugHelper.debugFontLink(canvas, settings)) .setLocalGoto(st.getClass().getSimpleName())); document.add(new Chunk(":", f)); document.add(Chunk.NEWLINE); document.add(new Phrase(" non default parameters for " + st.getClass().getSimpleName() + ": " + getParamInfo(st), f)); document.add(Chunk.NEWLINE); if (!st.getConditions().isEmpty()) { document.add(new Phrase(" conditions for this styler: ", f)); } for (StylingCondition sc : (Collection<StylingCondition>) st.getConditions()) { document.add(Chunk.NEWLINE); document.add(new Chunk(" ", f)); document.add( new Chunk(sc.getClass().getSimpleName(), DebugHelper.debugFontLink(canvas, settings)) .setLocalGoto(sc.getClass().getSimpleName())); document.add(Chunk.NEWLINE); document.add(new Phrase(" non default parameters for " + sc.getClass().getSimpleName() + ": " + getParamInfo(sc), f)); } } document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); } document.newPage(); document.add(new Phrase("Properties used for the report", f)); document.add(Chunk.NEWLINE); ByteArrayOutputStream bo = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(bo); settings.listProperties(ps); ps.close(); document.add(new Paragraph(bo.toString(), f)); document.newPage(); try { bo = new ByteArrayOutputStream(); ps = new PrintStream(bo); Help.printHelpHeader(ps); ps.close(); document.add(new Paragraph(bo.toString(), f)); Help.printStylerHelp(document, f); Help.printConditionrHelp(document, f); } catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException ex) { log.log(Level.SEVERE, null, ex); } }
From source file:com.vectorprint.report.itext.ItextHelper.java
License:Open Source License
public static void resetLineDash(PdfContentByte canvas) { canvas.setLineDash(new float[] { 1, 0 }, 0); }
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);/*from w ww . j a va2 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:ihm.panneaux.GenererPdf.java
public void applyLineDash(PdfContentByte canvas) { canvas.setLineDash(3, 3); }