Print margins in DOMPDF

三世轮回 提交于 2019-11-30 00:52:07

问题


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

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?

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).

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


回答1:


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

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

@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.




回答2:


sometimes you also need to set

html { margin: 0px}


来源:https://stackoverflow.com/questions/11649052/print-margins-in-dompdf

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