标签: mpdf

mPDF v8.0.4 - 在 PDF 文件上打印自定义字体

1\xc2\xb0这个问题应该很容易解决,但三天以来我一直在努力奋斗。

\n

2\xc2\xb0我只需要在 PDF Roboto-Regular 和 Roboto-thin 中使用两种字体。

\n

3\xc2\xb0我已经阅读了手册,但不幸的是我仍然做错了或者文件中缺少某些内容。
\n文档:https://mpdf.github.io/fonts-languages/font-names.html

\n

4\xc2\xb0我刚刚在 PD 文件上打印了Roboto-Regular ,但没有打印Roboto-Thin
\n非常非常感谢任何帮助!

\n

文件testmpdf.php

\n
// Load MPDF Loader\nrequire_once __DIR__ . \'/vendor/autoload.php\';\n\nuse Mpdf\\Mpdf;\n\n$mpdf = new Mpdf();\n$mpdf = new \\Mpdf\\Mpdf([\'tempDir\' => __DIR__ . \'/custom/temp/dir/path\']);\n\n$defaultConfig = (new \\Mpdf\\Config\\ConfigVariables())->getDefaults();\n$fontDirs = $defaultConfig[\'fontDir\'];\n\n$defaultFontConfig = (new \\Mpdf\\Config\\FontVariables())->getDefaults();\n$fontData = $defaultFontConfig[\'fontdata\'];\n\n$mpdf= new \\Mpdf\\Mpdf(\n[\'mode\' => \'utf-8\',\n\'format\' => \'A4\',\n\'margin_left\' => 0,\n\'margin_right\' => 0,\n\'margin_top\' => 0,\n\'margin_bottom\' => 0,\n\'margin_header\' => 0,\n\'margin_footer\' => 0,\n\'fontDir\' => array_merge($fontDirs, [\n        __DIR__ . \'/assets/css/fonts\',\n …
Run Code Online (Sandbox Code Playgroud)

php pdf wordpress mpdf woocommerce

4
推荐指数
1
解决办法
3574
查看次数

Mpdf\Mpdf LoggerAwareInterface 与 php 8.1.12 中的 Psr\Log 不兼容

尝试使用 mpdf 时出现以下错误:

Declaration of Mpdf\Mpdf::setLogger(Psr\Log\LoggerInterface $logger) 
must be compatible with Psr\Log\LoggerAwareInterface::setLogger(Psr\Log\LoggerInterface $logger): void 
Run Code Online (Sandbox Code Playgroud)

我能找到的关于该主题的最多信息是这个,但我找不到如何解决它。

有人提到使用分支php8-support,但我尝试了这个,但它也不起作用。

有人找到解决这个问题的方法吗?

我在 php 上8.1.12并使用"mpdf/mpdf": "v8.0.13"

php mpdf

4
推荐指数
1
解决办法
3750
查看次数

mPDF - 页脚 - 内容重叠页脚?

我们使用mpdf从html页面创建pdf.我们正在为第一页和最后一页之外的所有页面设置页脚.页脚都是一样的.问题是页面内容与页脚重叠.即,然后内容停在页脚上方并转到下一页,它一直到页面底部并重叠页脚.现在,在您保存分页符之前,pdf页面内容有点动态,长度将从几个段落变化到多个更改,因此不仅仅是放入分页符的情况.

有人这样做过吗?知道这个秘密吗?

谢谢

html pdf mpdf

3
推荐指数
1
解决办法
7341
查看次数

MPDF无输出(空白页)

我安装了MPDF实用程序,以便将HTML和CSS转换为PDF报告.到目前为止,事情一直很好,直到我尝试将某些页面转换为PDF,并且没有输出.

我必须提到我能够通过浏览器定期显示页面 - 只有在我尝试将其转换为PDF时才出现问题 - 然后我会收到空​​白页面.此外,没有编码问题(部分输出是用希伯来语写的,但我已经克服了这个障碍)

这是代码的一部分:

