How to continue an ordered list on a second page?

I am currently creating the document by creating ColumnText objects that are placed at specific coordinates. The content consists of variable data (text/barcodes/images) that is added to existing PDF documents/templates (think boiler plate). Most commonly, I have to place various sections of text in specific places.

I know how to create an ordered list, but I have come across a situation where the list begins with #1 on the first page and then #2-4 on the top of the second page. I use two different templates for p1 and p2.

However, when I start a new list for the part on the second page, iText starts numbering that new list from 1 instead of continuing with 2.

Posted on StackOverflow on Mar 26, 2015 by rcurrydev

You don't need two List objects, one for the first page and one for the second page. IText 7 provides a ColumnDocumentRenderer class and you can easily set the areas where you want your elements to appear.

ColumnDocumentRenderer renderer = new ColumnDocumentRenderer(doc,
   new Rectangle[]{new Rectangle(250, 400, 250, 406)});

In renderer constructor the second parameter is an array of columns (one column in this code snippet).

Now if you add to the document any sort of data, be sure it will appear only in the areas, you've specified. The list order won't be lost as well.

List list = new List(ListNumberingType.DECIMAL);
for (int i = 0; i 

Take a look at the ListInColumn example for more information. Here is what the result looks like:



Click this link if you want to see how to answer this question in iText 5.

Ready to use iText?

Try our iText 7 Library and add-ons FREE for 30 days. Test your proof of concept, and see if our solution is right for you.

Get my FREE trial

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now