List of usage examples for com.itextpdf.text.pdf PdfGState PdfGState
PdfGState
From source file:PrefichaPDF.java
public static void drawRectangle(PdfContentByte content, float x, float y, float width, float height) { content.saveState();//from w w w . jav a 2 s . c om 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();/* www.ja v a 2 s . com*/ 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 w w w .ja v a 2 s . 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:com.qmetric.document.watermark.strategy.MessageWatermarkStrategy.java
License:Open Source License
private void applyTextTransparency(final PdfContentByte overContent) { // Make transparent - see http://itext-general.2136553.n4.nabble.com/Insert-transparent-Text-td2158904.html final PdfGState gstate = new PdfGState(); gstate.setFillOpacity(OPACITY);/*from w w w . j a v a 2 s. co m*/ gstate.setStrokeOpacity(OPACITY); overContent.saveState(); overContent.setGState(gstate); }
From source file:com.vectorprint.report.itext.style.stylers.AdvancedImpl.java
License:Open Source License
/** * get a canvas for drawing, prepared according to settings * * @see #draw(com.itextpdf.text.Rectangle, java.lang.String) * @return// w w w . ja v a2 s . c om */ protected final PdfContentByte getPreparedCanvas(float opacity) { needRestore = false; PdfContentByte canvas = (tableForeground != null) ? tableForeground : (isBg()) ? getWriter().getDirectContentUnder() : getWriter().getDirectContent(); String layerName = getLayerName(); BLENDMODE blend = getBlend(); if (getWriter().getPDFXConformance() == PdfWriter.PDFX1A2001) { // check blend, opacity, layers if (!PdfGState.BM_NORMAL.equals(blend.getBlend()) && !PdfGState.BM_COMPATIBLE.equals(blend.getBlend())) { throw new VectorPrintRuntimeException("blend not supported in PDF/X-1a: " + blend); } if (layerName != null) { throw new VectorPrintRuntimeException("layers not supported in PDF/X-1a: " + layerName); } if (opacity < 1) { throw new VectorPrintRuntimeException("opacity not supported in PDF/X-1a: " + opacity); } } if (layerName != null) { layerManager.startLayerInGroup(layerName, canvas); } // pgs.setAlphaIsShape(true); if (opacity <= 1) { // PdfShading shading = PdfShading.simpleAxial(getWriter(), 0, 0, getDocument().right() - getDocument().getPageSize().getWidth() * 0.6f, getDocument().top() - getDocument().getPageSize().getHeight() * 0.6f, Color.green, Color.orange,true,true); // canvas.paintShading(shading); canvas.saveState(); needRestore = true; PdfGState pgs = new PdfGState(); pgs.setFillOpacity(opacity); pgs.setStrokeOpacity(opacity); canvas.setGState(pgs); } if (!BLENDMODE.NORMAL.equals(blend)) { if (!needRestore) { canvas.saveState(); needRestore = true; } PdfGState pgs = new PdfGState(); pgs.setBlendMode(blend.getBlend()); canvas.setGState(pgs); } if (getTransform() != null && !(this instanceof Image)) { canvas.transform(new AffineTransform(getTransform())); } return canvas; }
From source file:com.vectorprint.report.jfree.ItextChartHelper.java
License:Open Source License
/** * * @param chart the chart tp plot/*from w w w . j a v a 2 s . c o m*/ * @param contentByte the canvas to plot to * @param width the width of the chart will be fit to * @param height the height of the chart will be fit to * @return * @throws BadElementException */ public static Image getChartImage(JFreeChart chart, PdfContentByte contentByte, float width, float height, float opacity) throws BadElementException { // create PdfTemplate from PdfContentByte PdfTemplate template = contentByte.createTemplate(width, height); template.saveState(); PdfGState pgs = new PdfGState(); pgs.setFillOpacity(opacity); pgs.setStrokeOpacity(opacity); template.setGState(pgs); // create Graphics2D from PdfTemplate Graphics2D g2 = new PdfGraphics2D(template, width, height); // setup the drawing area Rectangle2D r2D = new Rectangle2D.Double(0, 0, width, height); // pass the Graphics2D and drawing area to JFreeChart chart.draw(g2, r2D); g2.dispose(); // always dispose this template.restoreState(); // create Image from PdfTemplate return Image.getInstance(template); }
From source file:ConexionBD.CreaPrefichaPDF.java
public static void drawRectangle(PdfContentByte content, float x, float y, float width, float height) { content.saveState();/*from ww w .j ava 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 www . j av a 2 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();/*from w w w . j av a2s .c o m*/ 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:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java
License:Open Source License
private void createTransparencyShapes(Document document, PdfWriter writer) throws Exception { PdfContentByte cb = writer.getDirectContent(); pictureBackdrop(document.leftMargin(), 350, cb); cb.saveState();//from w w w .jav a2s.co m PdfGState gs1 = new PdfGState(); gs1.setFillOpacity(0.5f); cb.setGState(gs1); pictureCircles(document.leftMargin(), 350, cb); cb.restoreState(); cb.resetRGBColorFill(); }