fkrauthan / wp-mpdf Goto Github PK
View Code? Open in Web Editor NEWPrint WordPress posts as PDF. Optional with Geshi highlighting.
Print WordPress posts as PDF. Optional with Geshi highlighting.
Hello, i try your plugin. It is the only standalone that i found.
I have a probleme, i have au bar on top on all page. I don't understand how hide pdf bar when i 'm not on White List page.
Good afternoon,
I have been trying to get the post's thumbnail using the the_post_thumbnail();
function and using it in the deafult.php template.
I hasn't worked for me could you help me ?
Thank you
Getting a Warning on line 356 of wp-mpdf/wp-mpdf.php
Attempt to read property "login" on null
} else if ( ( get_option( 'mpdf_need_login' ) == 2 && $dsatz->login == false || get_option( 'mpdf_need_login' ) == 3 && $dsatz->login == true ) && is_user_logged_in() != true ) {
Hi,
I'm trying to do the most straightforward thing I can think of, which is simply output the entire page, as it would in HTML, to PDF.
In trying to achieve this, in wp-content/wp-mpdf-themes/default.php
, I'm simply doing a require()
of my template for this page type:
<?php
ob_start();
require_once(dirname(__FILE__).'/../themes/mytheme/single-posttype.php');
ob_flush();
However, something is still breaking wp-mpdf:
mPDF error: Some data has already been output to browser, can't send PDF file
The page is then displayed, in HTML, exactly as it's supposed to, but not as PDF.
What would be the right way to do this? Can I somehow return the output buffer to wp-mpdf as string?
Hello,
I'm currently working on a project and using this WordPress plugin. It works perfectly fine and I'm able to generate PDF with selected theme which is basically PHP code that includes HTML and CSS. I want to change the font family to custom one like:
body {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
font-family: "EuclidCircularB Regular";
}
but it does not work. The font is installed and added correctly. Is there any way to add this custom font to PDF?
My PDF generation code looks like this:
if (have_posts()) :
while (have_posts()) : the_post();
$relative_url = untrailingslashit(ABSPATH) . wp_make_link_relative(get_the_post_thumbnail_url());
$pdf_output .= pdf_header();
$pdf_output .= pdf_images($relative_url);
// $pdf_output .= pdf_additional_images();
$pdf_output .= pdf_description(the_title('', '', false), $post);
$pdf_output .= pdf_header_next();
$blocks = parse_blocks($post->post_content);
$specifications = '';
foreach ($blocks as $block) {
if ('acf/metratec-specifications' === $block['blockName']) {
$specifications .= render_block($block);
}
}
$pdf_output .= pdf_specifications($specifications);
$similar = '';
foreach ($blocks as $block) {
if ('acf/metratec-related-products' === $block['blockName']) {
$similar .= render_block($block);
}
}
$pdf_output .= pdf_similar($similar);
$pdf_output .= pdf_ending();
endwhile;
Functions are basically returning HTML content as a string. Is there any way to specify the specific font?
If you change the category url at the wordpress settings the url printed in the pdf is wrong. It is an issue in the templates:
/mpdf/themes/default.php:144
// FIX! URL-Pfad zu Kategorien fehlt
$cat_links .= '<a href="' . get_bloginfo('home') . '/category/' . $cat->category_nicename . '" title="' . $cat->category_description . '">' . $cat->cat_name . '</a>, ';
Reported by another user
Hello!
I was wondering if you have a reason of why was removed from WP plugin directory?
https://wordpress.org/plugins/wp-mpdf/
What kind of issue the plugin has?
Thank you!
PHP Fatal error: Uncaught Error: Class 'Mpdf\Mpdf' not found in /domen/wp-content/plugins/wp-mpdf/wp-mpdf.php:195
It looks like some files were not included in bundle after the update.
(PHP - 7.4, WP - 5.8.2, template - default)
Hi in wp-mpdf.php line 226 :
if ( $pdf_html_header ) { $mpdf->SetHTMLHeader( $pdf_header ); } else { $mpdf->setHeader( $pdf_header ); } if ( $pdf_html_footer ) { $mpdf->SetHTMLFooter( $pdf_footer ); } else { $mpdf->setFooter( $pdf_footer ); }
You use $pdf_header and $pdf_footer in the 2 states of the condition. So $pdf_html_header and $pdf_html_footer are never used.
Thanks for this plugin :)
Regards,
Hello there,
I've created a custom post type with a bunch of custom fields and have used a jQuery gauge which i need to output in the pdf.
Here is the frontend screenshot of the Cpt:
http://i.imgur.com/ACear68.png
and here is the pdf output:
http://i.imgur.com/gthyUuc.png
I want to make the pdf same as in frontend
Good day sir.
I was just checking to see if all is well with PHP 8.0. I'm getting the following error whenever I update to PHP 8.1. and I can't quite seem to point out the issue. I understand you are one busy man, maybe share with us your to-do list and we will assist.
Error:
Fatal error: Uncaught Mpdf\MpdfException: Data has already been sent to output (/usr/www/users/mintopfwbf/wp-content/themes/jobboard_v2/admin/framework/autoload.php at line 162), unable to output PDF file in /usr/www/users/mintopfwbf/wp-content/plugins/wp-mpdf/vendor/mpdf/mpdf/src/Mpdf.php:9549 Stack trace: #0 /usr/www/users/mintopfwbf/wp-content/plugins/wp-mpdf/wp-mpdf.php(293): Mpdf\Mpdf->Output('manthako.pdf', 'I') #1 /usr/www/users/mintopfwbf/wp-content/plugins/wp-mpdf/wp-mpdf.php(504): mpdf_output(' apply_filters(NULL, Array) #4 /usr/www/users/mintopfwbf/wp-includes/plugin.php(476): WP_Hook->do_action(Array) #5 /usr/www/users/mintopfwbf/wp-includes/template-loader.php(13): do_action('template_redire...') #6 /usr/www/users/mintopfwbf/wp-blog-header.php(19): require_once('/usr/www/users/...') #7 /usr/www/users/mintopfwbf/index.php(17): require('/usr/www/users/...') #8 {main} thrown in /usr/www/users/mintopfwbf/wp-content/plugins/wp-mpdf/vendor/mpdf/mpdf/src/Mpdf.php on line 9549
PHP Warning: count(): Parameter must be an array or an object that implements Countable in /domen/wp-content/plugins/wp-mpdf/mpdf/classes/ttfontsuni.php on line 613
Pls fix
I see a huge number of Warnings in error_log file when I use ul
or ol
lists in my template layout. Without lists, everything is fine.
[09-Dec-2021 09:24:20 UTC] PHP Warning: A non-numeric value encountered in /domen/wp-content/plugins/wp-mpdf/mpdf/Tag.php on line 1889
[09-Dec-2021 09:27:11 UTC] PHP Warning: A non-numeric value encountered in /domen/wp-content/plugins/wp-mpdf/mpdf/Tag.php on line 2003
[09-Dec-2021 09:24:20 UTC] PHP Warning: A non-numeric value encountered in /domen/wp-content/plugins/wp-mpdf/mpdf/Tag.php on line 2006
[09-Dec-2021 09:27:11 UTC] PHP Warning: A non-numeric value encountered in /domen/wp-content/plugins/wp-mpdf/mpdf/mpdf.php on line 6387
Hey,
if I try to disable the checkbox "needs login" in the admin panel, it re-enables itself when I click "save". So, effectively, I can not turn it off. Sometimes, it stays unchecked but after re-loading the page, it is enabled again.
I did not see an error in the logs.
It just happens with PHP 8, with php 7.4 it works fine.
And thanks so much for updating mpdf! It will also be OK for me to use 7.4 for now, just wanted to raise this.
The file wp-mpdf.php uses a deprecated hook to sanitize the_content. Somewhere around line 264, it calls format_to_post('the_content');
FYI, format_to_post has been deprecated since WP 3.9, and hasn't been in use for a long time before that, so it wasn't really doing anything anyway.
My suggestion is to either get rid of that or replace it with wpdb::prepare()
Hey,
I just added it to one of the pages I manage and it worked great, thanks a lot!
When I pushed it to production, I got server errors and the PDF did not render:
PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in [...]/wp-content/plugins/wp-mpdf/mpdf/mpdf.php on line 2349
I got this because I use PHP 8. I am now using 7.3 to circumvent this.
I assume this would be fixed if mpdf would be updated, because the currently used version of mpdf (6.1) is pretty old.
I don't know how actively maintained this is and if it's too much to ask. I would look into it myself, but I am currently very short in time and also I don't have very deep php knowledge. I looked into it briefly, but not very deeply but I would love to be able to use a newer PHP version again.
Hi,
The current version of wp-mpdf throws this error when trying to generate pdf files:
PHP Fatal error: require_once() [function.require]: Failed opening required '/xxxxxxxxxx/wp-content/plugins/wp-mpdf/mpdf/mpdfi/pdf_context.php' (include_path='.:/usr/share/php:/usr/share/pear') in /xxxxxxxxxx/wp-content/plugins/wp-mpdf/mpdf/mpdf.php on line 32335
For some reason I can't seem to find wp-mpdf/mpdf/mpdfi/pdf_context.php on my system
After updating the plugin to Version 3.2.1 I have the following warning:
call_user_func_array() expects parameter 1 to be a valid callback, function 'mpdf_create_admin_menu' not found or invalid function name in /www/.../wp-includes/plugin.php on line 525
I just discovered your plugin but it was coincidentally removed from the WP Directory today. Any idea what is up and when it will be available again?
I'm generating PDF with this library, it works quite good, but I have a problem with footer. It generates content, but left one is not as I want.
In the attached image, I actually put the address for the German one like this:
'L' =>
array(
'content' => '<table class="footer" style="width: 600px !important; margin-left: 4px;">
<tr>
<td style="width: 100%;">
<div class="left">
<p>Metratec GmbH</p>
<p>Niels-Bohr-Str. 5 | 39106 Magdeburg, Germany</p>
<p>T: +49 (0)391 251906-00 | F: +49 (0)391 251906-01</p>
<p>Mail: [email protected] | www.metratec.com</p>
<br>
<p>' . $currentDate . ' | ' . $currentHour . '</p>
</div>
</td>
</tr>
</table>',
'font-size' => 8,
'font-style' => 'BI',
'font-family' => 'EuclidCircularB Regular',
),
but it moves the city/country name part into the next line. Is it possible to make this part of the footer longer, so it will have no break in my p
tags?
My full footer code is like following:
$pdf_footer = array(
'odd' =>
array(
'R' =>
array(
'content' => '<img src="https://dev-itoito.io/img/metratec/logo.jpg" alt="logo" style="width: 200px;float:right;" />',
'font-size' => 8,
'font-style' => 'BI',
'font-family' => 'EuclidCircularB Regular',
),
'L' =>
array(
'content' => '<table class="footer" style="width: 600px !important; margin-left: 4px;">
<tr>
<td style="width: 100%;">
<div class="left">
<p>Metratec GmbH</p>
<p>Niels-Bohr-Str. 5 | 39106 Magdeburg, Germany</p>
<p>T: +49 (0)391 251906-00 | F: +49 (0)391 251906-01</p>
<p>Mail: [email protected] | www.metratec.com</p>
<br>
<p>' . $currentDate . ' | ' . $currentHour . '</p>
</div>
</td>
</tr>
</table>',
'font-size' => 8,
'font-style' => 'BI',
'font-family' => 'EuclidCircularB Regular',
),
'C' =>
array(
'content' => '<table class="footer">
<tr>
<td style="width: 100%;">
<div class="left">
<p>US Office </p>
<p>Metratec USA</p>
<p>6 Liberty Square #2073 02109 Boston, MA, United States</p>
<p>T: +1 (857) 799-3795 | Mail: [email protected] </p>
<br>
<p>' . $currentDate . ' | ' . $currentHour . '</p>
</div>
</td>
</tr>
</table>',
'font-size' => 8,
'font-style' => 'BI',
'font-family' => 'EuclidCircularB Regular',
),
'line' => 1,
'line' => 1,
),
);
I am currently working on a template for a pdf of a post on Wordpress and I am pretty sure that my css works ( I've built the html/css on a different file) but when implementing it on the header, the FLEX is not working any idea on how to solve it?
Hi,
I have noticed that the plugin does not seem to handle images well that have a src set that doesn't contain the website URL.
Example:https://www.corelan.be/index.php/2009/07/19/exploit-writing-tutorial-part-1-stack-based-overflows/
The first image (under "Verify the bug") is created as:
<img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/wp-content/uploads/2009/07/image_thumb4.png" width="407" height="172" scale="0">
(the "src" does not contain the website URL)
The resulting PDF file shows these images as "missing"
thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.