Abhishek Srivastava wrote:

> My user will be give me a PDF Document which will be an Acroform.  It 
> contains one page with a background image and a few text fields in it.
>
>  
>
> At runtime, I want to generate a document with many pages. Each page 
> will have the same Acroform but the fields will be filled with 
> different values.
>
>  
>
> Just to give an example.
>
> Suppose the Acroform designer creates a 1 page form for the marks 
> which a student has obtained in a test. So the acroform has 
> placeholders for name of the student, and marks in various subjects.
>
>  
>
> Using this acroform, I have to create a PDF document which contains 
> the report card of the entire class. Each page will have report card 
> of individual student.
>
>  
>
I work for Ghent University and that's one of the things we do with iText.
There are different ways to achieve this.

In one project we create a PDF using the traditional 5 steps:
1. create document
2. create writer + add page event class
3. open document
for (every student) {
    4. add data + new page
}
5. close data

in the onOpenDocument method of the page event class,
we read the original PDF for two reasons:
PE1) to retrieve the background as a PdfImportedPage
PE2) to retrieve the coordinates of the placeholders

in the onEndPage method of the page event class,
we add the background we retrieved earlier (PE1).

Step 4 uses ColumnText.showTextAligned to add the data
from the database at the positions we retrieved earlier (PE2).

There are other ways to do this.
You could create each individual file in memory using
PdfStamper, setting and flattening the fields. Then add
each file from memory into one PDF using PdfCopy; but if
you have a large volume of pages (in our case about 27,000),
this solution will be less performing and result in larger file sizes.
br,
Bruno


_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to