My task at the moment is to write a class that can do the following things:
1. Add to an already existing pdf Fail watermark "outdated"
2. Check, whether the document already has this sign
3. Remove the sign

The first two points have been resolved through iText Stamper and layers.
Saly i can't  find an example of how to remove the specific layer. Please
Help, who can.
Layer added like this:

private void markAndMovePdfDocument(File pdfFile, String newPath)
                        throws Exception {
                PdfReader reader = new PdfReader(pdfFile.getPath());
                PdfStamper stamper = new PdfStamper(reader, new 
FileOutputStream(
                                newPath));
                Image watermarkImage = Image.getInstance("d:/watermark.jpg");
                PdfLayer wmLayer = new PdfLayer("watermark", 
stamper.getWriter());

                wmLayer.setOnPanel(true);
                // set layer parameters
                wmLayer.setPrint("print", true);
                wmLayer.setOn(true);
                wmLayer.setView(true);
                // Prepare transperancy
                PdfGState transparent = new PdfGState();
                transparent.setStrokeOpacity(0.4f);
                transparent.setFillOpacity(0.4f);
                PdfContentByte cb;
                int toPage = stamper.getReader().getNumberOfPages();
                for (int i = 1; i <= toPage; i++) {

                        cb = stamper.getUnderContent(i);

                        Rectangle rectangle = stamper.getReader()
                                        .getPageSizeWithRotation(i);

                        cb.beginLayer(wmLayer);
                        cb.setGState(transparent); // set block trasparency 
properties

                        // position relative to top
                        
watermarkImage.scaleAbsoluteHeight(rectangle.getHeight() - 20);
                        watermarkImage.scaleAbsoluteWidth(rectangle.getWidth() 
- 20);
                        float absoluteY = rectangle.getBottom()
                                        + (rectangle.getHeight() - 
watermarkImage.getPlainHeight() - 10);
                        watermarkImage.setAbsolutePosition(10, 10);
                        cb.addImage(watermarkImage);
                        cb.endLayer();

                }

                stamper.close();
        }

any tips on optimizing my code also warmly welcomed.
Thanks in advance


--
View this message in context: 
http://itext-general.2136553.n4.nabble.com/iText-how-to-remove-the-layer-watermark-tp3576811p3576811.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Discover what all the cheering's about.
Get your free trial download today. 
http://p.sf.net/sfu/quest-dev2dev2 
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to