我知道有类似的问题,但没有解决我的问题 . 我想用mPDF做的是以下内容:
Page 1: Text for item 1
Page 2: Full width and height image to cover the page with an image of item 1
Page 3: Text for item 2
Page 4: Full width and height image to cover the page with an image of item 2
...
下面的代码以一种方式拉伸图像,我想实现:
body {
background-image:url("image1.jpg");
background-image-resize: 5;
background-position: top center;
}
但这会导致在每个页面上设置图像(我知道,它是body元素) . 所以我尝试了以下内容:
<div style='
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image:url("image1.jpg");
background-image-resize: 5;
background-position: top center;
'></div>
但这不起作用 . 所以我尝试使用相同的代码,只使用颜色,而不是图像:
<div style='
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #F00;
'>
</div>
<div style="page-break-before: always;"></div>
这是有效的 . 整个页面都是红色的 . 那么如何用图像来实现呢?
有任何想法吗?
1 回答
经过大量的试用后,我发现,这样做的简单方法就是将HTML代码分成不同的部分,然后用单独的WriteHtml调用插入它们 . 例如: