为什么我的内容与我的页脚重叠? [英] Why is my content overlapping with my footer?

查看:411
本文介绍了为什么我的内容与我的页脚重叠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用itextsharp生成pdf ...我的问题是我的内容/文字页脚...我想自动将内容分解为新页面...如果它出现在页脚...

I am using itextsharp to generate pdf ...i m getting problem is my content/text coming upon footer...i want to automatically break down content to new page...if it comes upon footer..

现在我正在使用document.newpage()

right now i m using document.newpage()

但我想自动完成我的页面/内容自动分解到新的页面..它不应该来到页面的页眉/页脚...

but i want to do it automatically that my page /content automatically breakdown to new page..it should not come to header/footer of page...

我通过这个类创建页眉/页脚的信息

FOr Information i create header/footer through this class

public class ITextEvents : PdfPageEventHelper

我用过这个函数

public override void OnEndPage

我还附上即时通讯的结果...
请帮助我...如果你在评论中提问,我可以分享更多信息

I m attaching also the result that i m getting right now... please help me on this...i can share more information if you ask in comments

我希望最后一个框自动进入新页面.....

i want this last box to come automatically to new page.....

推荐答案

假设您使用 document.add()添加流动内容,则必须确保定义底部边距足以容纳页脚。

Assuming that you are adding the flowing content using document.add(), you have to make sure that you define a bottom margin that is sufficiently large to accommodate the footer.

您不能共享 OnEndPage 方法,但假设你有类似的东西:

You don't share the code you have in your OnEndPage method, but suppose that you have something like:

canvas.MoveTo(36, 50);
canvas.LineTo(559, 50);
canvas.Strike();

这从 x = 36 中划出一条线至 x = 559 at y = 50

This draws a line from x = 36 to x = 559 at y = 50.

假设您已经创建了文档,如下所示:

Suppose you have created your Document like this:

Document document = new Document();

在这种情况下,您创建的文档包含A4格式的页面(595 x 842用户单位) )和36个用户单位的边距。由于底部边距仅为36个用户单位,因此您的内容可能与从底部以50个用户单位绘制的线重叠。

In this case, you are creating a document with pages in the A4 format (595 x 842 user units) and margins of 36 user units. As the bottom margin is only 36 user units, your content risks overlapping with the line drawn at 50 user units from the bottom.

您应该更改创建文档,如下所示:

You should change the line where you create the Document like this:

Document document = new Document(PageSize.A4, 36, 36, 36, 55);

现在您的下限为55个用户单位,而您在50个用户单位下划线不再重叠。

Now you have a bottom margin of 55 user units and the line you draw at 50 user units no longer overlaps.

注意:我使用术语用户单位,因为这是我们在PDF中定义测量的方式。默认情况下,1个用户单位等于1个点。默认保证金为36个用户单位或半英寸。

Note: I use the term user units because that's how we define measurements in PDF. By default 1 user unit equals 1 point. The default margin is 36 user units or half an inch.

这篇关于为什么我的内容与我的页脚重叠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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