Itext - a5 page size is the vertical half of a4

4.6k Views Asked by At

i'm trying to create a pdf that must be on a5 format ( the horizontal half on an a4 )

like wikipedia source i need that my page size must be equals to the horizontal half of a4 but using this:

Document document = new Document(PageSize.A5, 10, 10, 10, 10);

it creates me this:

enter image description here

But i need this:

enter image description here

(With all table inside rotated )

How can i fix? can someone help me? thanks!!!

2

There are 2 best solutions below

1
On

iText in Action, 2nd Edition, in chapter 13 has an example which rotates all pages in a PDF file by 90 degrees. The sample source code is available as RotatePages.java in the SourceForge iText SVN repository.

1
On

I solved simply in this way:

Document document = new Document(PageSize.A5.rotate(), 10, 10, 10, 10);

So

PageSize.A5 generate a page which size is vertical half of A4

PageSize.A5.rotate() generate a page which size is horizontal half of A4