GithubHelp home page GithubHelp logo

fkrauthan / wp-mpdf Goto Github PK

View Code? Open in Web Editor NEW
55.0 7.0 23.0 39.42 MB

Print WordPress posts as PDF. Optional with Geshi highlighting.

PHP 81.39% CSS 11.83% Shell 6.78%
wordpress-plugin mpdf wp-mpdf pdf-support php

wp-mpdf's People

Contributors

conlaccento avatar fkrauthan avatar grandeljay avatar nickgreen avatar nopticon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

wp-mpdf's Issues

how to hide

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.

Getting the Post image

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

Warning: Attempt to read property "login" on null

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

Usage with output buffering

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?

How to add custom font to PDF?

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?

Category url dosen't work after changing it at wp settings

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

PHP Fatal error after update

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)

Header & footer html problem

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,

PHP 8.0 compatibility issues

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 Warnings when I trying to use ul/ol lists in my custom wp-mpdf-theme template

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

Can not disable "needs login" with PHP 8

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.

format_to_post deprecated

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

Update mpdf

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.

PHP Fatal error - reference to files that don't exist

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

Function 'mpdf_create_admin_menu' not found

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

How to make the left content bigger in footer?

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.

image

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,

	),
);

Flex is not working for header

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?

issue with images

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.