user1913644
user1913644

Reputation: 155

Fit content on pdf size with iTextSharp?

I'm having troubles with this, I managed to set the size of the pdf document to the one I needed (~3cm x ~7cm), but the content inside the pdf is using like a third of the space. And I need to use the whole available space.

So, this is how it looks:

http://s9.postimg.org/hrxsjjagv/fill.png

See how all the content is centered in that little space in the middle. I tried setting the table widthpercentage to 100, with no luck.

What can I do?

Upvotes: 0

Views: 758

Answers (1)

Bruno Lowagie
Bruno Lowagie

Reputation: 77528

You currently have something like:

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

Try this instead:

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.

Upvotes: 1

Related Questions