1T3XT info <info <at> 1t3xt.info> writes:

> 
> I would work with ColumnText.
> 
> For the first page, I would add the first page of the template
> without the fields as the background of my new document.
> I would retrieve the positions of the fixed items, and put them
> on the page using ColumnText.
> 
> Then I would create a ColumnText object for the unstructured content;
> I would add the unstructured content using paragraphs, tables,...
> I would also call go() on a regular basis. Whenever a new page is
> needed, I would add a new page with the second page of the template
> as background.


Brilliant,

I ended up using a PdfPageEventHelper to set the template to either first page,
or follow-up page types and then put my content into 2 columnText blocks (for
left and right sides of the page) - since either could be >1 page long.. 

Then I wrote a little block of code to continue to add pages so long as either
columnText had content still to write out:

do
{
        int iLeftColHasMore = ct.go();
        int iRightColHasMore = ctRight.go();

        ct.setSimpleColumn(35.2716f, 105.56f, 137.131f, 704.298f, 12.0f,
Element.ALIGN_LEFT);
        ctRight.setSimpleColumn(154.747f, 65.5776f, 577.704f, 703.88f, 12.0f,
Element.ALIGN_LEFT);

        if (ColumnText.hasMoreText(iLeftColHasMore) ||
ColumnText.hasMoreText(iRightColHasMore))
        {
                document.newPage();
                Phrase pageNumTitle = new Phrase();
                pageNumTitle.add(new Chunk("Page " + iPageNumber, 
PDFNoteUtil.NOTETYPE));
                setPageHeader(writer, document, pageNumTitle, 
veVisit.getPatient());
                iPageNumber++;
        }
}
while (ColumnText.hasMoreText(ct.go()) || ColumnText.hasMoreText(ctRight.go()));

Works GREAT! Thanks for all of your help.

On to a new challenge -- I'd like to have lists as part of one of the
columnTexts, but have learned that that's unsupported (and I even think I
understand why). But I can't seem to hack my way around it. I need the
columnText magic to span pages, but I'd like to take advantage of lists (and
images, etc)...

I can't seem to use any indentation voodoo on the inner paragraphs as well (they
all seem to be ignored when nested inside of CT?) I was thinking of trying to
use a negative indent to fake it, but can't make that work. 

So - how does one have a multipage spanning CT (or the like) and get to use/fake
numbered lists?

Thanks again.

Dan  


------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to