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 ; }
get a canvas for drawing prepared according to settings