【问题标题】:Mpdf how to add dependency in a .module fileMpdf如何在.module文件中添加依赖项
【发布时间】:2018-02-26 10:55:08
【问题描述】:

Drupal 7

我正在尝试通过 mpdf 生成 Pdf 那么如何执行此事件以及如何添加依赖项 ..

我正在使用的代码

require_once __DIR__ 。 '/vendor/autoload.php'; //应该添加什么

$html = '
<h1><a name="top"></a>mPDF</h1>
<h2>Basic HTML Example</h2>
This file demonstrates most of the HTML elements.

<h5>Heading 5</h5>
<h6>Heading 6</h6>
';

$mpdf=new Mpdf;
$mpdf->WriteHTML($html);
$mpdf->Output();

这是我得到的错误

【问题讨论】:

    标签: php drupal mpdf


    【解决方案1】:

    您需要在您的 Drupal 站点上添加 mPDF 库

    首先,您从以下 URL (http://www.mpdf1.com/mpdf/index.php) 下载了 mPDF 包 他们将文件夹解压缩到 /sites/all/libraries 路径

    注意:不需要添加代码来包含mPDF的自动加载文件,它会默认从库文件夹中添加

    此外,您会发现 Drupal 的 mPDF 模块,在这里您将有更多的选择来减少您的时间

    模块路径:https://www.drupal.org/project/pdf_using_mpdf

    【讨论】:

    • 现在我得到了这个code
      致命错误:require_once(): Failed opening required '/opt/lampp/htdocs/drupal7/sites/all/ /opt/lampp/htdocs/drupal7/sites/all/modules/poc3/poc3.module 中的 modules/poc3/vendor/autoload.php' (include_path='.:/opt/lampp/lib/php') 上线124
      code
    • 您是否下载并添加库到 /sites/all/libraries/ 路径?如果您已添加库,则无需添加 require_once DIR 。 '/供应商/autoload.php';在你的模块文件中
    • 我已经像这样添加了 require_once DIR 。 '/libraries/mpdf/mpdf.php';
    猜你喜欢
    • 1970-01-01
    • 2013-03-09
    • 2012-04-18
    • 2016-04-05
    • 2017-05-17
    • 2020-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多