使用iTextSharp使内容适合pdf大小吗? [英] Fit content on pdf size with iTextSharp?

查看:111
本文介绍了使用iTextSharp使内容适合pdf大小吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此有麻烦, 我设法将pdf文档的大小设置为所需的大小(〜3cm x〜7cm),但是pdf中的内容占用了大约三分之一的空间. 而且我需要使用整个可用空间.

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.

这就是它的样子:

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

查看所有内容如何集中在中间的那个小空间中. 我尝试将表格的widthpercentage设置为100,但是没有运气.

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.

我该怎么办?

推荐答案

您当前有类似的东西:

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

尝试以下方法:

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

0值是页边距的大小(左,右,上,下).如果您省略它们,则默认情况下(在任一侧)它们是36个用户单位.如果矩形的尺寸为85 x 200用户单位,则使用默认边距将使您的13 x 128用户单位添加内容.这与您所体验到的一致.

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.

这篇关于使用iTextSharp使内容适合pdf大小吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