-----Ursprüngliche Nachricht-----
Von: "Bruno Lowagie" <[email protected]>
Gesendet: 13.07.09 16:47:01
An: Post all your questions about iText here 
<[email protected]>
Betreff: Re: [iText-questions] add PdfPTable into Columntext into an existing 
PDF File

Stephan Trautmann wrote:
> 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. 

You can't add content using PdfCopy, but you already have an instance of 
PdfStamper, why don't you add the PdfPTable using stamper.getContentOver()?

br,
Bruno

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



Hello,

thank you very much for your tip. It works now =) with just a little change in 
the code.

By the way another question. Just in case I am adding a very large table with 
the spamper, only the first party of the table will be displayed, because the 
stamper only works on one page at a time... is there a possibility to add the 
rest of my content on a new inserted page using the current stamper object... 
my code currently looks like:

cb = stamper.getOverContent(1);
                        
                        ct = new ColumnText(cb);
                        ct.setAlignment(Element.ALIGN_CENTER);
                        ct.setSimpleColumn(36, 36, PageSize.A4.width()-36, 
PageSize.A4.height()-300);

                        //Tabellenkörper erzeugen

                        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 < beteiligungEigenschaften.length; 
m++)
                        {
                                
                                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)
                                {
                                        break;
                                }
                                ++currentColumn;
                                if(currentColumn>=1){
                                        break;
                                }
                                                                
                        }
                        stamper.setFormFlattening(true);
                        stamper.close();


Only the first ca 20 rows of ca 660 are displayed... I tried to use the 
go(true) simulation to find out whether a new page has to be started but i 
didn't get it to work :(

in hope there is a solution

regard

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/

Reply via email to