Loading...
 
Skip to main content

History: mPDF

Source of version: 64

Copy to clipboard
            !  {icon name="file-pdf-o"} mPDF

!! Overview
{DIV(class="lead")}__mPDF__ is a PHP class which generates PDF files from UTF-8 encoded HTML. It is based on FPDF and HTML2FPDF, with a number of enhancements. __mPDF__ was written by Ian Back and is released under the GNU GPL v2 licence. 
__mPDF__ is manually installable in Tiki since Tiki15. Since ((Tiki18)) you can install __mPDF__ with the new __((Packages))__ feature from the Tiki admin panel in a few clicks.{DIV}

{REMARKSBOX(close=n type=tip title="PDF Output of Tiki content with 'mPDF'")}
((dev:Online Publishing House - Output formats|All Free / Libre / Open Source PDF generation solutions were analyzed)) and mPDF was selected as the overall best solution for deep integration in Tiki. The main reasons are:
# Vast feature set: The [https://github.com/IanNBack/mpdf/raw/master/mpdfmanual.pdf|mpdfmanual.pdf (8 megs download)] is over 600 pages!
# It's written in PHP (like Tiki) so it eases deployment, facilitates integration and makes it easier for the Tiki community to contribute.
# The approach is to convert HTML to PDF (other approaches would have been more complex / less suitable for the Tiki context)
# Strong multilingual support: Some of the other good solutions didn't support all languages. And thus, it would have forced us to have a second solution for these languages, which would have fragmented the efforts.

Since the GNU GPL v2 licence is not compatible with Tiki's LGPL licence, we cannot ship __mPDF__ with the source code as part of Tiki. Thus, we have prepared the mPDF integration from ((Tiki16)) in the code to an extent, that users can simply install mPDF in three simple steps and activate the feature with a prepared dropdown in the admin panel. mPDF is offered via ((Packages)) in ((Tiki18)).

See also:
* http://wikisuite.org/blogpost10-mPDF-7-0-0-Released
* http://wikisuite.org/blogpost5-Tiki17-makes-collaborative-digital-publishing-a-breeze
{REMARKSBOX}

{maketoc}

!! Installation
Please mind, that mPDF does not work in/behind an http-password protected directory; at least not with a simple standart installation without extra configuration.

{TABS(name="user_tabset_01" tabs="Tiki15 and Tiki16 or manual installation (for non-svn-Tikis)|Tiki17|Tiki18")}
__This is the Steps 1 and 2 by hand__

{BOX()}
-=Step 1=-

Download the mPDF library to your server, extract (unzip) to an appropriate place in or outside the Tikiroot (Tiki installation directory).

__References:__

