PdfCopy does not allow changes. After creating you doc with PdfCopy read
it and use PdfStamper to do the changes.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of [EMAIL PROTECTED]
> Sent: Thursday, June 17, 2004 2:01 PM
> To: [EMAIL PROTECTED]
> Subject: [iText-questions] Adding Watermark with PdfCopy
> 
> Hi,
> 
> I'm trying to add a watermark (or just an image)  to a pdf 
> which is created using PdfCopy. I use the following code 
> (which is derived from the example code for the PdfCopy):
> 
> try {
>                 int f = 0;
>                 String outFile = args[args.length-1];
>                 Document document = null;
>                 PdfCopy  writer = null;
>                 while (f < args.length-1) {
>                     // we create a reader for a certain document
>                     PdfReader reader = new PdfReader(args[f]);
>                     // we retrieve the total number of pages
>                     int n = reader.getNumberOfPages();
>                     System.out.println("There are " + n + " 
> pages in " + args[f]);
>                    
>                     if (f == 0) {
>                         // step 1: creation of a document-object
>                         document = new 
> Document(reader.getPageSizeWithRotation(1));
>                         // step 2: we create a writer that 
> listens to the document
>                         writer = new PdfCopy(document, new 
> FileOutputStream(outFile));
>                         // step 3: we open the document
>                        
>                         Watermark watermark = new 
> Watermark(Image.getInstance("C:/temp/watermark.jpg"), 200, 320);
>                         document.add(watermark);
>                        
>                         document.open();
>                     }
>                     // step 4: we add content
>                     PdfImportedPage page;
>                     for (int i = 0; i < n; ) {
>                         ++i;
>                         page = writer.getImportedPage(reader, i);
>                         writer.addPage(page);
>                         System.out.println("Processed page " + i);
>                     }
>                     PRAcroForm form = reader.getAcroForm();
>                     if (form != null)
>                         writer.copyAcroForm(reader);
>                     f++;
>                 }
>                 // step 5: we close the document
>                 document.close()
> 
> It does not create any errors, but the resulting pdf does not 
> contain the watermark. What am I doing wrong?
> 
> thanks
> Marc
> 
> 
> 
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
> Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
> Conference, June 28 - July 1 at the Moscone Center in San 
> Francisco, CA
> REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority 
> Code NWMGYKND
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 


-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to