【问题标题】:Fit content on pdf size with iTextSharp?使用 iTextSharp 使内容适合 pdf 大小?
【发布时间】:2015-04-17 23:34:32
【问题描述】:

我遇到了麻烦, 我设法将 pdf 文档的大小设置为我需要的大小(~3cm x ~7cm),但 pdf 中的内容占用了大约三分之一的空间。 而且我需要使用整个可用空间。

所以,这就是它的样子:

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

查看所有内容如何集中在中间的那个小空间中。 我尝试将表格宽度百分比设置为 100,但没有成功。

我能做什么?

【问题讨论】:

  • 考虑设置边距。这可以使用适用的构造函数或某种方法来实现。

标签: pdf itextsharp


【解决方案1】:

你目前有类似的东西:

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 个用户单位来添加内容。这与您的体验有些一致。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多