If no exception is thrown my guess is that your PDF has a crop box and you are
writing the footer outside the visible area.
Paulo
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Peter Delahunty
> Sent: Wednesday, August 20, 2008 3:32 PM
> To: [email protected]
> Subject: [iText-questions] PdfStamper not working on some PDF's
>
>
> Hi All
>
> Have written some code using itext framework to write a
> footer to each page
> in a PDF.
>
> String origninalPdf = "test.pdf";
> String outputPdf = "test-stamped.pdf";
> String text "hello from me";
>
> PdfReader reader = new PdfReader(originalPdf);
>
> PdfStamper stamper = new PdfStamper(reader, new
> FileOutputStream(outputPdf));
> BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,
> BaseFont.WINANSI,
> BaseFont.EMBEDDED);
> int total = reader.getNumberOfPages();
>
> for (int i = 1; i <= total; i++) {
> Rectangle rectangle = reader.getPageSize(i);
> float pageHeight = rectangle.getHeight();
> float pageWidth = rectangle.getWidth();
> PdfContentByte over = stamper.getOverContent(i);
> over.beginText();
> float fontSize = getFontSize();
> over.setFontAndSize(bf, fontSize);
>
> float stringWidth = over.getEffectiveStringWidth(text, false);
> float x = getXPostition(pageWidth, stringWidth);
> float y = getYPostition(pageHeight);
>
> over.setTextMatrix(x, y);
> over.showText(text);
> over.endText();
> }
>
> stamper.close();
> reader.close();
>
> The problem i am having is. The code works fine on the PDF's
> i create using
> Open Office and some other ones i have eg (the itext in
> action book) . I run
> my code and open the file in a reader and can see my footer.
>
> However it does NOT work for other PDF's.
>
> Can anyone tell me why PdfStamper would not work under some
> circumstances eg
> (security issues, permissions, pdf versions etc)
>
> Can i get it throw an error if it failed to work.
>
> many regards in advance Pete
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php