||Download | [http://www.mpdf1.com/mpdf/index.php] %%%get the newest stable version or %%%[https://github.com/mpdf/mpdf/archive/development.zip] %%%try the newest developer version
Github | [https://github.com/mpdf/mpdf] %%%
Documentation | [https://mpdf.github.io/] %%%'mpdf Manual'
Manual as PDF | [http://www.mpdfonline.com/repos/mpdfmanual.pdf] %%%||

__Recommended places to install ''mPDF'':__

''either here inside the Tikiroot:''

A : {CODE()}files/mpdf{CODE}

''or here inside the Tikiroot:''

B : {CODE()}vendor_custom/mpdf{CODE}

''or outside the Tikiroot (recommended for security reason):''

C : {CODE()}
in a structure like this (recommended example):

a "container" for the project:
     /myproject 
a directory for the filegallery (do not use the database for file upload!):
     /myproject/files/*
the Tikiroot (main installation):
     /myproject/tiki16
and here the extracted mpdf directory:
     /myproject/mpdf
{CODE}
{BOX}
{BOX()}
-=Step 2=-

Make the following directories inside __mPDF__ writable (in worst case ''"#: chmod -R 777 path/to/directory"''):

this:
{CODE()}graph_cache{CODE}

and this:
{CODE()}tmp{CODE}

and this one aswell:
{CODE()}ttfontdata{CODE}
{BOX}

{BOX()}
-=alternative option: Steps 1 and 2 using composer in the command-line=-

{BOX()}__Required__: command line access, and composer package installed. You can install composer with commands like (afapt to your OS or linux distribution): 
{CODE(colors="shell")}
sudo apt-get install composer
{CODE}
{BOX}

Since mPDF is on https://composer.tiki.org/ , you can run this command from the tikiroot folder

{CODE(caption="")}composer require mpdf/mpdf --update-no-dev{CODE}

This will install mPDF in __vendor/mpdf/mpdf__ (which you need to set in the admin panel). It is vendor/mpdf/mpdf and not just vendor/mpdf/

{FADE(label="Alternative installation (without composer)" icon="y" bootstrap="y")}
Alternatively, you could use this longer instruction if you need for some reason (which would get the data as per specifications at https://packagist.org/packages/mpdf/mpdf ):

{CODE(caption="6.1.3 is latest stable version as of writing this")}php temp/composer.phar require mpdf/mpdf "6.1.3" --update-no-dev {CODE}

This will install mPDF in __vendor/mpdf/mpdf__ (which you need to set in the admin panel). It is vendor/mpdf/mpdf and not just vendor/mpdf/

You still need to set permissions as described above. This is [https://github.com/mpdf/mpdf/commit/69d1abdde39b5341c53c1498af4625f414f04625|supposed to be handled by Composer] but somehow is not as of writing this.
{FADE}

This will modify your composer.json file. If you are running from SVN, this modification will be maintained as you do "svn updated". But if you install via FTP (The zip archive of Tiki), you will need to run this command at each upgrade.
{BOX}

{BOX()}
-=Step 3=-

Enable __mPDF__ in Tiki:

Up to ((Tiki15|Tiki 15.x)) (and up to 16.1): 
* Go to Control Panel > General > General settings (tab) > PRINT > mPDF
+ ( example.com/tiki-admin.php?page=general#contentadmin_general-2 )
+ and select the path where you did install mPDF to. 
Since ((Tiki16|Tiki 16.2)): 
* Go to Control Panel > Print Settings > PDF > PDF from URL > mPDF
+ ( example.com/tiki-admin.php?page=print )
+ and select the path where you did install mPDF to. 

Path to be set in the input field (opens when PDF and mPDF is chosen):

Steps 1 and 2 by hand:
* A : {CODE()}files/mpdf{CODE}
* B : {CODE()}vendor_custom/mpdf{CODE}
* C : {CODE()}../mpdf{CODE}
Steps 1 and 2 by command line (composer)
* {CODE()}vendor/mpdf/mpdf{CODE}
{BOX}
/////
__Tiki 17__
mPDF in ((Tiki17)) is vastly improved compared to ((Tiki15)) and ((Tiki16)) (and it will be even better in ((Tiki18))).

See also: ((PluginPDF))

Known issue (solved in Tiki18): if you have text with __.tiki__, it will be truncated. So __doc.tiki.org__ will become __doc.org__

{BOX()}
__How to install and configure in Tiki 17 using the composer / command-line __

6.1.3 is latest stable version as of writing this
use this in the command-line in your tiki root (needs shell access to the server):

{CODE()}php temp/composer.phar require mpdf/mpdf 6.1{CODE}

Then login to your Tiki and got to yourtiki.com/tiki-admin.php?page=print and set  the following two preferences:

* PDF from URL: mPDF
* mPDF path: vendor/mpdf/mpdf
{BOX}

/////
__Tiki 18__
From Tiki18 you can install mPDF via the ((Composer Web Installer))

You can test this with the current Trunk version (pre-18)

See also: ((PluginPDF))

{TABS}

---

!! Configuration

Although __mPDF__ should work with Tiki out of the box even on average shared hosting, when you followed the above steps, you will have "only a basic configuration" at this point. There are tons of options that allow you to play with additional Fonts, creating paginated PDF documents, hiding the source URL etc., which you will find in the manual (see above references).

Main configuration of __mPDF__ is located in */mpdf/config.php plus a number of more specific config files in the same directory.


-=Related=-
__Collection of References on doc.tiki.org__

((PDF)) general overview about PDF creation in Tiki
((mPDF)) create PDFs from Tiki content (advanced library that works even on shared hosting)
((PluginPDF)) alter default settings of mPDF per wiki page
((PluginPDFPageBreak)) add a page break for PDFs created with mPDF
((wkhtmltopdf)) create PDFs from Tiki content (needs root installation)
((dompdf)) used for pdf print of slideshows
((PluginMediaPlayer)) display PDF file from file gallery
((PluginArchiveBuilder))
((Print))

%%%
        

History

Advanced
Information Version
Josue Zirimwabagabo 82
Josue Zirimwabagabo 81
Josue Zirimwabagabo 80
Marc Laporte Put URL higher on page 79
Torsten Fabricius 78
Torsten Fabricius 77
Philippe Cloutier Overview: more exact introduction (16->15.2) 76
Marc Laporte 75
Marc Laporte 74
Marc Laporte 73
Marc Laporte 72
Marc Laporte 71
Marc Laporte 70
Marc Laporte 69
Marc Laporte 68
Marc Laporte Now that things we done cleanly in 18.x, we don't need the manual (and confusing) documentation 67
Marc Laporte Tiki17 is no longer supported 66
Marc Laporte Tiki 17 is no longer supported. Interesting info moved to 18.x section 65
Marc Laporte Use Tiki18 64
Marc Laporte Just use Tiki18 63
Marc Laporte 62
Marc Laporte 61
Marc Laporte 60
Marc Laporte That domain expired 59
Torsten Fabricius 58
Torsten Fabricius 57
Torsten Fabricius 56
Torsten Fabricius 55
Torsten Fabricius 54
Torsten Fabricius 53
Torsten Fabricius added Related 52
Marc Laporte 51
Marc Laporte 50
Torsten Fabricius 49
Torsten Fabricius should be halfway nice and readable now (again) 48
Torsten Fabricius ty better using BOX inside TABS 47
Torsten Fabricius test format 46
Torsten Fabricius needed to change formattimg for that TABS and maketoc fit together 45
Torsten Fabricius allocated all installation hints to one place, using the TABS plugin 44
Marc Laporte 43
Torsten Fabricius demoted my just added headline by one level for the sake of consistency 42
Torsten Fabricius added Tiki version destiction on top of "Installation" ... maybe Tabs ... the mpf improvement with Tiki 17 makes a HUGE difference!! Thx guys!!! 41
Marc Laporte 40
Marc Laporte 39
Marc Laporte 38
Marc Laporte Distinct, simpler instructions for Tiki17 37
Marc Laporte Edit restored by rescue script 2017-04-24T18:09:12+00:00 36
Xavier de Pedro Edit restored by rescue script 2017-04-24T18:09:12+00:00 35
Xavier de Pedro Edit restored by rescue script 2017-04-24T18:09:12+00:00 34
Xavier de Pedro Edit restored by rescue script 2017-04-24T18:09:12+00:00 33
  • «
  • 1 (current)
  • 2