Print WordPress posts as PDF. Optional with Geshi highlighting. It also has support for password protected posts and only logged in users can print post as pdf support.

Note: You can find the development repository at Github: https://github.com/fkrauthan/wp-mpdf


This file is part of wp-mpdf.

wp-mpdf is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

wp-mpdf is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with wp-mpdf. If not, see http://www.gnu.org/licenses/.


  1. Upload the whole plugin folder to your /wp-content/plugins/ folder.
  2. Set write permission (777) to the plugin dir folder => /wp-content/plugins/wp-mpdf/cache
  3. Go to the plugins page and activate the plugin.
  4. Add to your template “<?php if(function_exists(‘mpdf_pdfbutton’)) mpdf_pdfbutton(); ?>” as a small button or “<?php if(function_exists(‘mpdf_pdfbutton’)) mpdf_pdfbutton(false, ‘my link’, ‘my login text’); ?>” as a textlink. The second text specifies the text which should displayed if you have checked “needs login” and a user isn’t logged in.
    (if you wish to open the pdf print in a new tab you may pass “true” for the first parameter)
  5. You can adjust some options: in your admin interface, click on plugins and then on wp-mpdf. For allowing or disabling pdf export you can use the checkbox when creating/editing a post or a page.
  6. Place your templates into /wp-content/wp-mpdf-themes

The mpdf_pdfbutton function signature: function mpdf_pdfbutton($opennewtab=false, $buttontext = '', $logintext = 'Login!', $print_button = true, $nofollow = false, $options = array())

The options array supports ‘pdf_lock_image’ => ‘/my/image/path/relative/to/wordpress/route’ and ‘pdf_image’ => ‘/my/image/path/relative/to/wordpress/route’ to overwrite which icon should be used.


January 16, 2020
Independent of any platform : works perfectly with wordpress 5.3.2! It is extremely useful for a wordpress scientific publication website CSS customization is a bit difficult but the results superb (with footnotes, references, custom post type...)
September 30, 2019
Great plugin, it just *works*! After some trial and error I made it also to use my own template by pulling data from a BuddyPress user and display it as a contact info sheet. Thanks!
May 2, 2019
I wanted to provide a way for my visitors to download posts as PDFs and began to google for solutions. First of all it seems, that "post to PDF" can be understood in a couple of ways. I wanted to have it a simple way: on a post page a button, that opens a new window with the PDF to be saved or shared. I found a couple of plugins, that didn't work in my environment, server error 500. I found some with annual fees. Well, I don't mind paying for services per se, but this is a gratis site, and so far donations aren't flowing in. Then I found one with an output, that ,eh, leaves a lot to desire, until I found this. To tell the truth it took me a while to figure out how to get the button on a post. And I like to my some minor formatting on the PDF, but overall effect is wow! Nice PDF, as if I had myself manually done 🙂
September 3, 2016
Thanks for this great plugin. Really appreciate that you offer your free time to write a plugin like this.
February 7, 2017
Hello Friends I need your help urgent... I have downloaded this plugin and try to generate the PDF IN LOCALHOST... But is shows me the blank page/pdf... please suggest me what's wrong with this ... I need to submit this pdf project by tonight and i need your help ... Here is the code of my page wp-mpdf.php (WHOLE PAGE CODE)( I M USING THIS PLUGUN IS LOCALHOST) [ moderator note - code removed. use a pastebin if you need to include large amounts of code ]
Read all 13 reviews

Contributors & Developers

“wp-mpdf” is open source software. The following people have contributed to this plugin.


