Hello,

I am not sure about what is your problem, but take a look at this web.
Maybe it helps you.

http://www.nabble.com/populate-the-List%3CString%3E-in-acro-forms-using-iText-on-multiline.-td16969216.html#a16969216

--------------------------------------------------
From: "Stephan Trautmann" <[email protected]>
Sent: Monday, July 13, 2009 4:32 PM
To: <[email protected]>
Subject: [iText-questions] add PdfPTable into Columntext into an existingPDF 
File

> Hello,
>
> I have been working with IText for 2 weeks now and already read through 3 
> quaters of the book which I have bought last week. Its really interesting 
> how many different options I got in manipulating pdf and generate new 
> ones.
>
> But as usuall there are questions coming up which are not quite easily to 
> be answered by the given examples or tutorials, of which I have read 
> almost all =)
>
> Problem:
>
> I have a "Pdf Template" called ExportTemplate.pdf, having 3 PdfFormFields 
> to be filled in, which works perfectly using the pdf stamper.
> But now i want to add a PdfPTable using Columntext to illustrated a large 
> Table that should start directly beyond these 3 form fields.
>
> my steps:
> 1. read the template (template = new 
> RandomAccessFileOrArray("ExportTemplate.pdf") to memory
> 2. fill fields with stamper
> 3. read stamped pdf from memory ==> reader = new 
> PdfReader(baos.toByteArray())
> 4. creating a copy of the memory page + importing the first page which i 
> have already filled in
> 5.ADD TABLE WITH DYNAMIC CONTENT:
>
> The result i get is that i get only the copy of my first page but no table 
> is added.
> I expected the table to be added in the middle of the page. The 
> y-coordinates for the simpleColumn have just been set to the middle to see 
> whether something has been added at least.
>
> I am going to give you the code below to illustrate what i have already 
> done.
>
>         PdfReader reader;
> ByteArrayOutputStream baos;
> PdfStamper stamper;
> AcroFields field;
> PdfContentByte cb;
> ColumnText ct;
> Color textColor = Color.lightGray;
> RandomAccessFileOrArray template;
> Document document = new Document();
> try
> {
> template = new RandomAccessFileOrArray("ExportTemplate.pdf");
> reader = new PdfReader(template, null);
> baos = new ByteArrayOutputStream();
> stamper = new PdfStamper(reader, baos);
>
> //fill fields
> field = stamper.getAcroFields();
>
> field.setFieldProperty(identitaet, "textsize", 10f, null);
> field.setField(identitaet, idBeteiligungshalter);
>
> field.setFieldProperty(name, "textsize", 10f, null);
> field.setField(name, nameBeteiligungshalter);
> field.setFieldProperty(date, "textsize", 10f, null);
> field.setField(date, stichtag);
>
> stamper.setFormFlattening(true);
> stamper.close();
>
> reader = new PdfReader(baos.toByteArray());
> document = new Document(reader.getPageSizeWithRotation(1));
>
> PdfCopy copy = new PdfCopy(document, new 
> FileOutputStream("FilledExportTemplate.pdf"));
>
> document.open();
>
> copy.addPage(copy.getImportedPage(reader, 1));
>
> cb = copy.getDirectContent();
>
> ct = new ColumnText(cb);
> ct.setAlignment(Element.ALIGN_CENTER);
> ct.setSimpleColumn(36, 36, document.right() - 36, document.top() - 36);
>
> //generate table body
>
> PdfPTable tableMainHeader = new PdfPTable(7);
> tableMainHeader.setWidthPercentage(100f);
> tableMainHeader.setWidths(new int[] { 15, 35, 10, 10, 10, 10, 10 });
> PdfPCell cell = new PdfPCell();
>
> for (int m = 0; m < beteiligungen.size(); m++) //beteiligungen size =660 
> table rows each having 7 columns
> {
>
> for (int l = 0; l < 7; l++)
> {
> cell = new PdfPCell();
> cell.setBackgroundColor(textColor);
> cell.setMinimumHeight(30f);
> cell.addElement(new Chunk(beteiligungEigenschaften[m][l].toString()));
> tableMainHeader.addCell(cell);
>
> }
> }
>
> ct.addElement(tableMainHeader);
>
> //render
> int currentColumn =0;
> while (true)
> {
> int status = ct.go();
> if ((status & ColumnText.NO_MORE_TEXT) != 0)
> {
> System.out.println(status);
> System.out.println(ColumnText.NO_MORE_COLUMN);
> System.out.println(ColumnText.NO_MORE_TEXT);
> break;
> }
> ++currentColumn;
> if(currentColumn>=1){
> break;
> }
>
> }
>
>
>
> }
> catch (DocumentException de)
> {
> System.err.println(de.getMessage());
> }
> catch (IOException ioe)
> {
> System.err.println(ioe.getMessage());
> }
> document.close();
>
>
> I hope there is an obvious fault in my code that might be found easily.
> Looking forward to your reply
>
> regards
>
> Stephan
>
>
> ______________________________________________________
> GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://movieflat.web.de
>
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full 
> prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> 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
> Check the site with examples before you ask questions: 
> http://www.1t3xt.info/examples/
> You can also search the keywords list: 
> http://1t3xt.info/tutorials/keywords/
> 

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
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
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to