Thanks Paulo for your help. It's wonderful iText exists and you support it
the way you do.

I noticed some bugs when I place a table in the header using events. If I
place an extra blank row at the bottom of the table, the first row gets
chopped off at page top. Only half of the first row will print. Correct
spacing is given between the header and the rest of the document. If I give
a blank row at the top it is ignored.

I am working now to get the header to position properly. It comes out too
close to the top of the page, probably at absolute zero for printable page
area, and no space below the header and the rest of the document. I need to
find a non printable character to hold a space, other than \n. I'm sure I
can get header positioning to work.

The following snippet will create a header with half the top row chopped
off:

public void onEndPage(PdfWriter writer, Document document) {
try {
Rectangle page = document.getPageSize();
PdfPTable table = new PdfPTable(3);
table.addCell(pdfPCellBold("MMIS Report XXXX",PdfPCell.ALIGN_LEFT,0));
table.addCell(pdfPCellBold("KidCare Application
Profile",PdfPCell.ALIGN_CENTER,0));
table.addCell(pdfPCellBold("Household ID#
"+rsA.getString("APPL_ID").trim(),PdfPCell.ALIGN_RIGHT,0));
table.addCell(pdfPCellBold(ToolsMisc.shortTimestamp(rsA.getTimestamp("UPDT_TST")),PdfPCell.ALIGN_LEFT,2));
table.addCell(pdfPCellBold("[  ]  3089 Found",PdfPCell.ALIGN_RIGHT,0));
table.addCell(pdfPCellBold("\n",0,3));
table.setTotalWidth(page.width() - document.leftMargin() -
document.rightMargin());
table.writeSelectedRows(0, -1, document.leftMargin(), page.height() -
document.topMargin() + table.getTotalHeight(), writer.getDirectContent());

private static PdfPCell pdfPCellBold(String s, int justify, int span) {
Font fo = new Font();
fo.setStyle(fo.BOLD);
PdfPCell c = new PdfPCell(new Phrase(s,fo));
c.setBorder(0);
if (span > 0) c.setColspan(span);
c.setHorizontalAlignment(justify);
return c;
}

>From: "Paulo Soares" <[EMAIL PROTECTED]>
>Date: Tue, 1 Feb 2005 09:41:49 -0000
>
>You must use PdfPTable and page events. See the example
>headers_and_watermarks.java at itextpdf.sf.net.
>
>> -----Original Message-----
>> From: [EMAIL PROTECTED] 
>> [mailto:[EMAIL PROTECTED] On 
>> Behalf Of David McDivitt
>> Sent: Tuesday, February 01, 2005 12:12 AM
>> To: [email protected]
>> Subject: Re: [iText-questions] use table in header
>> 
>> I can almost get a table to work with the following:
>> 
>>   Phrase ph = new Phrase();
>>   ph.add(new Chunk("MMIS Report XXXX"));
>>   ph.add(new Chunk("KidCare Application Profile"));
>>   ph.add(new Chunk("Household ID# "+rsA.getString("APPL_ID").trim()));
>>   ph.add(Chunk.NEWLINE);
>>   ph.add(new 
>> Chunk(ToolsMisc.shortTimestamp(rsA.getTimestamp("UPDT_TST"))));
>>   ph.add(new Chunk(""));
>>   ph.add(new Chunk("[  ]  3089 Found"));
>>   ph.add(Chunk.NEWLINE);
>>   HeaderFooter hf = new HeaderFooter(ph,false);
>>   hf.setBorder(0);
>>   doc.setHeader(hf);
>>   doc.open();
>> 
>> Is there some way to set the phrase width similar to a table, 
>> then, can
>> alignment be set for each of the chucks? Thanks
>> 
>> 
>> >From: David McDivitt <[EMAIL PROTECTED]>
>> >Date: Mon, 31 Jan 2005 16:07:08 -0600
>> >
>> >I must add a header to the PDF and the header must be a 
>> table. I've spent
>> >all day and cannot figure out how. I am not using PdfP 
>> objects but just
>> >plain objects: Table and not PdfPTable.
>> >
>> >Through trial and error I found out a command such as:
>> >
>> >   doc.setHeader(new HeaderFooter(new Phrase("xx"),false));
>> >
>> >must come before doc.open(); . I need the page header to have a table
>> >instead of a phrase. Help would be appreciated. Thanks
>> 
>> 
>> 
>> -------------------------------------------------------
>> This SF.Net email is sponsored by: IntelliVIEW -- Interactive 
>> Reporting
>> Tool for open source databases. Create drag-&-drop reports. Save time
>> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
>> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
>> _______________________________________________
>> iText-questions mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/itext-questions



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to