开发者

DOMPDF Page background (or alternatives?)

开发者 https://www.devze.com 2023-02-09 00:13 出处:网络
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 pad开发者_开发百科ding with a border and then inside that

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 pad开发者_开发百科ding 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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号