Skip to main content
Skip table of contents

How to use the full size of a page?

I managed to set the size of the PDF document I'm creating to the size I need (~3cm x ~7cm), but the content inside the page is only using a third of the space. I need to use the whole available space.

Posted on StackOverflow on Apr 17, 2015 by user1913644

You currently have something like:

JAVA
Rectangle rect = new Rectangle(85, 200);
Document document = new Document(rect);

Try this instead:

JAVA
Rectangle rect = new Rectangle(85, 200);
Document document = new Document(rect, 0, 0, 0, 0);

The 0 values are the size of the margins (left, right, top, bottom). If you omit them, they are 36 user units by default (on either side). If your rectangle measures 85 by 200 user units, using the default margins leaves you 13 by 128 user units to add content. This is somewhat consistent with what you experience.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.