Loading...
 

 PDF Output of Tiki content with 'mPDF'


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.

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:
  1. Vast feature set: The mpdfmanual.pdf is over 600 pages!
  2. It’s written in PHP (like Tiki) so it eases deployment, facilitates integration and makes it easier for the Tiki community to contribute.
  3. The approach is to convert HTML to PDF (other approaches would have been more complex / less suitable for the Tiki context)
  4. Strong multi-lingual 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. work is ongoing to make this easier.




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.


This is the Steps 1 and 2 by hand


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 :
files/mpdf


or here inside the Tikiroot:

B :
vendor_custom/mpdf


or outside the Tikiroot (recommended for security reason):

C :
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



Step 2

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

this:
graph_cache


and this:
tmp


and this one aswell:
ttfontdata




alternative option: Steps 1 and 2 using composer in the command-line

Required: command line access, and composer package installed. You can install composer with commands like (afapt to your OS or linux distribution):
sudo apt-get install composer



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

composer require mpdf/mpdf --update-no-dev


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/

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 ):

6.1.3 is latest stable version as of writing this
php temp/composer.phar require mpdf/mpdf "6.1.3" --update-no-dev


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 supposed to be handled by Composer but somehow is not as of writing this.


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.



Step 3

Enable mPDF in Tiki:

Up to 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 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 :
    files/mpdf
  • B :
    vendor_custom/mpdf
  • C :
    ../mpdf
Steps 1 and 2 by command line (composer)
  • vendor/mpdf/mpdf


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


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):

php temp/composer.phar require mpdf/mpdf 6.1


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



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







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.

CSS

This is for Tiki 15, and no longer needed in Tiki 17.

There are some CSS rules in an array in config.php (starting around line 330) for simple modifications of the documents’ appearance, if no separate CSS file is used. Follow the pattern of the rules already present. CSS shorthand is not supported. For example, to add lines between table rows, change this:

'TD' => array(
		'PADDING-LEFT' => '0.1em',
		'PADDING-RIGHT' => '0.1em',
		'PADDING-TOP' => '0.2em',
		'PADDING-BOTTOM' => '0.2em',
	),

to this:
'TD' => array(
		'PADDING-LEFT' => '0.1em',
		'PADDING-RIGHT' => '0.1em',
		'PADDING-TOP' => '0.2em',
		'PADDING-BOTTOM' => '0.2em',
		'BORDER-BOTTOM-COLOR' => 'gray',
		'BORDER-BOTTOM-STYLE' => 'solid',
		'BORDER-BOTTOM-WIDTH' => '1px',
	),


See also

pdf






Experiments in overriding default output of mPDF

Reference: https://mpdf.github.io/paging/different-page-sizes.html

A4 Landscape on all pages

This is for Tiki 15, and no longer needed in Tiki 17, as we now can use PluginPDF
Put this in Custom CSS in tiki-admin.php?page=look
@page {
    sheet-size: A4-L;
}


A4 Landscape for just one page

This is for Tiki 15, and no longer needed in Tiki 17, as we now can use PluginPDF
Put this in the page, and approve it
{HTML()}
<style type="text/css">
@page {
    sheet-size: A4-L;
}
</style>
{HTML}




doc.tiki.org


Bootstrap

AdminGuide

UserGuide

Keywords

Keywords serve as “hubs” for navigation within the Tiki documentation. They correspond to development keywords (bug reports and feature requests):

Accessibility (WAI and 508)
Accounting (7.x)
Articles and Submissions
Backlinks
Banners
Batch (6.x)
BigBlueButton audio/video/chat/screensharing (5.x)
Blog
Bookmark
Browser Compatibility
Link Cache
Calendar
Category
Chat
Clean URLs
Comments
Communication Center
Compression (gzip)
Contacts (Address Book)
Contact us
Content Templates
Contribution (2.x)
Cookie
Copyright
Credit (6.x)
Custom Home and Group Home Page
Date and Time
Debugger Console
Directory of hyperlinks
Documentation link from Tiki to doc.tiki.org (Help System)
Docs 8.x
Draw 7.x
Dynamic Content
Dynamic Variable
External Authentication
FAQ
Featured links
File Gallery
Forum
Friendship Network (Community)
Gmap Google maps
Groups
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
Kaltura video management (4.x)
Karma
Live Support
Login
Logs (system & action)
Look and Feel
Lost edit protection
Mail-in
Map with Mapserver
Menu
Meta Tags
Mobile Tiki and Voice Tiki
Mods
Module
MultiTiki
MyTiki
Newsletter
Notepad
Payment
Performance Speed / Load
Permissions
Platform independence (Linux-Apache, Windows/IIS, Mac, BSD)
Polls
Profiles
Profile Manager
Report
Toolbar
Quiz
Rating
Feeds
Score
Search engine optimization
Search
Search and Replace
Security
Semantic links (3.x)
Shadowbox
Shadow Layers
Share
Shopping cart
Shoutbox
Slideshow
Smiley
Social Networks
Spam protection (Anti-bot CATPCHA)
Spellcheck
Spreadsheet
Stats
Surveys
Tags (2.x)
Task
Tell a Friend, alert + Social Bookmarking
TikiTests (2.x)
Theme CSS & Smarty
Trackers
Transitions (5.x)
TRIM
User Administration including registration and banning
User Files
User Menu
Watch
WebHelp
WebDAV (5.x)
Webmail
Web Services
Wiki 3D
Wiki History, page rename, etc
Wiki Page Staging and Approval (2.x)
Wiki Plugin extends basic syntax
Wiki Syntax
Wiki structure (book and table of content)
Workspace
WSOD
WYSIWYCA
WYSIWYG (2.x)
XMLRPC


Tiki Newsletter

Delivered fresh to your email inbox!
Newsletter subscribe icon
Don't miss major announcements and other news!
Contribute to Tiki
Show php error messages