Hi,

 

I am creating multiple PDF files within a loop each PDF file needs to have page x of y, as well as, a header on each page.

 

I have looked over the examples for creating a page event, however, none of them show passing parameters in the function call writer.setPageEvent(new SummaryEndPageEvent()); Is it possible to pass parameters within this call?  For example:  writer.setPageEvent(new SummaryEndPageEvent(String myReportTitle, String myAcct, String acctNum, String fromDate, String toDate));

 

SummaryEndPageEvent(String myReportTitle, String myAcct, String acctNum, String fromDate, String toDate)

{

            this.myReportTitle = myReportTitle;

            this.myAcct = myAcct;

            this.acctNum = acctNum;

            this.fromDate = fromDate;

            this.toDate = toDate;

 }

 

If not, is there another way to display the same info on all report pages?

 

Also, can I create more than one table within the header portion of a page event and do I have to use a table to format my header? The format of my report is:

 

                                                                                                           Title (centered)(passed in param)

            Image(left center of header)                              AccountName  (passed in param)         AccountNumber(passed in param)

                                                                                    From:   (passed in param)                     To: (passed in param)

 

I originally had some really ugly code for setting the text to the correct position(but it worked):

If possible I would rather use this code in my pageEvent rather than try to manipulate tables to format my header.

 

Image png = Image.getInstance("../webapps/slb/images/logo.png");

                            png.scalePercent(80);

                            Chunk ck = new Chunk(png, 0, -40);                          

                            document.add(ck);   

 

                            document.add(new Phrase(("\t\t\t\t\t\t\t\t\t\t\t\t" + myReportTitle + "\n"),new Font(Font.COURIER, 16, Font.BOLD)));

                            document.add(new Phrase(("                           Billed To: " + delmAcctString + "\t\t\t\t\t\t\t\t\t\tAcct #: " + acctNum + "\n" +

                                                                       "                           For the Period: " + fromDate                    + " \t\t\t\t\tTo: " + toDate ),new Font(Font.COURIER, 12, Font.BOLD)));

                           

                            //Create the line for under the header

                            PdfContentByte textBody = writer.getDirectContent();

                            textBody.setLineWidth(1);

                            //underline after for/to

                            textBody.moveTo(8,505);

                            textBody.lineTo(825,505);

                         

                            textBody.stroke();

 

Thank you in advance for any advice you may have!

 

Tanya

 

Reply via email to