Skip to content

Commit

Permalink
Fixed code style, added extension.xml and added README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagocamposviana committed Apr 7, 2015
1 parent b2e845c commit cd9b961
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 61 deletions.
76 changes: 76 additions & 0 deletions README.md
@@ -0,0 +1,76 @@
Mugo wkhtmltopdf
================

Installation
------------

1) Extract the contents under the extension/ directory of your
eZ Publish installation and activate it for all siteaccesses.
2) Regenerate the autoloads array

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

Note:

The extension in the SiteURL site.ini setting to generate the pdf.

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://downloads.sourceforge.net/project/wkhtmltopdf/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>


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

image.ini.append.php


[ImageMagick]
...
Filters[]=background=-background %1
Filters[]=flatten=-flatten
...
[sample_pdf_image]
Filters[]
Filters[]=background=#eee
Filters[]=flatten
108 changes: 56 additions & 52 deletions doc/INSTALL.txt
@@ -1,56 +1,62 @@
* Installation
Mugo wkhtmltopdf
================

1) Extract the contents under the extension/ directory of your
eZ Publish installation and activate it for all siteaccesses.
2) Regenerate the autoloads array
Installation
------------

1) Extract the contents under the extension/ directory of your
eZ Publish installation and activate it for all siteaccesses.
2) Regenerate the autoloads array

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

Note:

The extension in the SiteURL site.ini setting to generate the pdf.
The extension in the SiteURL site.ini setting to generate the pdf.

* Installing wkhtmltopdf on CentOS
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://downloads.sourceforge.net/project/wkhtmltopdf/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/
yum install fontconfig libXrender libXext xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi freetype libpng zlib libjpeg-turbo openssl
wget http://downloads.sourceforge.net/project/wkhtmltopdf/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
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>

<?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>


-
Expand All @@ -59,14 +65,12 @@ We need to use high resolutions images, we can also improve the quality by chang
image.ini.append.php


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


[ImageMagick]
...
Filters[]=background=-background %1
Filters[]=flatten=-flatten
...
[sample_pdf_image]
Filters[]
Filters[]=background=#eee
Filters[]=flatten
12 changes: 12 additions & 0 deletions extension.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<software>
<metadata>
<name>&lt;a href="http://www.mugo.ca"&gt;Mugo wkhtmltopdf&lt;/a&gt;</name>
<version>1.0</version>
<copyright>Copyright (C) 2013 &lt;a href="http://www.mugo.ca"&gt;Mugo Web&lt;/a&gt;</copyright>
<license>GNU General Public License v2.0</license>
<software/>

This comment has been minimized.

Copy link
@brookinsconsulting

brookinsconsulting May 9, 2015

Contributor

We think it would be better if you documented that the dependent library you are including within this extension is MIT licensed. eZJsCore provides a solid example of how to do this, https://github.com/ezsystems/ezpublish-legacy/blob/master/extension/ezjscore/extension.xml#L10

</metadata>

<dependencies/>
</software>
10 changes: 6 additions & 4 deletions modules/wkhtmltopdf/module.php
Expand Up @@ -3,11 +3,13 @@

$ViewList = array();

$ViewList[ 'node' ] = array( 'script' => 'node.php',
'params' => array( 'node_id' ),
'functions' => array( 'node' ) );
$ViewList['node'] = array(
'script' => 'node.php'
, 'params' => array( 'node_id' )
, 'functions' => array( 'node' )
);

$FunctionList = array();
$FunctionList[ 'node' ] = array();
$FunctionList['node'] = array();

?>
13 changes: 8 additions & 5 deletions modules/wkhtmltopdf/node.php
Expand Up @@ -3,7 +3,6 @@
use mikehaertl\wkhtmlto\Pdf;

$node = false;
$object = false;

if ( isset( $Params['node_id'] ) )
{
Expand All @@ -15,15 +14,19 @@
$url = $siteINI->variable( 'SiteSettings', 'SiteURL' ) . '/content/view/full/' . $Params['node_id'];
$pdf = new Pdf();
$pdf->addPage( $url );
$pdf->send( $node->attribute('name') . '.pdf');
$pdf->send( $node->attribute('name') . '.pdf' );
eZExecution::cleanExit();
}
else
{
$Result = array();
$Result['path'] = array(array('url' => false,
'text' => 'Module not found'));
$Result['content'] = $tpl->fetch("design:error/kernel/20.tpl");
$Result['path'] = array(
array(
'url' => false
,'text' => 'Module not found'
)
);
$Result['content'] = $tpl->fetch( "design:error/kernel/20.tpl" );
}

?>

0 comments on commit cd9b961

Please sign in to comment.