Finally I got some success... here is what I did. Found it in an example. It
creates an exact copy of the PDF with a new logo in it. Just what I needed.
The only odd thing is I have to divide the image size by 2 to get it to a
reasonable size though. If I don't the image looks huge? ie.
img.scaleToFit(img.width() / 2, img.height() / 2);
Thanks for everyone's time!
PdfReader reader = new PdfReader("C:\\original.pdf");
PdfStamper stamper = new PdfStamper(reader, new
FileOutputStream("C:\\newPDF.pdf"));
Image img = Image.getInstance("C:\\_projects\\GPO\\logo.jpg");
img.scaleToFit(img.width() / 2, img.height() / 2);
img.setAbsolutePosition(470, 780);
int pageNumber = 1;
PdfContentByte cb = stamper.getOverContent(pageNumber);
cb.addImage(img);
stamper.close();
reader.close();
From: "Paulo Soares" <[EMAIL PROTECTED]>
Reply-To: Post all your questions about iText here
<itext-questions@lists.sourceforge.net>
To: "Post all your questions about iText here"
<itext-questions@lists.sourceforge.net>
Subject: Re: [iText-questions] Signature fields lost when
usingPdfContentByte
Date: Fri, 9 Mar 2007 20:16:25 -0000
If you first flatten Final_PKI_logo.jpg it may work.
Paulo
----- Original Message -----
From: "Rick DeFazio" <[EMAIL PROTECTED]>
To: <itext-questions@lists.sourceforge.net>
Sent: Friday, March 09, 2007 8:06 PM
Subject: Re: [iText-questions] Signature fields lost when
usingPdfContentByte
> Thanks Bruno, what I am simply trying to do is add a logo to the
existing
> document. The code i am using below does not seem to work though...
>
> PdfReader reader = new PdfReader("C:\\originalPDF.pdf");
> PdfStamper stamper = new PdfStamper(reader, new
> FileOutputStream("C:\\newPDF.pdf"));
>
> PdfImportedPage page = stamper.getImportedPage(reader, 1);
>
> Image img = Image.getInstance("C:\\_projects\\GPO\\Final_PKI_logo.jpg");
> img.scaleToFit(img.width() / 2, img.height() / 2);
> img.setAbsolutePosition(470, 780);
>
> page.addImage(img);
>
> stamper.close();
> reader.close();
>
>
>>From: Bruno Lowagie <[EMAIL PROTECTED]>
>>Reply-To: Post all your questions about iText here
>><itext-questions@lists.sourceforge.net>
>>To: Post all your questions about iText here
>><itext-questions@lists.sourceforge.net>
>>Subject: Re: [iText-questions] Signature fields lost when
>>usingPdfContentByte
>>Date: Fri, 09 Mar 2007 18:26:00 +0100
>>
>>Rick DeFazio wrote:
>> > I copy a document that has 2 signature fields on it using
>>PdfContentByte.
>>
>>Saying you copy a document 'using PdfContentByte' is ambiguous.
>>Define 'I copy'; choose one of the following answers:
>>- with PdfWriter
>>- with PdfCopy
>>- with PdfStamper - NOTE THAT THIS IS THE ONLY GOOD ANSWER! -
>>
>> > The newly created document ends up losing these 2 signature fields?
>>
>>Of course the signature fields are lost.
>>What did you expect? That anybody could just go on
>>and forge signed documents?
>>
>> > Does anyone know of some example code to get around this?
>> > I have searched but found none...
>>
>>Maybe you should read the book (more specifically chapter 16).
>>br,
>>Bruno
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
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/
_________________________________________________________________
Dont waste time standing in linetry shopping online. Visit Sympatico / MSN
Shopping today! http://shopping.sympatico.msn.ca
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
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/