Translate “wp-mpdf” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.



  • Made codebase PHP 7.3 compatible (thanks to nopticon)
  • Fixed issues with newer wordpress versions (thanks to nopticon)


  • Fixed some small bugs
  • Updated mpdf to version 6
  • Updated geshi to latest version
  • Made plugin compatible with PHP 7


  • Fixed admin menu call


  • Fixed options menu with recent WordPress versions (thanks to NickGreen)
  • Removed a call to a deprecated method


  • Added option to replace the pdf button images
  • Fixed a bug where 0 for pdf margin was interpreted as no value set


  • Added removed font folder (again…)


  • Added missing files
  • Fixed a php warning (thanks to Menelao)
  • Fixed a temp folder issue (thanks to shortster)


  • Fixed cache dir guessing


  • Added nofollow option to the pdf download buttons (default: not enabled)
  • If cache folder within the plugin folder is not writable check for cache folder within the mpdf template folder


  • Added missing font folder
  • Updated mpdf lib to version 3.7.1


  • Fixed some issues with wordpress 3.7
  • Changed template loading (templates loaded from the custom template folder. If it can’t find a template there it tries to load it from the plugin template folder.)
  • Updated mpdf lib to version 5.7
  • Moved all tmp directories to one folder (plugin_direcotry/tmp. Don’t forget to give write permission for this folder)
  • Removed not needed files and directories for the mpdf lib


  • Removed some deprecated calls (thanks to Permarad)
  • Fixed some php warnings (thanks to Jason Judge)
  • Fixed the readme
  • Added the possibility to translate the ui (at the moment frontend only)


  • Added some hooks and actions to the plugin (thanks to Danny)


  • Updating mpdf lib to version 5.6.1


  • Fixed category link in the templates


  • Fixed pdf link id to class (thanks to ZilverDragOn)


  • Fixed project homepage link again


  • Fixed project homepage link


  • Disable printing of password protected posts without entering passwort first


  • Add french language templates (thanks to Patrick)


  • Add template option to enable HTML in Header and Footer


  • Updateing mpdf lib to version 5.3
  • Add a small fix for image paths. Thanks to Mário Kašuba.


  • Disable wrong anotations in PDFs (thanks to misenko)
  • Fix image printing for multi instance wordpress setups (thanks to stephen7cohen)


  • Fix version number


  • Add a debug option (You must create a folder called debug in the wp-mpdf root folder)


  • Set the tmp path for mpdf
  • Add codepage selection to the admin menu


  • Update the german template translation (Thank you for your help Andreas)
  • Updateing mpdf lib to version 4.6
  • Fix formating for the default english template


  • Fix a small image bug


  • Updating mpdf lib
  • Add option to select a user for cron generating of pdfs for cache


  • Now the content filter would be added to the pdf file. So all content plugins should work at pdf print now.
  • Remove some broaken wp-mpdf filters


  • There goes somthing worng. This version should work correct again.


  • Fix a copy and paste bug


  • Fix relativ links


  • Fix a encoding problem (Thanks to swwwolf)
  • Add geshi line number print as a option


  • Now the bug is completly fixed 🙂


  • The bug is at the moment not fixed.


  • Spaces and Tabs are now correct at pre tags. (Thanks to mark for his help)


  • Now to add new Posts to the black-/white-list, you only must select it from a dropdown


  • Added the option to add a text if you have checked “need login” and a user isn’t logged in
  • Added an option to set “need login” per post
  • Added an option to set an own pdf name
  • Added an optional download statistic
  • Now removing cache file and database entry when a post/page is deleted


  • Fixed a new image print bug


  • Added the option to allow pdf print only to users who are logged in
  • Added a script that you can call by cron to create templates in the background (if you have caching enabled)


  • Added a missing file


  • Fixed two small include bugs
  • Fixed a php4 issiue


  • Some small bugfixes
  • PDF Template support (now you can also use a pdf file as a template): If you need this please write me a mail so I can tell you how it works.


  • Added two vars to the templates for using PDF Templates


  • Added option to make a black list instead of a white list
  • Added button to clear all selected posts on the black/white list


  • Fixed the pdf button function e.g. when using this function on the archive page


  • Fixed a small pre html tag problem


  • Fixed an image printing bug
  • Cleaned some code parts which aren’t needed
  • Changed PDF author and creator string
  • Moved the theme dir from the plugin dir to wp-content/wp-mpdf-themes
  • Now you can access the plugin config under settings and not any longer under plugins


  • Fixed an encoding problem again


  • Added function parameter for pdfbutton to link to a new page for PDF Print
  • Added function to display only for some Posts and Pages the PDF print


  • Fixed a <pre> problem with newlines


  • Fixed an encoding problem
  • Converted <pre> to <div class=”pre”> to prevent a pdf print bug


  • Created an admin panel


  • Released the Plugin