Hi All,

Let me give you brief desc

 

I am using  two classes

  1. PDFAllPDFGen which generates pdf of all schedules(nearly 25 schedules)  in application

  2. Sched1PDFgen which generates individual  pdf I,e for schedule1

 

In Sched1PDFgen  I've method   

public void writeSched1(PdfWriter writer, Document document, HttpServletRequest request,HttpServletResponse response)

which takes above params and is used by both classes.

 

This method is invoked from  

 public void generate(HttpServletRequest request, HttpServletResponse response) throws IOException,Exception  of Sched1PDFgen which writes to stream

 

 

In PDFAllPDFGen generate method I am calling

Methods by instantiating each class like

public void generate(HttpServletRequest request, HttpServletResponse response)

{

   //For Sched1

   Sched1PDFgen  sched1 = new Sched1PDFgen ();

  sched1. writeSched1(PdfWriter writer, Document document, HttpServletRequest request,HttpServletResponse response);

 document.newPage();

//For Sched2

   Sched2PDFgen  sched1 = new Sched2PDFgen ();

  Sched2. writeSched2(PdfWriter writer, Document document, HttpServletRequest request,HttpServletResponse response);

 

}

Now problem is in Sched1

 

I am using PdfPTable in for loop

 

PdfPTable ancExp_body_Table = getAncExpHeaderTable();

for(int i=0 ; i<anc_income.length ;i++ )

 {

                 

                 String acctNo = anc_income[i].accountNumber.toString();

                 String expClass ="";

                 if(!anc_income[i].expenseClassification.trim().equals("null") && anc_income[i].expenseClassification != null)

                                expClass = anc_income[i].expenseClassification;

                String amt = nf.format(anc_income[i].amount);

                cell = new PdfPCell(new Paragraph(acctNo,normalFont));

                ancExp_body_Table.addCell(cell);

                cell = new PdfPCell(new Paragraph(expClass,normalFont));

                ancExp_body_Table.addCell(cell);

                cell = new PdfPCell(new Paragraph(amt,normalFont));

                ancExp_body_Table.addCell(cell);

 

                if (!writer.fitsPage(ancExp_body_Table)) {

                                System.out.println("Inside 8 fitpage");

                                ancExp_body_Table.deleteLastRow();

                                i--;

                                if(ancExp_body_Table.size() >1)

                                {

                                                ancExp_body_Table.writeSelectedRows(0, -1, document.left(),  document.top()-38, cb);

                                }

                                System.out.println("Before");

                                document.newPage();

                                System.out.println("After");

                                ancExp_body_Table = getAncExpHeaderTable();

                                //ancExp_header_Table.writeSelectedRows(0, -1, document.left(),  document.top()-20, cb);

                }

 

 }

}

 ancExp_body_Table.writeSelectedRows(0, -1, document.left(),  document.top()-38, cb);

 

Now problem is when table doesn't fit in writer  it is checking for condition(marked in orange) and opening a new page  when method is called from Sched1PDfGen .But data is truncated when method is called from PDFAllPDFGen  writer  is not opening a new Page().

Can anyone please help me with this issue?

 

Thanks,

Suneetha

Attachment: Sched2.pdf
Description: Binary data

Attachment: Sched8.pdf
Description: Binary data

Reply via email to