> Hi:
>
> I need to create a pdf file, with layout like [header | table of data
> (read from database) | footer]. The number of the rows of the table is
> not fixed, can across multiple pages.
> Ideally, like to import a template pdf file of layout [ header | xx |
> footer], then fill in/replace the 'xx' with actual data from database.
> Or, can I import header.pdf (into what object), add content to
> document, and then append footer.pdf?
> Is this achievable using iText? Form fill seems to require fixed
> number of rows.
> The following code doesn't seem to work either.
>
> -----------------------------------------
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(fileName));
PdfContentByte cb = writer.getDirectContent();

// import header
PdfReader reader = new PdfReader("Header.pdf");
PdfImportedPage page1 = writer.getImportedPage(reader, 1);
cb.addTemplate(page1, 1f, 0, 0, 1f, 0f, 0f);

// add table
document.add(new Paragraph("--- start of data table ---"));
PdfPTable table = new PdfPTable(3);
for() {
table.addCell();
}
document.add(table)
document.add(new Paragraph("--- end of data table ---"));

// import footer
PdfReader reader2 = new PdfReader("Footer.pdf");
PdfImportedPage page2 = writer.getImportedPage(reader2, 1);
cb.addTemplate(page2, 1f, 0, 0, 1f, 0, -320);

> ------------------------------------------
>
> Thanks for the help.
>
> David Ge
>
>




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to