0

I'm using iText 5.4.4 and I want to generate a PDF for a continuous paper ticket printer. My doubt is how to set the new Document to avoid splitting the pdf in several pages:

Rectangle pagesize = new Rectangle(360f, 720f);
Document document = new Document(pagesize, 36f, 72f, 108f, 180f);

There is any posibility to do this ?

j08691
  • 204,283
  • 31
  • 260
  • 272

1 Answers1

1

PDF is not HTML. PDF is a Page Description Language. At the root of a PDF file, you have an object named the Catalog dictionary. In this Catalog dictionary, there is a reference to a page tree. This page tree is a structure that contains references to every page in the file. A page is an autonomous element in the PDF. Suppose that you have a PDF with 10,000 pages and you only need page 10,000, then you can fetch that page directly without having to render the 9,999 preceding pages. This is a "raison-d'ĂȘtre" of PDF. Hence your question sounds very strange: it is inherent to PDF to have pages.

It seems as if you want to create a PDF with a single page, containing a number of tickets each measuring 10 inches in height. In that case, you have to create a large page on which you print all these tickets (note that this is a bad idea, but I'm merely answering your question).

You need to take into account, that there's a maximum size for a PDF page. This maximum is 14,400 for the width and 14,400 for the height. So if you want to create a single page for a large number of tickets each having a height of 10 inch, you can create a page like this:

Rectangle pagesize = new Rectangle(360f, 14400f);

You will be able to fit 20 tickets with height 10 inch (720 user units) on this page, not more.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165