DOMPDF中的页边距 [英] Print margins in DOMPDF

查看:191
本文介绍了DOMPDF中的页边距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用DOMPDF生成PDF. 我有一些HTML,然后将其转换为PDF.

I'm trying to generate a PDF using DOMPDF. I have some HTML which is then converted into a PDF.

但是我有一个问题.当我在页面顶部放置一个对象(例如图标)时,在PDF中它也会显示在页面顶部. 但是,当我打印PDF时有一定的余量.我知道必须有一个最小的余量,但就我而言,它太大了. 有什么方法可以控制DOMPDF中的此边距?

But I have a problem. When I put an object at the top of the page (e.g. an icon), in the PDF it's also show on the top of the page. But when I print the PDF there is a margin. I know that there has to be a minimal margin, but in my case it's just too large. Is there some way to control this margin in DOMPDF?

我正在尝试复制现有文档,并且徽标的原始位置不在页面顶部(PDF中已经有页边距).但是当我打印它时,它的位置与我生成的PDF的位置完全相同(并且PDF中没有空白).

I'm trying to reproduce an existing document and in the original the logo is not on the top of the page (there is already a margin in the PDF). But when I print it, it's located at the exact same position as in the PDF generated by me (and there is no margin in the PDF).

PDF中是否已设置打印边距?

Is there somewhere a print margin already set in the PDF?

推荐答案

以下样式将有效地将文档的边距设置为0:

The following style will effectively set the margins of your document to 0:

@page { margin: 0px; }
body { margin: 0px; }

dompdf 0.6.0使用

@page,dompdf 0.5.1使用body.您可以单独修改页面和正文的页边距,尽管现在两者的页边距共同充当您的内容边界.

@page is used by dompdf 0.6.0, body by dompdf 0.5.1. You can modify the margin of the page and body independently, though right now the margin of the two together acts as your content bounds.

这篇关于DOMPDF中的页边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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