html - 在dompdf中制作一个图像覆盖所有的第一页

标签 html css dompdf

我正在尝试获取一张图片来填充 dompdf pdf 的整页,之后的每一页都有页眉和页脚。使用下面的代码,它会创建附加的图像。我已经做了我能想到的一切来纠正这个问题,包括将所述图像的大小调整为 595px x 842px(A4 纸张大小)。我需要做些什么特别的事情吗?

$html .="<style> 
@page {
    margin-top:130px;
}
body {
    font-family: Arial, Helvetica, sans-serif;
}
.flyleaf {
    page-break-after: always;
    margin:-130px;
    padding:0;
  }
.flyleaf img {
  min-width: 100%;
  min-height: 100%;
}
.header,
.footer {
    width: 100%;
    text-align: center;
    position: fixed;
}
.header {
    top: -110px;
}

.footer {
    bottom: 0px;
}
</style>";
$html .='<div class="flyleaf" width="100%"><img style="max-width:100%;max-height:100%;" src="'.$header.'"></div>';
$html .='<div class="header">';
$html .='<td style="width:100px;"><img src="'.$logo.'"></td>';
$html .='</div>';
$html .='<div class="page">';
$html .='//Page content here';
$html .='</div>';
$html .='<div class="footer">';
$html .='//Footer content here';
$html .='</div>';

Image Example

最佳答案

对我很有帮助的是像这样为封面制作框架:

#cover_sheet {

    position         : absolute;

    top              : 0px;
    left             : 0px;
    right            : 0px;
    bottom           : 0px;

    overflow         : hidden;
    margin           : 0;
    padding          : 0;
}

应该可以在那里以正确比例输入 .svg 图像。

一个有助于检查的页面是 http://eclecticgeek.com/dompdf/debug.php

关于html - 在dompdf中制作一个图像覆盖所有的第一页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35484400/

相关文章:

php - 页面刷新时继续隐藏 HTML 输入字段?

javascript - jquery 和换行符

php - 在 opencart 中使用 css 更改 h 标签

php - MathJax html 渲染为 pdf

php - 使用 codeigniter 通过电子邮件发送 dompdf 生成的 pdf

javascript - 使用 Aurelia 对 Blur 进行现场验证

javascript - 将动画 GIF 的第一帧绘制到 HTML5 Canvas

html - 地铁风格中的 Div 位置

css - Chrome 图像显示太亮

php - 防止复制使用 dompdf 创建的 pdf 中的内容