Support » Plugin: wp-mpdf » No PDF generated

  • Resolved Jason Judge


    I’ve added the PDF link to my custom page template, and set it up as a whitelist page.

    When I click the link, a new tab options for the URL + output=pdf. This then redirects back to the HTML page, but no PDF is generated.

    All three cache directories are empty, apart from the .htaccess and dummy.txt files that come installed. The cache folders are writeable.

    Where should I be looking to find out what could be going wrong? Debugging is on, but I don’t know where that is logged. The settings screen does not have any values in the “thema” dropdown, in case that is important.

Viewing 13 replies - 1 through 13 (of 13 total)
  • For a start, line 368 of wp-mpdf/wp-mpdf.php contains this:

    if($_GET['output'] == 'pdf') {

    It generates warnings, as it assumes the “output” element exists. This would be better:

    if(isset($_GET['output']) && $_GET['output'] === 'pdf') {

    If I use this in my page template, and am logged in (or not logged in), but have the “requires logged in” box unchecked:

    mpdf_pdfbutton('my link', 'my login text');

    the text this is displayed on the link is “my login text”. According to the documentation, it should display “my link”, if I understand correctly.

    If I don’t supply that function with *both* strings (even though I’m not interested in limiting access to logged in users) then no link appears at all. Of course, it could be a link with no text, but I haven’t checked that.

    If I do check the “requires login” box, then neither string supplied to that function is displayed. Instead it shows the link to the login page with the text “Login!”. So, I realise the “not logged in text is actually the third parameter, and the second parameter is the “download PDF” string. The first parameter is a mystery.

    Plugin Author fkrauthan


    Your last problem with mpdf_pdfbutton: The documentation was wrong. You need to specify the following mpdf_pdfbutton(false, 'my link', 'my login text');. The first parameter defines if the link should be open in the same tab (false) or in a new tab (true).

    Line 368 is fixed with the next version (2.12.0) which should be out within the next 24 hours.

    Your main issue sounds like a different installed plugin is blocking the access to the pdf links.

    I have the “404 Redirected” plugin installed. Disabling that has turned the redirect into a white screen. It’s a step forward…

    This is the error behind the white screen:

    Warning: require(/var/www/vhosts/[redacted]/httpdocs/dev-folder/wp-content/plugins/wp-mpdf/../../wp-mpdf-themes/.php): failed to open stream: No such file or directory in /var/www/vhosts/[redacted]/httpdocs/dev-folder/wp-content/plugins/wp-mpdf/wp-mpdf.php on line 426 
    Fatal error: require(): Failed opening required '/var/www/vhosts/[redacted]/httpdocs/dev-folder/wp-content/plugins/wp-mpdf/../../wp-mpdf-themes/.php' (include_path='.:') in /var/www/vhosts/[redacted]/httpdocs/dev-folder/wp-content/plugins/wp-mpdf/wp-mpdf.php on line 426

    This is line 425, and it does seem to be related to the fact that the setting page does not show any themes in the drop-down list. Have I missed something in the installation instructions? Do I need to install a theme:


    I copied the contents of wp-content/plugins/wp-mpdf/themes/ to wp-content/wp-mpdf-themes/

    This has given me the the ability to select “default” as a theme in the settings page. The installation instructions says something about some theme files, which is guess is what this is about, but it was not very clear at all. I only found out about this by looking at the code.

    It is now telling me that the cache directories are not writeable (I am only seeing this with debug turned on, otherwise I would be totally in the dark). Now, I *did* set the cache folders to be writeable, but installing the last update has reset those folders.

    Two things I would suggest may help:

    1. Error reporting. Tell the user (or admin) that something is wrong when a folder cannot be written to, rather than just dump them into a while screen.
    2. Why no set the folder permissions during the install and upgrade process? If permissions cannot be set, then give the admin the instructions on what folders to change permissions on. There are three (or perhaps four) folders that need changing, so make it easy for the admin rather than having to go on a bug hunt and digging through documentation *every* time the plugin gets updated.

    It looks a great plugin, and it is much appreciated, and I’m just playing devil’s advocate here – I would rather tell you what I think is wrong, and what would probably make a lot of other people give up long ago. Obviously take it or leave it, but all comments meant with the best intentions.

    Setting the write permissions, and I get a PDF document. Wooo 🙂

    I’m displaying a custom page template – a price list that pulls products in from a custom post type, then groups them into major groups and tabulates the results into several tables.

    I guess I will need to put my custom template into the theme and make that selectable. This will have to wait until tomorrow though, as I need to work on other projects today. In the meantime, this is a good start.

    Feel free to close this issue once you decide if there are any actions for you to follow up.

    Another suggestion:

    If a wp-content/wp-mpdf-themes/ folder has not been created with any theme files in, then the plugin should perhaps fall back to the plugin internal theme folder. This would get it up and working out of the box a lot faster, and people can create their own theme files once they are ready to customise it.

    In my standard WP theme, my page uses a custom page template “template-prices.php”. So I somehow need to create a wp-mpdf version of that template then link it in to the wp-mpdf theme. I’m guessing I would alter default.php to look at the selected page template, and if it exists, include it? Or maybe there is another way?

    Plugin Author fkrauthan


    I’ve created a new method for loading templates. First it looks up the custom user template directory (outside of the plugin folder so it doesn’t get deleted on plugin update). If it can’t find the template there it looks into the plugins own template folder. So there is no need any more to copy the default templates. I plan to publish a new version soon with some more bug fixes.

    I need your help… I have a same problem… 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)

    Plugin Author fkrauthan


    Is it possible that you have modified the plugin? I can’t support customized plugins. But you should take a look into your php log and webserver log maybe you can find there what the problem is.

    Moderator Jan Dembowski


    Brute Squad and Volunteer Moderator

    @harshida09? Per the forum welcome can you please post your own topic?

    Also please do not post that large amount of PHP code again. Use if you must.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘No PDF generated’ is closed to new replies.