Hello,

I need to add a watermark to a PDF that already has a background color. The
PDF document was created first, then a background color may be added, and a
watermark to be added after that. 

I used the following code to add the background color:
                        PdfReader reader = new PdfReader(pdf);
                        int pages = reader.getNumberOfPages();
                        Rectangle pageSetup = reader.getPageSize(1);
                        pageSetup.setBackgroundColor(color);

                        document = new Document(pageSetup, 0, 0, 0, 0);
                        PdfWriter writer = PdfWriter.getInstance(document, 
output);
                        document.open();

                        PdfImportedPage page;

                        for (int i = 1; i <= pages; i++) {
                                page = writer.getImportedPage(reader, i);
                                document.add(Image.getInstance(page));
                        }
Then in a later step, if a watermark is needed, we used the PdfStamper to
stamp in the UnderContent:
                        PdfStamper theStamper = new PdfStamper(thePdfReader, 
theDocumentContent);
                        int iNumberPages = thePdfReader.getNumberOfPages();
                        int iPage = 0;
                        PdfContentByte thePdfContentByte;
                        while (iPage < iNumberPages) {
                                iPage++;
                                thePdfContentByte = 
theStamper.getUnderContent(iPage);
                                thePdfContentByte.addImage(anImage);
                        }

The problem is that the watermark image is hidden behind the background
color (say Yellow).

Is it possible to find the "topmost" UnderContent, so that the watermark can
be added there in front of the background color? 

Thank you for your help in advance.


--
View this message in context: 
http://itext-general.2136553.n4.nabble.com/Adding-watermark-in-front-of-the-page-background-color-tp4178886p4178886.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
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