Create each page with PdfStamper to a ByteArrayOutputStream and concatenate it with PdfCopy as you generate the pages.
Best Regards, Paulo Soares > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Simon Ward > Sent: Thursday, July 01, 2004 4:43 PM > To: [EMAIL PROTECTED] > Subject: [iText-questions] Trying to combine several PDFs > into one doco > > Hi, I am developing a Reporting system for a highschool. I > have mad several templates for the various pdf files > (coverPage, reportPages). I can stamp the coverPage and > write the new PDF file, but how do I alter my code to write the > several pages of the report body and append them to the > coverPage? Keeping in mind that I am not writing new > documents and the number of pages I add are variable. The > following code > explains further (the various > values are retrieved from a database using other code): > > PdfReader reader = new PdfReader(templatePath > + "SCTemplate.pdf"); > > try > {PdfStamper stamp = new PdfStamper(reader, > new FileOutputStream(reportPath + someFile.pdf")); > AcroFields form = stamp.getAcroFields(); > > form.setField("reportTitle",reportTitle); > form.setField("studentName",studentName); > form.setField("date",reportDate); > form.setField("reportCount",reportCount); > form.setField("absences",daysAbsent); > form.setField("yaComment",yaComment); > form.setField("pComment",pComment); > form.setField("yaName",yaName); > form.setField("pName",pName); > form.setField("yrLevel",shortYearLevel); > form.setField("achievements",achievements); > > stamp.setFormFlattening(true); > stamp.close();} > > catch(Exception e) > {System.out.println("Error: " + e);} > > //This concludes the Cover Page > > I now need to loop through each subject the student is taking > and create a new report and append it to the coverPage: > > //AccessDatabase here > > while(database.next()) > {get report values and do something to write the pdf > write the new report using the smae method as the cover page. > > //Need to collate all pages here} > > And this is where I am having trouble. I have looked at the > tutorials and searched for examples high and low, but they all > deal with writing the Document object and not the PdfStamper > object. The templates need to be in PDF form so the > administrators can manage the report layout after > development, otherwise I would simply use the Document > object and write the pdf from scratch. > > Thanks in advance, > Simon > > > > > > ------------------------------------------------------- > This SF.Net email sponsored by Black Hat Briefings & Training. > Attend Black Hat Briefings & Training, Las Vegas July 24-29 - > digital self defense, top technical experts, no vendor pitches, > unmatched networking opportunities. Visit www.blackhat.com > _______________________________________________ > iText-questions mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/itext-questions > ------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions
