Fit content on pdf size with iTextSharp?

不问归期 提交于 2020-01-06 15:05:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!