Paulo -

 

Ok, I got a little farther on this issue.  I have included a small
program here the is ugly but demonstrates the problem.  Notice that if
you run it, page 3 has only a header on it. Not actually text.  I have
narrowed this issue down to the fact that I MUST use a PdfPTable in my
header creation.  Probably not a normal thing to do, but it makes for
simple headers with a lot of data. 

 

    static void tabletest()

    {

        // list of patients reviewed - no reccomendation

        Console.WriteLine("Test Report");

        Phrase newline = new Phrase("\n");

        

        // Document Creation call - Margins are Left, Right, Top, Bottom
- pagesizes are standards

        Document document = new Document(PageSize.LETTER, 54, 54, 36,
36);

        

        // Initiate the PDF Writer - Creates File Name to output

        PdfWriter writer = PdfWriter.GetInstance(document, new
FileStream("TestReport.pdf", FileMode.Create));

        // Sets PDF Version to Acrobat 8 (use n+1 to determine Acrobat
version required) Set to Version 8 for simplicity

        writer.SetPdfVersion(PdfWriter.PDF_VERSION_1_7);

                    

        // Open the main document

 

       //Header Population

        PdfPTable headtable = new PdfPTable(3);

        for (int i = 0; i < 25; i++)

        {

            headtable.AddCell("Some Head Text");

        }

 

        Paragraph chead = new Paragraph();

        chead.Add(headtable);

 

        HeaderFooter centerhead = new HeaderFooter(chead, false);

        centerhead.Border = Rectangle.BOTTOM_BORDER;

 

        //Defining a document.Footer=centerhead; does really strange
things.. the whole table is at the top of the page

 

        document.Header=centerhead;

        

        // Stuff to till the Body

        document.Open();

        Phrase title = new Phrase("Da Report");

        document.Add(newline);

        document.Add(title);

        Paragraph NoCommentIntro = new Paragraph("A lot of text of some
kind");

        document.Add(NoCommentIntro);

        document.Add(newline);

 

        float[] widths2 = { 227, 110, 110 };

        PdfPTable PatList = new PdfPTable(widths2);

        PatList.HorizontalAlignment = Element.ALIGN_CENTER;

        PatList.DefaultCell.Border = Rectangle.NO_BORDER;

        PatList.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;

 

        //Define repeating headerow

        PatList.HeaderRows = 1;

 

        PatList.AddCell(new Phrase("Patient"));

        PatList.AddCell(new Phrase("Last Review"));

        PatList.AddCell(new Phrase("Status"));

 

        for (int i = 0; i < 60; i++)

        {

            PatList.AddCell(new Phrase("Bob Smith"));

            PatList.AddCell(new Phrase("A 302"));

            PatList.AddCell(new Phrase("Hospitalized"));

        }

        document.Add(PatList);

 

        PdfPTable sigs = new PdfPTable(2);

        sigs.WidthPercentage = 90;

        sigs.ExtendLastRow = true;

        PdfPCell RxSig = new PdfPCell(new Phrase("Signature2"));

        RxSig.HorizontalAlignment = Element.ALIGN_RIGHT;

        PdfPCell PSig = new PdfPCell(new Phrase("Signature2"));

        PSig.HorizontalAlignment = Element.ALIGN_RIGHT;

        sigs.AddCell(RxSig);

        sigs.AddCell(PSig);

        document.Add(sigs);

        

 

        document.Close();

    }

 

 

FYI: Visual Studio 2008 - C#

iTextSharp: File Version is 4.1.2.0

 

 

This issue ONLY seems to occur when I use a table in my header layout.
To make this work I have wrapped my table in a paragraph before adding
it to the header.   This inclusion or exclusion of the footer does not
seem to make a difference unless the footer is a table and then it just
gets weird!     Is this just a weird glitch in the functions or have I
stumbled onto an undocumented feature?

 

 

Matt

 

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to