DOMPDF Page background (or alternatives?)

做~自己de王妃 提交于 2020-01-16 18:27:11

问题


I am trying to export some dynamic content into a PDF file with a small bit of page formatting.

I'd like to have the PDF pages have a small padding with a border and then inside that border, a small company logo should appear up the top right on each page.

Now the issue is that because the content is dynamic, the number of pages and content per page can vary. This means I can't manually create a DIV with a border and an image inside because the content could be more or less pages depending on what gets exported.

I'm trying to find a way to create a 'page background' for each PDF page and then in this background I would then draw up the borders and the logo and then have all the content superimposed on this customer background.

Is this even at all possible with DOMPDF? Or are there any alternatives that may provide a little more customisation like this?


回答1:


jfoucher's method could be what you need, but if you need an HTML content and/or a logo on each page, you could also use DOMPDF from the SVN trunk, and use fixed positionning, like if the "CSS position fixed" example here.




回答2:


This is indeed possible with dompdf.

What I do is simply set the following CSS properties (or similar) on the body:

body{
    background-image:url('/assets/img/bg_pdf.jpg');
    background-repeat:no-repeat;
    background-position: 15px 1450px;
}

In this case, I am using it for a page footer, but change these values according to your needs. The pixels values are obtained by trial and error... The background is an actual image, which you'll have to create in an image editor.



来源:https://stackoverflow.com/questions/4910187/dompdf-page-background-or-alternatives

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