Php DOMPDF背景图像有时看起来很清晰
我正在使用DOMPDF创建一个证书,以便人们可以打印它。问题是背景图像有时看起来很清晰。这就是事情有时看起来很好,有时不好,我不知道为什么 我的pdf html代码是:Php DOMPDF背景图像有时看起来很清晰,php,dompdf,Php,Dompdf,我正在使用DOMPDF创建一个证书,以便人们可以打印它。问题是背景图像有时看起来很清晰。这就是事情有时看起来很好,有时不好,我不知道为什么 我的pdf html代码是: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<style>
@page {
margin:0;
padding:0;
}
body{
margin:0;
padding:0;
width:841px;
height:545px;
font-family:Verdana;
}
#lol{
width:841px;
height:545px;
background:url(30-Day-Goals-Certificate.jpg);
background-repeat: no-repeat;
position:relative;
}
.eating{
position: absolute;
top: 355px;
left: 425px;
color: #02436d;
font-size: 17px;
font-weight: bold;
font-family:"proxima";
}
.exercise{
position: absolute;
top: 387px;
left: 455px;
color: #02436d;
font-size: 17px;
font-weight: bold;
font-family:"proxima";
}
.name{
position: absolute;
top: 220px;
left: 275px;
color: #237e2f;
font-size: 42pt;
font-weight: bold;
font-family:"english";
}
.month_number{
position: absolute;
top: 172px;
left: 571px;
color: #02436d;
font-size: 28pt;
font-weight: bold;
font-family:"lucida";
}
</style>
</head>
<body>
<body>
<div id="lol">
<div class="eating">10</div>
<div class="exercise">12</div>
<div class="name">Jhon Doe</div>
<div class="month_number">#4</div>
</div>
</body>
</html>
@页面{
保证金:0;
填充:0;
}
身体{
保证金:0;
填充:0;
宽度:841px;
身高:545px;
字体系列:Verdana;
}
#哈哈{
宽度:841px;
身高:545px;
背景:url(30天目标证书.jpg);
背景重复:无重复;
位置:相对位置;
}
.吃{
位置:绝对位置;
顶部:355px;
左:425px;
颜色:#02436d;
字号:17px;
字体大小:粗体;
字体系列:“proxima”;
}
.运动{
位置:绝对位置;
顶部:387px;
左:455px;
颜色:#02436d;
字号:17px;
字体大小:粗体;
字体系列:“proxima”;
}
.姓名{
位置:绝对位置;
顶部:220px;
左:275px;
颜色:237e2f;
字号:42pt;
字体大小:粗体;
字体系列:“英语”;
}
.月号{
位置:绝对位置;
顶部:172px;
左:571px;
颜色:#02436d;
字号:28pt;
字体大小:粗体;
字体系列:“露西达”;
}
10
12
约翰·多伊
#4
图片可在
我的pdf生成器代码是:
<?php
require_once("dompdf_config.inc.php");
ob_start();
require("pdf.php");
$dompdf = new DOMPDF();
$dompdf->load_html(ob_get_clean());
$dompdf->set_paper(array(0,0,629.00,410.00),'portrait');
$dompdf->render();
$dompdf->stream();
?>
有人遇到同样的问题吗?这看起来像是一个ramdom错误,我想不出原因。提前感谢您的帮助您可以使用以下变量提高分辨率: def(“dompd_DPI”,96) 在dompdf_config.inc.php中
/**
* Image DPI setting
*
* This setting determines the default DPI setting for images and fonts. The
* DPI may be overridden for inline images by explictly setting the
* image's width & height style attributes (i.e. if the image's native
* width is 600 pixels and you specify the image's width as 72 points,
* the image will have a DPI of 600 in the rendered PDF. The DPI of
* background images can not be overridden and is controlled entirely
* via this parameter.
*
* For the purposes of DOMPDF, pixels per inch (PPI) = dots per inch (DPI).
* If a size in html is given as px (or without unit as image size),
* this tells the corresponding size in pt.
* This adjusts the relative sizes to be similar to the rendering of the
* html page in a reference browser.
*
* In pdf, always 1 pt = 1/72 inch
*
* Rendering resolution of various browsers in px per inch:
* Windows Firefox and Internet Explorer:
* SystemControl->Display properties->FontResolution: Default:96, largefonts:120, custom:?
* Linux Firefox:
* about:config *resolution: Default:96
* (xorg screen dimension in mm and Desktop font dpi settings are ignored)
*
* Take care about extra font/image zoom factor of browser.
*
* In images, <img> size in pixel attribute, img css style, are overriding
* the real image dimension in px for rendering.
*/
/**
*图像DPI设置
*
*此设置确定图像和字体的默认DPI设置。这个
*可通过明确设置
*图像的宽度和高度样式属性(即,如果图像是本机的
*宽度为600像素,指定图像的宽度为72点,
*在渲染的PDF中,图像的DPI为600
*背景图像不能被覆盖,并且是完全受控的
*通过这个参数。
*
*对于DOMPDF,每英寸像素数(PPI)=每英寸点数(DPI)。
*如果html中的大小以px表示(或不以图像大小表示单位),
*这以pt表示相应的大小。
*这将调整相对大小,使其与图形的渲染类似
*参考浏览器中的html页面。
*
*在pdf中,始终为1磅=1/72英寸
*
*各种浏览器的渲染分辨率(每英寸像素):
*Windows Firefox和Internet Explorer:
*系统控制->显示属性->字体分辨率:默认值:96,大字体:120,自定义:?
*Linux Firefox:
*关于:配置*分辨率:默认值:96
*(忽略mm中的xorg屏幕尺寸和桌面字体dpi设置)
*
*注意浏览器的额外字体/图像缩放因子。
*
*在图像中,“像素大小”属性(img css样式)被覆盖
*用于渲染的真实图像尺寸(以px为单位)。
*/
你好,你说的“sharp”是什么意思?你能给我两个PDF文件吗:一个正常,一个不正常。图像边缘清晰。我现在没有一个,因为我无法复制它。它只是随机发生的,只要我有一个,我就会帮你上传