问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/29711104/fit-content-on-pdf-size-with-itextsharp