定制 mugo/mugo-wkhtmltopdf 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mugo/mugo-wkhtmltopdf

Composer 安装命令:

composer require mugo/mugo-wkhtmltopdf

包简介

eZ Publish Legacy extension which integrates the phpwkhtmltopdf library into eZ Publish to provide the basis for a solution for generating PDFs using eZ Publish templates and content stored within eZ Publish

README 文档

README

Mugo wkhtmltopdf is an eZ Publish Legacy extension which integrates the phpwkhtmltopdf library into eZ Publish to provide the basis for a solution for generating PDFs using eZ Publish templates and content stored within eZ Publish.

Composer Installation

  1. Install the package through composer:
composer require mugo/mugo-wkhtmltopdf dev-master;
  1. Activate the extension for all siteaccesses using settings/override/site.ini.append.php by manually adding the extension name 'mugo_wkhtmltopdf' to [ExtensionSettings] ActiveExtensions[] settings array. Here is an example:
[ExtensionSettings]
ActiveExtensions[]
ActiveExtensions[]=mugo_wkhtmltopdf
  1. Regenerate the autoloads array using php command: php ./bin/php/ezpgenerateautoloads.php;

  2. Clear all caches using php command: php ./bin/php/ezcache.php --clear-all;

Manual Installation

  1. Extract the contents under the extension/ directory of your eZ Publish installation

  2. Activate the extension for all siteaccesses using settings/override/site.ini.append.php by manually adding the extension name 'mugo_wkhtmltopdf' to [ExtensionSettings] ActiveExtensions[] settings array. Here is an example:

[ExtensionSettings]
ActiveExtensions[]
ActiveExtensions[]=mugo_wkhtmltopdf
  1. Regenerate the autoloads array using php command: php ./bin/php/ezpgenerateautoloads.php;

  2. Clear all caches using php command: php ./bin/php/ezcache.php --clear-all;

Testing Installation

You can test it by accessing http://siteURL/wkhtmltopdf/node/2

Note: The extension uses the SiteURL in site.ini setting to generate the pdf, please make sure it is correct pointing to the current host url.

Installing wkhtmltopdf on CentOS

yum install fontconfig libXrender libXext xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi freetype libpng zlib libjpeg-turbo openssl;
wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-centos6-amd64.rpm;
rpm -ivh wkhtmltox-0.12.2.1_linux-centos6-amd64.rpm;
ln -s /usr/local/bin/wkhtmltopdf /usr/bin/;

If SELinux is running, this must be enabled or wkhtmltopdf will segfault:

setsebool -P httpd_execmem 1;

Install this file at /etc/fonts/conf.d/10-wkhtmltopdf.conf to improve text quality

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<!-- Improve kerning and spacing for wkhtmltopdf as per https://github.com/wkhtmltopdf/wkhtmltopdf/issues/45#issuecomment-53485578 -->
<fontconfig>
 <match target="font">
  <edit mode="assign" name="rgba">
   <const>rgb</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hinting">
   <bool>true</bool>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hintstyle">
   <const>hintslight</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="antialias">
   <bool>true</bool>
  </edit>
 </match>
  <match target="font">
    <edit mode="assign" name="lcdfilter">
      <const>lcddefault</const>
    </edit>
  </match>
</fontconfig>

Optional Image Quality Settings

We need to use high resolutions images, we can also improve the image quality by changing the transparent to a solid color.

Change the image settings in a settings override file: image.ini.append.php

[ImageMagick]
...
Filters[]=background=-background %1
Filters[]=flatten=-flatten
...
[sample_pdf_image]
Filters[]
Filters[]=background=#eee
Filters[]=flatten

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 11
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2015-05-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固