Quantcast

itext

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

itext

vicky rodriguez

Hi,
Hope someone can help me out with this.
I have a table in itext that some times is 200 pages long and some times half a page (depending on the user data)
The problem that I am having is that the footer is not being displayed in all the pages. Some times the last page doesn' t have a footer and some time 4 or 5 pages in the middle of the report. It doesn't make any sense since the table is the same for two pages and the footer and the margin two.

I am using onEndPage and set the pageEvent before opening the document
I have a bottom margin in the document of 40 and set the footer at 20
The table doesn't have any specific size it has this default settings:

 public void setDefaultTableSettings(Table table) {
        table.setWidth(TABLE_WIDTH);
        table.setBorderWidth(TABLE_BORDER_WIDTH);
        table.setBorderColor(TABLE_BORDER_COLOR);
        table.setDefaultCellBorderColor(CELL_BORDER_COLOR);
        table.setDefaultCellBorderWidth(CELL_BORDER_WIDTH);
        table.setAutoFillEmptyCells(true);
        table.setAlignment(Element.ALIGN_LEFT);
        table.setPadding(TABLE_PADDING);
        table.setDefaultVerticalAlignment(Element.ALIGN_MIDDLE);
    }
Here is the code:
-----------------------------------------------------------------------------------------------------------------------
  /**
   * OnEndPageEvent Inner class that sets the footer in the .pdf documents
   */
   class OnEndPageEvent extends PdfPageEventHelper{
         MessageResources messageResources;

         OnEndPageEvent(MessageResources resources){
              this.messageResources = resources;
          }
         public void onEndPage(PdfWriter writer, Document document){
            try {
                Font footerFont = getFooterFontForPastSpendingSummary(messageResources);
                Calendar calendar = new GregorianCalendar();
                String year = ""+calendar.get(Calendar.YEAR);
                String today = calendar.get(Calendar.MONTH) + "/"+ calendar.get(Calendar.DAY_OF_MONTH)+ "/"+  year.substring(2);
                Rectangle page = document.getPageSize();
                PdfPTable foot = new PdfPTable(3);
                PdfPCell cell = new PdfPCell(new Paragraph(today, footerFont));
                cell = setCellDefaultSettings(cell, Rectangle.ALIGN_LEFT);
                foot.addCell(cell);
                cell= new PdfPCell(new Paragraph(getCenterFooter(year), footerFont));
                cell = setCellDefaultSettings(cell, Rectangle.ALIGN_CENTER);
                foot.addCell(cell);
                cell= new PdfPCell(new Paragraph(messageResources.getMessage("summary.pdf.footer.right") + " " +  writer.getPageNumber(), footerFont));
                cell = setCellDefaultSettings(cell, Rectangle.ALIGN_RIGHT);
                foot.addCell(cell);
                foot.setTotalWidth(page.width() - doc.leftMargin() - doc.rightMargin());
                foot.writeSelectedRows(0, -1, doc.leftMargin(), 20, writer.getDirectContent());
            }
            catch(Exception e){
                e.printStackTrace();
            }
        }

-----------------------------------------------------------------------------------------------------------------------------------------------


Any ideas?
Thank you very much!!!

Vicky





       
____________________________________________________________________________________
Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545469

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: itext

blowagie
vicky rodriguez wrote:
> It doesn't make any sense

You seem to be mixing class Table and class PdfPTable:

>  public void setDefaultTableSettings(Table table) {
>                 PdfPTable foot = new PdfPTable(3);

Also I'm not sure the way you dimension and position
the table is entirely correct. If all pages have the
same size, I suggest you define the position of the
table in the constructor of the event. That will at
least save you some CPU and probably give you a more
predictable result.
br,
Bruno

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
Loading...