Well, if I do not use -1 as for num of rows, I need split the data manually 
so that they can fit to each pages. But there is another problem. It seems 
that on 2nd and following pages, the table starts at the same location (same 
Y value), but i want the table on the first page to be located at 1/3 of the 
top, and on 2nd and other pages the table starts from the top of the page.

Part of my code is here:

int totalRows = 1000;
int numOfColumns = 5;

// read all the rows data
for (int i = 0; i < 1000; i++)
{
        for (int j = 0; j < numOfColumns; j++)
        {
                PdfPCell num = new PdfPCell(new Paragraph("xxx " + i));
                t.addCell(num);
        }
}

// write first page of the table
// Note: The table starts at the 1/3 top of the page (Y = 300), and there 
are 40 rows
table.setTotalWidth(document.right() - document.left());
table.writeSelectedRows(0, 40, document.left(), document.right(), 
writer.getDirectContent());

// write the leftover of the rows to the tables on 2nd and more pages
// Note: the table on 2nd and following pages are starting at top of the 
page (Y = 600).
int leftRows = 1000 - 40;
for (int i = 0; i < leftRows/80; i++)       // 80 rows for each page
{
        document.newPage();
        table.setTotalWidth(document.right() - document.left());
        table.writeSelectedRows(40 + i * 80, 100 + i * 80, document.left(), 
document.right(), cb);
}

I have tried added these codes after write first page table rows, but this 
does not move the table up to the top for 2nd pages and following ones:

                        PdfContentByte cb = writer.getDirectContent();
                        ColumnText ct = new ColumnText(cb);
                        float currentY = ct.getYLine();
                        currentY -= 200;

Is something wrong in my code? Howe can I make the table which holds 
thousands of rows data have different Y values on different pages?

Here is the layout for better understanding:

page 1:
text
text, etc
table

page 2, 3, ....
table

last page:
table
text

Thanks

Ruitao





>From: Bruno Lowagie <[EMAIL PROTECTED]>
>Reply-To: Post all your questions about iText here 
><[email protected]>
>To: Post all your questions about iText here 
><[email protected]>
>Subject: Re: [iText-questions] Table position
>Date: Fri, 27 Oct 2006 16:56:00 +0200
>MIME-Version: 1.0
>Received: from lists-outbound.sourceforge.net ([66.35.250.225]) by 
>bay0-mc6-f1.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2444); Fri, 27 
>Oct 2006 07:56:45 -0700
>Received: from sc8-sf-list2-new.sourceforge.net (unknown [10.3.1.94])by 
>sc8-sf-spam2.sourceforge.net (Postfix) with ESMTPid 09A1112E26; Fri, 27 Oct 
>2006 07:56:44 -0700 (PDT)
>Received: from sc8-sf-mx2-b.sourceforge.net 
>([10.3.1.92]helo=mail.sourceforge.net)by sc8-sf-list2-new.sourceforge.net 
>with esmtp (Exim 4.43)id 1GdT8S-0001g2-3P for 
>[email protected];Fri, 27 Oct 2006 07:56:40 -0700
>Received: from outmx026.isp.belgacom.be ([195.238.4.91])by 
>mail.sourceforge.net with esmtps (TLSv1:AES256-SHA:256)(Exim 4.44) id 
>1GdT8O-0001Bp-LOfor [email protected];Fri, 27 Oct 2006 
>07:56:41 -0700
>Received: from outmx026.isp.belgacom.be (localhost [127.0.0.1])by 
>outmx026.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-OUT-2.22)with 
>ESMTP id k9REuOKO013954for <[email protected]>;Fri, 27 
>Oct 2006 16:56:24 +0200 (envelope-from <[EMAIL PROTECTED]>)
>Received: from [192.168.1.4] 
>(196.137-246-81.adsl-dyn.isp.belgacom.be[81.246.137.196])by 
>outmx026.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-OUT-2.22)with 
>ESMTP id k9REuNsC013939for <[email protected]>;Fri, 27 
>Oct 2006 16:56:24 +0200 (envelope-from <[EMAIL PROTECTED]>)
>X-Message-Info: LsUYwwHHNt0X1+xpBiNuYA6ETIUbh7p8Vl3NXe3esr4=
>User-Agent: Thunderbird 1.5.0.7 (Windows/20060909)
>References: <[EMAIL PROTECTED]>
>X-Spam-Score: 0.0 (/)
>X-Spam-Report: Spam Filtering performed by sourceforge.net.See 
>http://spamassassin.org/tag/ for more details.Report problems 
>tohttp://sf.net/tracker/?func=add&group_id=1&atid=200001
>X-BeenThere: [email protected]
>X-Mailman-Version: 2.1.8
>Precedence: list
>List-Id: Post all your questions about iText 
>here<itext-questions.lists.sourceforge.net>
>List-Unsubscribe: 
><https://lists.sourceforge.net/lists/listinfo/itext-questions>, 
><mailto:[EMAIL PROTECTED]>
>List-Archive: 
><http://sourceforge.net/mailarchive/forum.php?forum=itext-questions>
>List-Post: <mailto:[email protected]>
>List-Help: 
><mailto:[EMAIL PROTECTED]>
>List-Subscribe: 
><https://lists.sourceforge.net/lists/listinfo/itext-questions>, 
><mailto:[EMAIL PROTECTED]>
>Errors-To: [EMAIL PROTECTED]
>Return-Path: [EMAIL PROTECTED]
>X-OriginalArrivalTime: 27 Oct 2006 14:56:45.0182 (UTC) 
>FILETIME=[1ECFB9E0:01C6F9D8]
>
>Ruitao Duan wrote:
> > Hi Bruno,
> >
> > Thanks for your reply. PdfPTable.writeSelectedRows is the method that i 
>have
> > tried:
> >     PdfPTable.writeSelectedRows(0, -1, 100, 300, cb);
> >
> > But I have over 1000 rows of data in the table, and that method prints 
>out
> > all the data in one page only.
>
>That's because you don't use the method correctly.
>You set the number of rows to be printed to -1;
>this means you want to print ALL the rows.
>If you change this for instance to 5, only 5
>rows will be printed.
>Note that the method returns the Y-value of the
>position where the table ends.
>br,
>Bruno
>
>-------------------------------------------------------------------------
>Using Tomcat but need to do more? Need to support web services, security?
>Get stuff done quickly with pre-integrated technology to make your job 
>easier
>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>_______________________________________________
>iText-questions mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/itext-questions

_________________________________________________________________
Stay in touch with old friends and meet new ones with Windows Live Spaces 
http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to