Dear support,
i used this great plugin for years but recently i switched to a WordPress FSE block theme.
Is it possible to create or get a shortcode to embed “mpdf_pdfbutton();” within a WordPress block or shortcode block so i can use the plugin with the WordPress Website-Editor?
Unfortunately i’m not a good coder…
Thanks so much
André
]]>Hello!
I recently updated to the 8.3.1 version of the plugin from 3.7.1, and I started getting a fatal error when attempting to export PDFs from this plugin. The basic error is the following:
Fatal error: Uncaught Error: Interface “Psr\Log\LoggerAwareInterface” not found in “…/wp-content/plugins/wp-mpdf/vendor/mpdf/mpdf/src/Mpdf.php:29”
Mpdf.php:29 is the following line:
class Mpdf implements \Psr\Log\LoggerAwareInterface {
This line is trying to call LoggerAwareInterface.php inside /vendor/psr/log/Psr/Log. This path and file are present in the 7.3.1 version, but seemed to have been removed somewhere along the line. The newest version goes to /vendor/psr/log, and then stops. While fixing this error on my end was pretty simple – replacing the missing directories and files – it’s all subject to rewriting with future updates. I’m not sure if this change was intentional or not, but I figured it was worth mentioning, since the plugin itself is calling to something that has been moved or isn’t there at all.
]]>Just wanted to ask how someone can add custom template.
]]>I confirmed that English displays correctly without any problems. However, in Japanese, the characters appear as “???”.
I tried creating a custom theme and specifying the font in CSS after adding it to the server, but it did not work.
Is it possible to enable Japanese output?
Hello Florian,
After a year and a half without any problems with wp-mpdf, the ouput give an error.
An single custom post example : https://www.paysan-breton.fr/annonces-legales/l023511/
Technically:
– No cache activation,
– Personalized custom template with ACF fields
– Debug is enabled but does not generate HTML or I don’t know where to look !
Do you have any idea where this could come from?
]]>I’m trying to format my template. I’ve tried what seems to be the correct init (below), but it doesn’t work. Does your plugin work differently?
Thanks
<?php
global $post;
// Initialize mPDF with zero margins
$mpdf = new \Mpdf\Mpdf([
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
'margin_header' => 0,
'margin_footer' => 0
]);
// Fetch ACF fields
$acf_property_types = get_field('acf_property_types');
$acf_location = get_field('acf_location');
$acf_email = get_field('acf_email');
$acf_phone = get_field('acf_phone');
$acf_fax = get_field('acf_fax');
$acf_qrcode = get_field('acf_qrcode');
$acf_qrcode_url = $acf_qrcode ? $acf_qrcode['url'] : '';
// Convert featured image URL from https to http
$featured_image_url = get_the_post_thumbnail_url($post, 'full');
$featured_image_url = str_replace('https://', 'https://', $featured_image_url);
// Build the HTML output
$pdf_output = '<!DOCTYPE html>
<html xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>' . get_the_title() . '</title>
</head>
<body xml:lang="en">
<div class="featured-image" style="background-image: url(\'' . $featured_image_url . '\');">
<h1 class="title">' . get_the_title() . '</h1>';
if ($acf_property_types) {
$pdf_output .= '<ul class="property-types">';
foreach ($acf_property_types as $type) {
$pdf_output .= '<li>' . esc_html($type) . '</li>';
}
$pdf_output .= '</ul>';
}
if ($acf_location) {
$pdf_output .= '<p class="location"><img src="path/to/map-icon.jpg" alt="Location Icon" />' . esc_html($acf_location) . '</p>';
}
if ($acf_email) {
$pdf_output .= '<p class="email"><img src="path/to/email-icon.jpg" alt="Email Icon" />' . esc_html($acf_email) . '</p>';
}
if ($acf_phone) {
$pdf_output .= '<p class="phone"><img src="path/to/phone-icon.jpg" alt="Phone Icon" />' . esc_html($acf_phone) . '</p>';
}
if ($acf_fax) {
$pdf_output .= '<p class="fax">' . esc_html($acf_fax) . '</p>';
}
if ($acf_qrcode_url) {
$pdf_output .= '<img class="qrcode" src="' . esc_url($acf_qrcode_url) . '" alt="QR Code" />';
}
$pdf_output .= '<div class="content">' . apply_filters('the_content', get_post_field('post_content', $post->ID)) . '</div>';
$pdf_output .= '</div>
<footer class="footer">
<img class="logo" src="path/to/logo.jpg" alt="Company Logo" />
</footer>
</body>
</html>';
// Write the HTML to the PDF and output it
$mpdf->WriteHTML($pdf_output);
$mpdf->Output();
?>
]]>
Hi, on the website micromed.ua we have the same problem with broken images as this topic https://www.ads-software.com/support/topic/images-broken-and-duplicated/
For example:
images inside PDF: images are not shown correctly – it has an error [X] icon.
We thought that plugin should be updated from 3.4. to version 3.7.1 but after that our website crashed. When updating, the plugin stops working altogether and causes a number of errors in the functionality of the site. So we need to back it up.
Does it any ways to fix that problem?
]]>Hello!
Can I use ACF fields? How to do it?
At least initially I don’t want buttons on my website, I want to find some sample code and documentation (still looking) and modify and test a sample I found:
//require dirname(__FILE__) . '/../../plugins/wp-mpdf/wp-mpdf.php';
$mpdf=new mPDF();
$mpdf->WriteHTML('<p>Hi ya Dennis from mPDF</p>');
$mpdf->Output();
exit;
Including “wp-mpdf.php” didn’t work.
]]>Hello!
Your plugin seems to be really lightweight and perfect option for me, but it looks like it has a bug with Cyrillic encoding. I was trying all available options, but PDF is still outputting with question marks on Cyrillic texts. UTF-8 should cover it all, but looks like it’s not working as intended.
Could you please review it and add support of Cyrillic characters? I can see other users were complaining about Greek chars too, so it’s a common issue for non-Latin letters.
Sharing the example of such generated PDF file.
Best regards,
]]>Hello,
The PDF file generates without problems. UTF-8 encoding. Unfortunately, instead of Polish characters, there is?. Any ideas what could be wrong?
Hi there
On pages translated with TranslatePress, the generation of PDFs doesn’t seem to work. I’ve just got a blank PDF. Does anyone else have the same problem?
]]>Hi,
In my template, I’m using a field containing a base64 encoded image for a custom post type. This template works well with your help
Now, I want the put a base64 image in the pdf and I’m trying a simplistic method in HTML like :
$base64_logo = get_field('logo_annonce');
if( $base64_logo ):
$pdf_output .= '<div class="annonce--logo">';
$pdf_output .= '<img src="data:image/png;base64,'. $base64_logo .' "/>';
$pdf_output .= '</div>';
endif;
Unfortnaly, it doesnt work.
Maybe, it isn’t possible with FPDF library.
Any idea.
Hello Florian,
Is it possible to copy plugin templates into a theme for PDF customizations to prevent my custom plugin template from being deleted on the next update ?
I hope I could override template in the theme.
Thanks for your answer.
]]>Thanks so much for creating this plugin, it looks very promising!
I got one issue though: is it possible to echo out content instead of concatenating it to $pdf_output? I created a template file with the following code which resulted in a blank pdf:
ob_start();
echo '<div>Generate your content</div>';
$html = ob_get_contents();
ob_end_clean();
Rewriting our scripts would lead to a lot of duplicate code, so being able to echo out content would be fantastic.
Thanks again and kind regards,
Georg
I would like to make it so that the blue title at the top of the pdf where the site name is printed and the author and date in English are hidden when the pdf is generated. How can I do this? What do I need to change?
]]>I have a custom wp-mpdf theme with the meta defintion
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
The previous versions of wp-mpdf has given me the umlauted ? and ? as well as the Esperanto diacritical letters (?, ?, ?, ?, ? and ?) as they are in utf-8. I now updated to WP 5.9.1 and wp-mpdf 3.7.1 and I get only the umlauted letters.
This is the same issue as Greek Characters Encoding Issue.
Addendum
I had to restore from back-up the whole site since generating PDFs is currently broken.
See
https://finnababilejo.fi/artikolo/juha_metsakallas/2022/03/joka-toista-haukkuu-itse-on/
and try to generate a PDF (button in at the end of the article).
]]>hello i have installed the plugin and would like to make it so that the file is downloaded without opening it from chrome. Is it possible to do this? With pdfjs I knew that all you had to do was pdf.save(‘test.pdf’); and it would be downloaded. Is there a way to do this with this plugin? thanks
]]>Hello, I need help with the encoding of greek characters. They appear as ????. I have set charset as UTF-8, I have also changed the font-family to Arial to be sure that there is not font problem but nothing works. In html preview the characters appear fine. Only in pdf format I have this problem.
How can I fix it?
Thank you.
]]>Hello. Great plugin, appreciate the development. I just installed today and followed the instructions and the defaults are working fine.
I read in the documentation that there should a link to “Settings” for this plugin in the WordPress plugin section. However, I am only seeing the “Deactivate” option. I was hoping to use the settings to disable the cache and set which template file to use.
Running plugin version: 3.7.1
on WordPress: 5.8.2
Thanks in advance!
]]>Hello!
I have customed the PDF creation, see for instance How to output a footnotes list by PHP?, so I have hesitated to update WP-MPDF in order to not to break my system.
Some time ago I discovered that my site suffers from the Error Message: Failed to load PDF document issue. User got this message but by pressing the reload button on the error message dialog, the PDF got loaded ok. Because the PDF creation worked, there was just a fuss with a misleading error message dialog, I did not put any effort to solve this, especially because if the PDF was cached there was no error.
I updated the WordPress to 5.8.2 a couple of days ago and I decided to take a look to this creation error. This time clicking on the reload button did not help, but reloading the page gave me the PDF!! I turned debug logging on in WordPress and reproduced the error dialog.
In wp-config.php
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
No errors were caught. However, the topic Automatically create pdf? gave me the idea. I disabled the debug logging again in order to not slow down my site but retained the setting to not to show errors to the users and actived the cron job to create the PDFs in the background in advance. Given the frequency of new articles creating one new PDF every hour is more than enough for my site.
Hope this helps anybody with the same issue.
]]>Do you know why the PDFs will create when I visit the page in Firefox or Safari, but not in Chrome? I have tried an incognito window and a regular window. Each time I get a black screen with a dialog popup that says “Error. Failed to load PDF document.” There’s a reload button, but that doesn’t do anything.
I have checked the WP debug log and see the following (this is just a excerpt — there are a ton of these errors, but they all say the same thing)
`[22-Sep-2021 23:37:22 UTC] PHP Deprecated: Array and string offset access syntax with curly braces is deprecated in /www/harmonclaytor_930/public/wp-content/plugins/wp-mpdf/mpdf/mpdf.php on line 2349
[23-Sep-2021 00:38:23 Europe/London] PHP Deprecated: Array and string offset access syntax with curly braces is deprecated in /www/harmonclaytor_930/public/wp-content/plugins/wp-mpdf/mpdf/classes/grad.php on line 955
[23-Sep-2021 00:38:23 Europe/London] PHP Deprecated: Array and string offset access syntax with curly braces is deprecated in /www/harmonclaytor_930/public/wp-content/plugins/wp-mpdf/mpdf/classes/otl.php on line 3113
[23-Sep-2021 00:38:23 Europe/London] PHP Warning: A non-numeric value encountered in /www/harmonclaytor_930/public/wp-content/plugins/wp-mpdf/mpdf/Tag.php on line 1889
[23-Sep-2021 00:38:23 Europe/London] PHP Warning: A non-numeric value encountered in /www/harmonclaytor_930/public/wp-content/plugins/wp-mpdf/mpdf/Tag.php on line 2006
[23-Sep-2021 00:38:23 Europe/London] PHP Warning: A non-numeric value encountered in /www/harmonclaytor_930/public/wp-content/plugins/wp-mpdf/mpdf/mpdf.php on line 6387
Hi, I’m needing a way to have a pdf created automatically when the page is displayed. Is that possible? I don’t want the user to have to click a button. I would like to save the pdf on my server and them email it to our staff. Let meknow if this is possible?
Thank you!
I get this error when I try to activate the plugin
]]>Any estimate of when this will be available for download again?
]]>Hi,
I don’t know if I am the only one, but when I fill in other text for the PDF Buttom text, in the WP MPDF settings, then this doesn’t change the text. The text is still the same as “PDF Button”. In fact I want not text at all. Only the PDF image as button is enough for me. So, when I let the custom text empty, the text is still “PDF Button”.
I will appreciated it when there will be maybe an update so this setting could work. Or if there will be someone who knows to change that in the source file, because I am not a PHP programmer (only a beginner).
Thanks in advance.
Good afternoon, is there a way to apply bootstrap to the generated pdf?
Thank you
With WP_DEBUG enabled I get this notice:
Deprecated: Array and string offset access syntax with curly braces is deprecated
If I understand correctly you have stopped development of this plugin. I might be interested to contribute to it and maybe take over development. Do you accept pull requests on the github repo?
]]>The title says it all.
]]>Hello,
I need your help in two things :
Remove the footer borders or at leat hide them with css. I created my own template but I don’t find how to remove them (Screenshot
2- Is it possible to add an option (metabox) to post edition mode where the admin can choose a theme for that page?
Please advise,
Thank you.
]]>