Thanks Mark still i have problem. Text shows only on first page. I need that
text on every page. Now my code looks like this and its still doesn't work:
public void wstawDanePdf(String existing_pdf) {
try {
PdfReader reader = new PdfReader(existing_pdf_file);
int nu_pages = reader.getNumberOfPages();
PdfStamper stamper = new PdfStamper(reader, new
FileOutputStream(new_pdf_file));
PdfContentByte over;
BaseFont helv = BaseFont.createFont(BaseFont.COURIER_BOLD,
BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
for(int curPage = 1; curPage < nu_pages; curPage++){
over = stamper.getOverContent(curPage);
over.beginText();
over.setFontAndSize(helv, 11);
over.setTextMatrix(57, 635);
over.showText("Text has to be added
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
over.endText();
}
stamper.close();
} catch (IOException ioe) {
ioe.printStackTrace();
System.out.println(ioe.getMessage());
} catch (DocumentException de) {
de.printStackTrace();
System.out.println(de.getMessage());
}
}
Pozdrawiam,
Paweł Gawędzki
________________________________
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mark Storer
Sent: Thursday, April 03, 2008 6:21 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] pdf Image to real Image?
Your while loop (as written in the email here) is an infinite loop. You need
to increment 'i'.
And I suggest you use a 'for' loop when you know ahead of time how many passes
you're going to make... it reduces the chance of you making this kind of error.
You might end up with something like:
for (int curPage = 1; curPage < nu_pages; ++curPage) {
putData( stamper.getOverContent( curPage ), helv );
}
--Mark Storer
PDF Guy
On Thu, Apr 3, 2008 at 7:43 AM, Gawędzki, Paweł <[EMAIL PROTECTED]> wrote:
I can't add data to existing pdf. It's adding data only to first page.
Nothing hepends on others. This is my code:
try {
PdfReader reader = new PdfReader(pdf_path1);
int nu_pages = reader.getNumberOfPages();
PdfStamper stamper = new PdfStamper(reader, new
FileOutputStream(pdf_path2));
PdfContentByte over;
BaseFont helv = BaseFont.createFont(BaseFont.COURIER_BOLD,
BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
int i=1;
while(i < nu_pages) {
over = stamper.getOverContent(i);
putData(over, helv);
}
stamper.close();
} catch (IOException ioe) {
ioe.printStackTrace();
System.out.println(ioe.getMessage());
} catch (DocumentException de) {
de.printStackTrace();
System.out.println(de.getMessage());
}
private void putData(PdfContentByte over, BaseFont helv) throws
DocumentException, IOException {
over.beginText();
over.setFontAndSize(helv, 11);
over.setTextMatrix(, oy);
over.showText("Text to add");
over.endText();
}
I do not know why it works only for first page.
------------------------------------------------------------------------------
Skandia Życie Towarzystwo Ubezpieczeń S.A.
ul. Cybernetyki 7, 02-677 Warszawa
Sąd Rejonowy dla m.st. Warszawy, XIII Wydział Gospodarczy
Krajowego Rejestru Sądowego Nr KRS 0000056463,
Regon: 016003836, NIP: 951-19-33-418
wysokość kapitału zakładowego: 46.000.000,00 PLN
wysokość kapitału wpłaconego: 46.000.000,00 PLN
------------------------------------------------------------------------------
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar
------------------------------------------------------------------------------
Skandia Życie Towarzystwo Ubezpieczeń S.A.
ul. Cybernetyki 7, 02-677 Warszawa
Sąd Rejonowy dla m.st. Warszawy, XIII Wydział Gospodarczy
Krajowego Rejestru Sądowego Nr KRS 0000056463,
Regon: 016003836, NIP: 951-19-33-418
wysokość kapitału zakładowego: 46.000.000,00 PLN
wysokość kapitału wpłaconego: 46.000.000,00 PLN
------------------------------------------------------------------------------
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar