gpt4 book ai didi

php - 生成带有无边距背景图像的 PDF

转载 作者:行者123 更新时间:2023-12-04 10:57:51 27 4
gpt4 key购买 nike

我想在 CodeIgniter 中使用 DOMPDF 工具生成 PDF。

我有一张图片,我想在背景完整的 DIN A4 PDF 页面中显示它,当我尝试这样做时:

body{
background-image: url('http://blogs.ucl.ac.uk/quantum/files/2013/12/artwork-fullsize.jpg'); background-position: bottom right; background-repeat: no-repeat;
background-size: 100%;
width:100%;
height:100%;
padding: 0px;
margin: 0px;
}

我有一个 PDF,但它显示有边距(或填充)。我想要没有边距或填充,只有完整的 100% 图像背景。

谢谢,

最佳答案

dompdf 尚不支持 background-size 声明。最简单的解决方法是绝对定位图像并将尺寸设置为页面尺寸(百分比计算似乎仍然有点偏差)。您必须考虑页边距,因此您也应该设置这些页边距。

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
@page { margin: .5in; }
.bg { top: -.5in; right: -.5in; bottom: -.5in; left: -.5in; position: absolute; z-index: -1000; min-width: 8.5in; min-height: 11in; }
</style>
</head>
<body>
<img class="bg" src="http://eclecticgeek.com/images/macro/ants.jpg">
</body>
</html>

关于php - 生成带有无边距背景图像的 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32792412/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com