Here is the code I used to test it. The change I made to ColumnText works fine in production, but I am getting unexpected results in this test code. The headers are missing whenever the next "chunk" starts at the top of the page. Other than that, it seems to work.

package test;

import java.io.FileOutputStream;
import java.io.FileNotFoundException;

import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;

/**
* Created by ADP Lightspeed. User: olsenm Date: Oct 5, 2005 Time: 3:43:15 PM
*/
public class HeaderTest
{
   public static void main(String[] args)
   {
       try
       {
           Document pdfDoc = new Document();
PdfWriter writer = PdfWriter.getInstance(pdfDoc, new FileOutputStream("/home/olsenm/headertest.pdf"));
           pdfDoc.open();
           // set skipFirstHeader to false for first chunk
           pdfDoc.add(getContent(false));
           // add content in chunks with skipFirstHeader set to true
           for (int i=0; i < 10; i++)
               pdfDoc.add(getContent(true));
           pdfDoc.close();
           writer.flush();
           writer.close();
       }
       catch (DocumentException e)
       {
           e.printStackTrace();  //Todo - Implement this properly
       }
       catch (FileNotFoundException e)
       {
           e.printStackTrace();  //Todo - Implement this properly
       }
   }

   private static PdfPTable getContent(boolean skipHeader)
   {
       PdfPTable outerTable = getOuterContent();
       PdfPTable innerTable = getInnerContent();
       outerTable.setSkipFirstHeader(skipHeader);
       innerTable.setSkipFirstHeader(skipHeader);
       outerTable.addCell(innerTable);
       return outerTable;
   }

   private static PdfPTable getOuterContent()
   {
       PdfPTable outerTable = new PdfPTable(1);
       outerTable.setSplitRows( true);
       outerTable.setSplitLate( false);
       outerTable.addCell("OUTER HEADER");
       outerTable.setHeaderRows(1);
//        for (int i=1; i < 3; i++)
//            outerTable.addCell("   Outer Content " + i);
       return outerTable;
   }

   private static PdfPTable getInnerContent()
   {
       PdfPTable innerTable = new PdfPTable(1);
       innerTable.setSplitRows( true);
       innerTable.setSplitLate( false);
       innerTable.addCell("      INNER HEADER");
       innerTable.setHeaderRows(1);
       for (int i=1; i < 91; i++)
           innerTable.addCell("         Inner Content " + i);
       return innerTable;
   }
}

From: "Paulo Soares" <[EMAIL PROTECTED]>
To: "Matt Olsen" <[EMAIL PROTECTED]>,<[email protected]>
Subject: RE: [iText-questions] skipFirstHeader and large documents
Date: Tue, 4 Oct 2005 09:45:05 +0100

Are you sure this doesn't break the code when using it outside nested
tables? Can you post a small complete example both with inner and outer
tables?

> I removed the !firstPass from the conditional and it seems to
> work fine.  I
> submitted the change to SourceForge.
>
>

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to