我希望你能帮助我解决这个问题,我第一次使用mPDF,我觉得这很棒,但是我希望用与我的网站相同类型的字体显示报告,在其文档中解释如何要做到这一点,但它似乎仍然不适合我.我到现在所做的是:
<link
href='http://fonts.googleapis.com/css?family=Open+Sans'
rel='stylesheet' type='text/css'>.然后我添加了一个样式表文件,其中包含<link rel="stylesheet" href="<?php echo base_url();
?>assets/publicidad/css/reporte.css" type="text/css">
我已经添加的字体Inside reporte.css 的使用
,我有一个使用'Open Sans'字体的定义
body {font-family:'Open Sans',Sans-Serif; }按预期显示字体.
之后,我按照这个清晰的文档http://mpdf1.com/manual/index.php?tid=453,但到目前为止我没有得到我的PDF文档中显示的所需字体,直到现在我还没有做到"4.要使用特定语言的字体,你还需要编辑配置文件(config_cp.php);让我们想象Frutiger包含泰语所需的全套字符:",但我不要认为这是问题,因为我使用的是我放下的默认配置.
function pdf_create($html, $filename, $stream = TRUE) {
require_once(APPPATH . 'helpers/mpdf/mpdf.php');
$mpdf = new mPDF();
$mpdf->SetAutoFont();
$mpdf->WriteHTML($html);
if ($stream)
{
$mpdf->Output($filename . '.pdf', 'D');
}
else
{
$mpdf->Output('./uploads/temp/' . $filename . '.pdf', 'F');
return './uploads/temp/' . $filename . '.pdf';
}
}
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我这样做.
$html = $this->load->view('publicidad/reporte_x_curso', …Run Code Online (Sandbox Code Playgroud) 我正在动态生成具有未知页数的PDF.mPDF运行良好,但第二页的上边距已经消失.如何设置包含文档的所有页面的边距?
我尝试了以下,但它没有效果:
$mpdf = new mPDF('', '', 0, '', 15, 15, 15, 15, 8, 8);
Run Code Online (Sandbox Code Playgroud) 我正在使用mPDF库将报告(以html格式)转换为pdf,但是将所有页面都放在一起.我想在确定之后添加一个分页符,但我还没有成功.
HTML
<div class='text my_form' style='margin:0px 0 0 0; padding:0px 0 0 0; border-style:dotted; border-color:white;'>
Run Code Online (Sandbox Code Playgroud)
我将这个传递给PHP为$ html
PHP
require_once ("./libraries/MPDF57/mpdf.php");
$mpdf=new mPDF("", "Letter", "", "", 10, 10);
Run Code Online (Sandbox Code Playgroud)
我想在找到上面显示的div之后添加分页符
preg_match_all("/((\<div\s)(class='text\smy_form'[\s\w\s]*border-color:white)(.+?)(\>)/", $html, $matches, PREG_SET_ORDER);
foreach($matches as $value) {
$html= $mpdf->AddPage();
}
$mpdf->WriteHTML($html);
$filename = "documentx.pdf";
$mpdf->Output($fileName, 'F');
Run Code Online (Sandbox Code Playgroud)
但是,不工作,请帮我通过正确的轨道:)
有人可以告诉我为什么mPDF不接受此代码以避免我的div中的分页
<div style="page-break-inside:avoid !important;">
multi
line
content
</div>
Run Code Online (Sandbox Code Playgroud) 我在body标签上创建了一个PDF(使用php库mPDF)和全尺寸背景图像:
body {
background: url("..path/to/bg.jpg") center no-repeat;
background-size: cover;
background-image-resize: 6;
background-image-resolution: 300dpi;
}
Run Code Online (Sandbox Code Playgroud)
它在chromes,IE和acrobats pdf viewer中看起来很好,但在FF中可怕:

知道如何为Firefox处理这个问题吗?我使用CSS,使用宽度和高度,不同的分辨率,嵌入为.svg,但没有成功.
我正在使用报价软件,我使用mpdf使用HTML格式生成报价.标题由以下代码设置.
$mpdf->SetHTMLHeader($header);
$mpdf=>SetHTMLFooter($footer);
Run Code Online (Sandbox Code Playgroud)
这适用于所有页面.但我需要不同的标题到第一页.我应该如何实现它?
我正在尝试使用mpdf将我的html页面转换为pdf格式.问题是我无法将多个CSS应用于pdf文件..这是我的php代码
<?php
$html =file_get_contents('mpdf/test.html');
include("../mpdf.php");
$mpdf=new mPDF();
$mpdf->SetDisplayMode('fullpage','two');
// LOAD a stylesheet 1
$stylesheet = file_get_contents('assets/css/main.css');
$mpdf->WriteHTML($stylesheet,1); // The parameter 1 tells that this is css/style only and no body/html/text
// LOAD a stylesheet 2
$stylesheetextra = file_get_contents('assets/css/test.css');
$mpdf->WriteHTML($stylesheetextra ,1); // The parameter 1 tells that this is css/style only and no body/html/text
$mpdf->WriteHTML($html,2);
$mpdf->Output();
exit;
?>
Run Code Online (Sandbox Code Playgroud)
它给出的输出没有test.css.main.css正确应用于pdf文件,但test.css没有应用.请帮助我吗?提前感谢你
我试图集中在详细目录描述的位置.
我希望页面仅从A1-G1中心,然后我合并并集中详细产品目录.问题在于,当我输出到PDF时,它仍然在页面左侧,并且右侧有大量的空白区域.
<?php
include_once 'processor/dbconfig.php';
include_once 'Classes/PHPExcel.php';
/**
* PHPExcel
*
* Copyright (C) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* …Run Code Online (Sandbox Code Playgroud) 我正在使用 mPDF 将表单输入数据保存为 PDF。对于英语,它工作正常。任何人都可以使用此代码将 HTML 表单数据保存为 PDF。
问题:为了满足我的项目要求,我需要使用中文。我当前的代码对此不起作用。
表单.html
<form action='processPDF.php' method='post'>
<label for="name">Name</label>
<input name="name" type="text" id="name">
<input type='submit' name='submit' value='Download PDF'>
</form>
Run Code Online (Sandbox Code Playgroud)
进程PDF.php
<?php
header('Content-Type: text/html; charset=UTF-8');
if (isset($_POST['submit'])) {
if (isset($_POST['name'])) {
$name = $_POST['name'];
} else {
$Larmtid = '';
}
if (!isset($error)) {
ob_start();
?>
<div style="padding:20px;">
<p>Name: <?php
echo $name;
?></p>
</div>
<?php
$body = ob_get_clean();
$body = iconv('UTF-8', 'UTF-8//IGNORE', $body);
$body = iconv('UTF-8', 'UTF-8//TRANSLIT', $body);
include("mpdf/mpdf.php");
$mpdf = new \mPDF('c', 'A4', '', '', …Run Code Online (Sandbox Code Playgroud)