if($customer!=$tempCustomer)
{


    if($tempCustomer!="")
    {
    $html.=("</table>");
    $html.=("</BR>???".$sumTotal."</BR>");
    $html.=("</BR>??????".$sumPallets."</BR>");
    }
    $sumTotal=0; //RESET SUM OF EACH CUSTOMER
    $sumPallets=0; //RESET PALLETS COUNT
    $html.=("</div>");
    $html.=("<div class='subTable'>");
//  $html.=("????: ".$customerName."</br>");
    $sumTotal=0;
    $sumPallets=0;
    $tempCustomer=$customer;
        $html.=("<table border='3' 

<tr><td>????</td><td>?????</td><td>?????</td><td>????</td><td>???</td><td>????</td><td>????</td><td>????</td><td>????  

?????</td><td>????</td><td>??????</td></tr>");
    $html.=("<tr>");
    $html.=("<td>".$grower."</td>");
    $html.=("<td>".$date."</td>");
    $html.=("<td>".$form."</td>");
    $html.=("<td>".$item."</td>");
    $html.=("<td>".$type."</td>");
    $html.=("<td>".$size."</td>");
    $html.=("<td>".$quantity."</td>");
    $html.=("<td>".$weight."</td>");
    $html.=("<td>".$price."</td>");
    $html.=("<td>".$total."</td>");
    $html.=("<td>".$pallet."</td>");
    $html.=("</tr>");
    $sumTotal+=$total;
    $sumPallets+=$pallet;

}
else
{
    $html.=("<tr>");
    $html.=("<td>".$grower."</td>");
    $html.=("<td>".$date."</td>");
    $html.=("<td>".$form."</td>");
    $html.=("<td>".$item."</td>");
    $html.=("<td>".$type."</td>");
    $html.=("<td>".$size."</td>");
    $html.=("<td>".$quantity."</td>");
    $html.=("<td>".$weight."</td>");
    $html.=("<td>".$price."</td>");
    $html.=("<td>".$total."</td>");
    $html.=("<td>".$pallet."</td>");
    $html.=("</tr>");
    $sumTotal+=$total;
    $sumPallets+=$pallet;

}

/*
$html.=("<td>".$form."</td>");
$html.=("<td>".$form."</td>");
$html.=("<td>".$form."</td>");
$html.=("<td>".$form."</td>");
$html.=("<td>".$form."</td>");
$html.=("<td>".$form."</td>");
$html.=("<td>".$form."</td>"); …
Run Code Online (Sandbox Code Playgroud)

php mpdf

3
推荐指数
1
解决办法
1万
查看次数

mpdf上的span width和float不起作用

我正在使用mpdf库开发报告html.我的代码是:

..
<td style="width:400px">
<span style="float:left; width:60px;">Rp</span>
<span style="float:right; width:340px;">100</span>
</td>
..
Run Code Online (Sandbox Code Playgroud)

我希望它在左侧显示'Rp',在右侧显示'100',在浏览器中它显示我想要的完美结果,但是当生成为pdf时,它们都在左侧.并且跨度的宽度不正确.为什么这不起作用?

有人请帮帮我,谢谢.

html mpdf

3
推荐指数
1
解决办法
8090
查看次数

使用mpdf在php中以pdf格式插入图像

这里,下面是我使用mpdf将图像转换为pdf的代码.$ html contains upload/tulips.jpg 但是,当函数执行创建的pdf文件时,图像图标显示该位置upload/tulips.pdf.请告诉我为什么会这样,因为没有错误来临.

   private function ConvertImageToPdf($inputPath,$outputPath)
            { 
                $mpdf=new mPDF();
                $html='<img src='.$inputPath.'/>';
                $mpdf->WriteHTML($html);
                $mpdf->Output($outputPath.".pdf",'F');
                $mpdf->debug = true;

            }
Run Code Online (Sandbox Code Playgroud)

php pdf image file mpdf

3
推荐指数
1
解决办法
2万
查看次数

最后打印页面MPDF中的页脚

嗨我正在使用MPDF,但我不能在最后一页打印页脚,我打印2-7页这是我的页脚代码

$mpdf->SetHTMLFooter('
<div id="firmas">
<table width="100%"><tr>
<td><br><br><br><br><br><small><h3><font face=\'Arial\'>Recibí Conforme</font>
</h3><small>    </td><td><br><br><br><br><small><h3><font face=\'Arial    
\'>Vo.Bo</font>    
</h3><small></td><td><small><br><br><br><br><br><h3><font face=\'Arial\'>Entregue 
Conforme</font></h3><small></td>
</tr>
</table>
</div>
');
Run Code Online (Sandbox Code Playgroud)

我想在最后一页显示,而不是在每一页显示.

php mpdf

3
推荐指数
1
解决办法
4756
查看次数

mPDF为SetHTMLHeader设置高度

当使用SetHTMLHeader函数时,是否存在设置助听器高度的任何方法?

在第一页中,默认大小是正确的,但在下一页中,内容会覆盖标题的结尾部分.

此致,奥斯卡.

height mpdf

3
推荐指数
1
解决办法
1万
查看次数

MPDF无法在谷歌浏览器中工作,但在Firefox中可以正常工作

在使用mPDF创建PDF文档时再次陷入困境。我已完成以下代码,该代码在Firefox和Safari中可以正常运行,但在Google Chrome中无法正常运行。

require_once 'mpdf60/mpdf.php';
$mpdf=new mPDF('c','A4','','' , 0 , 0 , 0 , 0 , 0 , 0); 

$mpdf->SetDisplayMode('fullpage');

$mpdf->list_indent_first_level = 0; 
$stylesheet = file_get_contents('css/style.css');
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($test, 2);
$mpdf->Output();  
Run Code Online (Sandbox Code Playgroud)

谁能指导我解决此问题的方法?

php mpdf

3
推荐指数
1
解决办法
6147
查看次数

致命错误:switch语句在mpdf.php中只能包含一个default子句

我正在使用mPDF,它与localhost一起工作正常.我将项目上传到实时服务器,但它没有正确生成pdf.

<?php

// HTML ommited

$body = ob_get_clean();

include ("mpdf/mpdf.php");

$mpdf = new mPDF('+aCJK', 'A4', '', '', 0, 0, 0, 0, 0, 0);

$mpdf->WriteHTML($body);

$mpdf->Output('SaveToPDF.pdf', 'D');
Run Code Online (Sandbox Code Playgroud)

在顶部,我把错误显示代码.要查看错误出错,我有以下错误.

致命错误:Switch语句在第1432行的/customers/d/e/a/....URL..GO..HERE/mpdf.php中只能包含一个默认子句

我在我的Localhost和现场使用PHP版本5.6.31我正在使用one.com,在那里我可以切换到不同的PHP版本,我尝试了所有.即5.6,7.0,7.1,7.2 beta

我使用的是mPDF 5.7,它不是作曲家版本.我想在我的pdf中使用chines字符,并且在5.7中提供了很好的支持.这就是我选择旧版本的原因

php mpdf

3
推荐指数
1
解决办法
7926
查看次数

标签 统计

mpdf ×10

php ×7

pdf ×3

html ×2

file ×1

height ×1

image ×1

woocommerce ×1

wordpress ×1