标签: mpdf

使用mPDF将PDF文件保存到目录

我有一个关于PDF文件的问题.我已编写代码以打开PDF,我设法在浏览器中输出上下文,但我也想将此PDF文件保存在目录中.

有谁知道我会怎么做?

如果您认为这对您有帮助,我可以发布代码.

萨金,提前谢谢你

php mpdf

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

使用mPDF和PHPmailer动态附加PDF

单击按钮时,我正在使用mPDF生成PDF.我正在寻找一种使用PHPmailer将PDF添加到附件的方法.这是我尝试过的:

$mpdf = new mPDF(); 
$mpdf->WriteHTML($output);
$emailAttachment = $mpdf->Output('filename.pdf','S');
$emailAttachment = chunk_split(base64_encode($emailAttachment));    

require_once('/inc/user_controller.php');
require_once('/inc/PHPMailer/class.phpmailer.php');
$user = new user();
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch

    $currentUserInfo = $user->userDetails($userId);

    try {
      $mail->AddAddress($currentUserInfo['emailAddress'], $currentUserInfo['firstName']);
      $mail->SetFrom('name@yourdomain.com', 'First Last');
      $mail->AddReplyTo('name@yourdomain.com', 'First Last');
      $mail->Subject = 'Your file is attached';
      $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create …
Run Code Online (Sandbox Code Playgroud)

php phpmailer mpdf

5
推荐指数
1
解决办法
7156
查看次数

使用dompdf将页面转换为PDF

我正在尝试使用dompdf将PHP页面转换为PDF,但我不确定最好的方法.我已经在页面上写了我希望它如何以标准HTML/PHP呈现,并希望它像这样显示,就像PDF一样:

期望的输出

我的PHP代码如下.我相信我需要将我的代码放入$html变量中以解析为dompdf,但我有点像一个PHP新手,所以会很感激一些帮助,知道实现这一目标的最佳方法是什么.显然,页面的样式都是从外部CSS文件引入的,所以我不确定这是不是一个问题?

<?php
    include("checklog.php"); 
    require_once("watchlist-controller.php");
    require_once("dompdf/dompdf_config.inc.php");
    $html = 
?>
<!DOCTYPE html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="shortcut icon" href="img/fav.ico">
        <link rel="apple-touch-icon" href="img/apple-touch-icon.png">
        <title>Screening - Your ticket to your movies - <?php echo $watchlist_name; ?></title>
        <meta name="description" content="Screening is a brand new take on the traditional movie database, fusing social networking and multimedia to provide a clear, concise experience allowing you to share your favourite movies, and discover new classics.">
        <meta name="keywords" content="Movies, Films, Screening, Discover, Watch, Share, …
Run Code Online (Sandbox Code Playgroud)

php pdf dompdf mpdf

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

表格在html中很好地显示,但在用mpdf生成的pdf中没有显示

我正在尝试使用mPDF在PHP中生成PDF.我的文档的一部分必须是这样的:http://cloudandfun.com/Capture.PNG

所以我写了HTML:

<table style = "width:100%">
<tr>
    <td>Appellation <br>(par ordre de préférence)</td>
    <td style = "border:0px;">
        <table style = "width:100%; border:0px;">
            <tr style = "border:0px;"><th style = "border:0px;">Abréviation (S’il y a lieu)</th></tr>
        </table>
        <table style = "width:100%;border:0px;">
            <tr style = " border:0px;">
                <td style = "width:33%;border-bottom:0px;border-left:0px;">Abréviation</td>
                <td style = "width:33%;border-bottom:0px;border-left:0px;">Facultative</td>
                <td style = "width:33%;border-bottom:0px;border-left:0px;border-right:0px;">Obligatoire</td>
            </tr>
        </table>
    </td>
</tr>
<tr>
    <td>1.</td>
    <td>
        <table style = "width:100%;border:0px;">
            <tr style = " border:0px;">
                <td style = "width:33%;border-bottom:0px;border-left:0px;border-top:0px;">--</td>
                <td style = …
Run Code Online (Sandbox Code Playgroud)

html php mpdf

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

mPDF - 不并排显示的内联块

我有一堆小表格格式化为内联块元素.在浏览器中,它们按预期并排显示,但是当使用mPDF输出它们时,它们会在每个表之后断开.无论我如何尝试格式化它们,它们总是在桌子后面打破.mPDF是否有窍门让元素并排堆叠?

我正在从页面中提取确切的HTML并通过AJAX发送它

以下是浏览器和pdf视图的示例.

HTML视图

PDF查看

我的mPDF生成器页面如下所示:

<?php
include("mpdf60/mpdf.php");

$html = $_POST['html'];

$mpdf=new mPDF('utf-8', 'A4');
$mpdf->SetDisplayMode('fullpage');

// LOAD a stylesheet
$stylesheet = file_get_contents('../../_css/main.css');
$mpdf->WriteHTML($stylesheet,1);    // The parameter 1 tells that this is css/style only and no body/html/text

$mpdf->WriteHTML($html);
$mpdf->Output('myPDF.pdf','D');

exit;
?>
Run Code Online (Sandbox Code Playgroud)

javascript css php mpdf

5
推荐指数
2
解决办法
5688
查看次数

MPDF div在表格内不起作用

我正在研究 mpdf,它是将 html 页面转换为 pdf 的一个很好的库,但是当我将块元素<div><p>放入表格单元格时,它的行为不像块元素,而是像内联元素。

代码:

 <td><div>Block Element</div></td>
Run Code Online (Sandbox Code Playgroud)

或者

 <td><p>Block Element</p></td>
Run Code Online (Sandbox Code Playgroud)

有没有办法让它成为块元素?

还是我应该使用其他库?

提前致谢。

html css php codeigniter mpdf

5
推荐指数
1
解决办法
6742
查看次数

Shopware阿拉伯语发票文本未连接

我使用Shopware创建阿拉伯语在线商店,问题是当商品正在创建pdf时,字母看起来没有连接,例如:

رقمالفاتورة

虽然它应该是

رقمالفاتورة

到目前为止,我尝试使用不同的网页安全字体在PdfCreation下的shopware支持体css,我发现字体更改但字母仍然没有连接.

在冲浪购物时,我发现它使用MPDF库将名为index.tpl(Markup)的文件转换为pdf,我试着指向谷歌字体并将其用于正文,但它没有加载字体

Shopware生成的Pdf样本(在PdfCreation Preview下)

css php pdf mpdf shopware

5
推荐指数
1
解决办法
181
查看次数

MPDF 复选框未显示在 PDF 中仅点

我使用 MPDF 将我的 html 表单输出为 PDF。但我的问题是,当它转换为 PDF 时,复选框的框形消失了,下面是我如何编码复选框的示例

<input type='checkbox' name='opening' value='referal' checked="checked"> Check 1
<input type='checkbox' name='opening' value='referal2' checked="checked"> Check 2
Run Code Online (Sandbox Code Playgroud)

这是转换前的 html 输出: 这是转换前的 html 输出:

这是 mpdf 输出: 这是 mpdf 输出:

如您所见,检查“?” 变成了点'.' 盒子形状消失了。我的代码有问题吗?或者 MPDF 是不可能的?

但让我补充一下,如果我使用单选按钮,一切都很好。但我需要的是复选框而不是单选按钮。单选按钮输出:单选按钮

这是我的完整代码 GeneratePDF.php

<?php

include('mpdf60/mpdf.php');


$html .=

 "  


<!DOCTYPE html>
<html>
<head>
    <title>Applicant Information Sheet</title>
    <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'>
    <link rel='stylesheet' type='text/css' href='style.css'>
</head>
<body>
<div class=' header-logos text-center'>
    <img src='headerimage/logo1.png' width='270' height='90' class=''>
    <img src='headerimage/logo2.png' width='170' height='130' class='' >
    <img …
Run Code Online (Sandbox Code Playgroud)

html php checkbox mpdf

5
推荐指数
1
解决办法
1388
查看次数

调用未定义的函数 Mpdf\mb_regex_encoding()

我想用 yii2 Mpdf 做一些报告,但是当我运行程序时,我收到了一个错误,如 Call to undefined function Mpdf\mb_regex_encoding() 请告诉我如何解决这个程序

这是我的控制器

public function actionRpt($id)
{   
    $content = $this->renderPartial('rpt', [
            'model' => $this->findModel($id),
        ]);

    // setup kartik\mpdf\Pdf component
    $pdf = new Pdf([
        // set to use core fonts only
        'mode' => Pdf::MODE_UTF8, 
        // A4 paper format
        'format' => Pdf::FORMAT_A4, 
        // portrait orientation
        'orientation' => Pdf::ORIENT_PORTRAIT, 
        // stream to browser inline
        'destination' => Pdf::DEST_BROWSER, 
        // your html content input
        'content' => $content,  
        // format content from your own css file if needed …
Run Code Online (Sandbox Code Playgroud)

php mpdf yii2-advanced-app

5
推荐指数
1
解决办法
6543
查看次数

mPDF将方形图像变成圆形

在mPDF中是否可以将图像做成圆圈?环顾四周,找不到明确的答案。

对我来说,这个图像显示得很好,除了它是一个正方形而且应该使它变成一个圆形。

的CSS

img{
    width: 150px;
    height: 150px;
    border-radius: 150px;
}
Run Code Online (Sandbox Code Playgroud)

的PHP

$inputPath = '../web_content/cool_cat.jpg';
<div class="profile_img">
    <img src="'.$inputPath.'"/>
</div>
Run Code Online (Sandbox Code Playgroud)

html css php mpdf

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