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:\\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: Stuart Jansen <[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] Centering PdfTemplate on new page...
>Date: Fri, 09 Mar 2007 12:35:20 -0700
>
>On Fri, 2007-03-09 at 14:04 -0500, Rick DeFazio wrote:
> > Stuart thanks for your reply... I need to make myself more clear.
> >
> > I have a document that is full of text and headings and whatever else. I
> > copy it into a pdfTemplate so that I can add a logo to it. I then write 
>this
> > template out to a new document. Problem is when doing that the content 
>is
> > not centered.
>
>Okay, what's wrong with using the same concept I illustrated but instead
>of my example:
>
>png.setAbsolutePosition(pageWidth/2 - imageWidth/2,   pageHeight/2 -
>imageHeight/2);
>
>the equivalent in your code would be:
>
>cb.addTemplate(page, documentWidth/2 - page.getWidth() / 2,
>documentHeight/2 - page.getHeight/2);
>
>--
>Stuart Jansen <[EMAIL PROTECTED]>
>Guru Labs, L.C.


><< signature.asc >>




>-------------------------------------------------------------------------
>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/

_________________________________________________________________
RealLiveMoms: Share your experience with Real Live Moms just like you 
http://www.reallivemoms.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/

Reply via email to