本文介绍了使用MPDF的PDF页面周围的边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有边框的html页面,但是当我使用MPDF时,他会打断div,而不是在损坏的div上方或下方放置边框,有人知道如何解决它,或者让每个带有边框的页面

I have an html page that has borders around, but when I use the MPDF, he breaks a div and not puts border above or down of the broken div, does anyone know how to fix it, or let each page with border around?

推荐答案

也许您可以尝试使用水印进行入侵:

Perhaps you could try a hack using watermarks:

http://www.olivettorestaurante.com.br/mpdf/examples/example35_watermarks.php

用作水印的整页正方形图像可能有效.我知道,这有点奇怪,但是有时MPDF在遇到一些问题时会变得很奇怪...:/

A full page square image used as watermark could work. I know, a bit triky, but sometimes MPDF turns weird when facing some problems... :/

一个更好的答案将很受欢迎.这是MPDF示例目录中与水印有关的简单代码:

A better answerd would be wellcome. Here is the sampl code available in the MPDF examples directory, related to watermarks:

<?php
$html = '
<h1>mPDF</h1>
<h2>Watermarks</h2>
<p>P: Nulla felis erat, imperdiet eu, ullamcorper non, nonummy quis, elit. Suspendisse potenti. Ut aeros at ligula vehicula pretium. Maecenas feugiat pede vel risus. Nulla et lectus. Fusce eleifend neque sit amet erat. Integer consectetuer nulla non orci. Morbi feugiat pulvinar dolor. Cras odio. Donec mattis, nisi id euismod auctor, neque metus pellentesque risus, at eleifend lacus sapien et risus. Phasellus metus. Phasellus feugiat, lectus ac aliquam molestie, leo lacus tincidunt turpis, vel aliquam quam odio et sapien. Mauris ante pede, auctor ac, suscipit quis, malesuada sed, nulla. Integer sit amet odio sit amet lectus luctus euismod. Donec et nulla. Sed quis orci.</p>
<hr />
<div>DIV: Proin aliquet lorem id felis. Curabitur vel libero at mauris nonummy tincidunt. Donecimperdiet. Vestibulum sem sem, lacinia vel, molestie et, laoreet eget, urna. Curabitur viverra faucibus pede. Morbi lobortis. Donec dapibus. Donec tempus. Ut arcu enim, rhoncus ac, venenatis eu, porttitor mollis, dui. Sed vitae risus. In elementum sem placerat dui. Nam tristique eros in nisl. Nulla cursus sapien non quam porta porttitor. Quisque dictum ipsum ornaretortor. Fusce ornare tempusenim. </div>
<div>DIV: Proin aliquet lorem id felis. Curabitur vel libero at mauris nonummy tincidunt. Donecimperdiet. Vestibulum sem sem, lacinia vel, molestie et, laoreet eget, urna. Curabitur viverrafaucibus pede. Morbi lobortis. Donec dapibus. Donec tempus. Ut arcu enim, rhoncus ac, venenatis eu, porttitor mollis, dui. Sed vitae risus. In elementum sem placerat dui. Nam tristique eros in nisl. Nulla cursus sapien non quam porta porttitor. Quisque dictum ipsum ornaretortor. Fusce ornare tempusenim. </div>
<blockquote>Blockquote: Maecenas arcu justo, malesuada eu, dapibus ac, adipiscing vitae, turpis. Fusce mollis. Aliquam egestas. In purus dolor, facilisis at, fermentum nec, moestie et, metus. Maecenas arcu justo, malesuada eu, dapibus ac, adipiscing vitae, turpis. Fusce mollis. liquam egestas. In purus dolor, facilisis at, fermentum nec, molestie et, metus.</blockquote>
<address>Address: Vestibulum feugiat, orci at imperdiet tincidunt, mauris erat facilisis urna, sagittis ultricies dui nisl et lectus. Sed lacinia, lectus vitae dictum sodales, elit ipsum ultrices orci, non euismod arcu diam non metus </address>
';
//==============================================================
//==============================================================
//==============================================================
include("../mpdf.php");
$mpdf=new mPDF('c');
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetWatermarkText('DRAFT');
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->showWatermarkText = true;
$mpdf->WriteHTML($html);
$mpdf->AddPage();
$mpdf->SetWatermarkImage('tiger.wmf', 1, '', array(160,10));
$mpdf->showWatermarkImage = true;$mpdf->WriteHTML('<h2>Using a Watermark as a Header</h2>');
$mpdf->WriteHTML($html);
$mpdf->AddPage();
$mpdf->SetWatermarkImage('tiger.wmf', 0.15, 'F');
$mpdf->WriteHTML('<h2>Using a Watermark Image as Background</h2>');
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
//==============================================================
//==============================================================
//==============================================================
?>

这篇关于使用MPDF的PDF页面周围的边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 06:13