First, I'd like to say well done on producing "iText". Your project is very welcome.
I'm struggling with how to create a very simple PDF that has 2 layers with the top layer having a simple transparent 'cut-out' area. I've got a small code snippet based on one of your examples. (code included at end of this email) In summary what I am trying to do is paint a transparent area on the top layer - to create a cut-out - so that what is painted on the lower layer is revealed and shows through this area. What I find is that any stroke or fill that I do with a supposedly transparent color (i.e. an instance of java.awt.Color with an alpha channel mask of 0x00) does not create a cut-out area on the top layer. The code in my example paints: - a large blue square on the bottom layer, - a slightly smaller yellow square in the same position on the top layer, - and then paints a diagonal cross (X) from corner to corner in the transparent colour. The PDF that my example code generates should ideally show a blue border around a yellow square with a blue diagonal cross (X) from corner to corner of the yellow square. Instead it shows a blue border with a yellow square, with a white diagnoal cross. The transparent colour being "java.awt.Color(0xff, 0xff, 0xff, 0);" I've got a copy of your "iText" book so if you were to point me to a page that might help, that would be great. Any tips that you have would be much appreciated. Kind Regards, Steven Bishop software configuration is: iText.jar : tested with versions 2.0.4 and 2.0.8 JVM : Sun jdk1.6.0_01 --- Begin Included File --- public class CutOut { public static void main(String[] args) { System.out.println("CutOut"); com.lowagie.text.Document theDocument = new com.lowagie.text.Document(com.lowagie.text.PageSize.A4, 50, 50, 50, 50); try { com.lowagie.text.pdf.PdfWriter theWriter = com.lowagie.text.pdf.PdfWriter.getInstance(theDocument, new java.io.FileOutputStream("cutout.pdf")); theWriter.setPdfVersion(com.lowagie.text.pdf.PdfWriter.VERSION_1_5); theDocument.open(); com.lowagie.text.pdf.PdfLayer layer1 = new com.lowagie.text.pdf.PdfLayer("Layer 1", theWriter); com.lowagie.text.pdf.PdfLayer layer2 = new com.lowagie.text.pdf.PdfLayer("Layer 2", theWriter); com.lowagie.text.pdf.PdfContentByte cb = theWriter.getDirectContent(); // Layer1... // cb.beginLayer(layer1); cb.setColorFill(java.awt.Color.blue); cb.rectangle(130, 130, 220, 220); cb.fill(); cb.endLayer(); // Layer2... // cb.beginLayer(layer2); cb.setColorStroke(java.awt.Color.yellow); cb.setColorFill(java.awt.Color.yellow); cb.rectangle(140, 140, 200, 200); cb.fill(); java.awt.Color theTransparentColour = new java.awt.Color(0xff, 0xff, 0xff, 0x00); System.err.println("TransparentColour : Alpha = "+theTransparentColour.getAlpha()); cb.setLineWidth(16); cb.setColorStroke(theTransparentColour); cb.setColorFill(theTransparentColour); cb.moveTo(140, 140); cb.lineTo(340, 340); cb.stroke(); cb.moveTo(140, 340); cb.lineTo(340, 140); cb.stroke(); cb.endLayer(); } catch (Exception dex) { dex.printStackTrace(); } theDocument.close(); } } --- End Included File --- ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/