BCcampus / pressbooks-mpdf

[UNMAINTAINED] open source HTML to PDF conversion
GNU General Public License v2.0
7 stars 7 forks source link

mPDF not working #16

Closed pbstudent closed 7 years ago

pbstudent commented 7 years ago

PB 3.9.6 / PBT 3.0.1 / mPDF 1.0.1 Clicking on mPDF in Export initiates a white screen with title of book in upper left-hand side of webpage. No emailed errors. No mPDF output.

This issue also occurs with other themes than PBT.

bdolor commented 7 years ago

I cannot reproduce this. What does the error log tell you?

markkindred commented 7 years ago

I recently encountered, and then overcame, this exact issue. Details to follow in next post.

bdolor commented 7 years ago

thanks Mark, looking forward to getting more detail.

markkindred commented 7 years ago

For one text book, the export process began fine, then failed part way through. Just as pbstudent reported, the white screen appeared with the book's title by itself at the top. The PHP logs showed the following error getting recorded:

PHP Fatal error: Maximum execution time of 600 seconds exceeded in wp-content/plugins/pressbooks-mpdf/symbionts/mpdf/mpdf.php on line 10750

And here’s the corresponding line of code from mpdf.php, lines 10747-10755:

10747          // extract alpha channel
10748          for ($ypx = 0; $ypx < $h; ++$ypx) {
10749             for ($xpx = 0; $xpx < $w; ++$xpx) {
10750                $alpha = (imagecolorat($im, $xpx, $ypx) & 0x7F000000) >> 24;
10751                if ($alpha < 127) {
10752                   imagesetpixel($imgalpha, $xpx, $ypx, (255-($alpha * 2)));
10753                }
10754             }
10755          }

Time after time, the php-errors.log file continued to show the “maximum execution time of 600 seconds exceeded” when I had already updated relevant config settings to revise with higher values for timeouts.

php.ini

max_execution_time = 2000

wp-config.php

set_time_limit(2000);

.htaccess

<IfModule mod_php5.c>
 php_value max_execution_time 2000
</IfModule>

So, the number “600” didn’t correlate.

The fix turned out to be set_time_limit( ) instances explicitly set in the following files:

mpdf/utils/font_coverage.php line 19 mpdf/utils/font_dump.php line 27 pressbooks/includes/modules/export/mpdf/class-pb-pdf.php line 110*

*the mPDF export failed to complete until the timeout was increased on this last php file.

If it helps, here is the diagnostic info straight out of PressBooks:

### System Information

#### Book Info

Book ID: 3
Book URL: http://library.open.oregonstate.edu/computationalbiology/
Book Privacy: Public

#### Browser

Platform: Apple
Browser Name: Firefox
Browser Version: 51.0
User Agent String: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:51.0) Gecko/20100101 Firefox/51.0

#### WordPress Configuration

Network URL: http://library.open.oregonstate.edu/
Network Type: Subdirectory
Version: 4.7.1
Language: en_US
WP_ENV: Not set
WP_DEBUG: Disabled
Memory Limit: 64M

#### Pressbooks Configuration

Version: 3.9.6
Book Theme: Pressbooks Custom CSS
Book Theme Version: 0.1
Root Theme: Pressbooks Publisher
Root Theme Version: 3.0.1

#### Pressbooks Dependencies

Epubcheck: Not Installed
Kindlegen: Installed
xmllint: Installed
PrinceXML: Not Installed
Saxon-HE: Not Installed

#### Must-Use Plugins

#### Network Active Plugins

CM Tooltip Glossary: 3.4.4
Pressbooks: 3.9.6
Pressbooks mPDF: 1.0.1
Pressbooks Textbook: 3.0.1
SSH SFTP Updater Support: 0.7.1
Table of Contents Plus: 1601
WP Broken Link Status Checker: 1.0.4
WP QuickLaTeX: 3.8.4

#### Book Active Plugins

#### Inactive Plugins

Akismet: 3.2

#### Server Configuration

PHP Version: 5.4.16
MySQL Version: 5.5.52
Webserver Info: Apache/2.4.6 (CentOS) PHP/5.4.16

#### PHP Configuration

Safe Mode: Disabled
Memory Limit: 1024M
Upload Max Size: 99M
Post Max Size: 99M
Upload Max Filesize: 99M
Time Limit: 2000
Max Input Vars: 1000
URL-aware fopen: On (1)
Display Errors: N/A

#### PHP Extensions

cURL: Supported
cURL Version: 7.29.0
imagick: Not Installed
sass: Not Installed
xsl: Installed
bdolor commented 7 years ago

pull request created https://github.com/pressbooks/pressbooks/pull/652

pbstudent commented 7 years ago

Thanks for looking into it. I still get the same white screen, even though I changed in pressbooks/includes/modules/export/mpdf/class-pb-pdf.php

set_time_limit( 600 ); to set_time_limit( 2000 );

or

I also tried changing the above from 1200 to 2000 but no difference.

(Just an observation, but when Prince is installed mPDF gets difficulties. Without Prince I rarely had issues completing an mPDF export.)

bdolor commented 7 years ago

I cannot see a relationship between Prince being installed on a server and mPDF. I cannot reproduce a white screen on export. Evidence that you could provide would exist in an error log of the PHP or Apache variety. Closing this for now. Please only re-open if specific error messages are found and include steps to reproduce the problem.

pbstudent commented 7 years ago

Thank you very much for your attention, but I have no access to anything outside the WordPress folder. I'm only an enduser who can no longer use mPDF, which has been great plugin and the only one to create a cover page. Hopefully, next version of Pressbooks may resolve my issue.

bdolor commented 7 years ago

You are welcome. Where endusers and developers meet is at an error message, usually in a log file. Developers cannot help endusers otherwise.

This debug.log file remains inside the Wordpress folder: Instructions are here https://codex.wordpress.org/Debugging_in_WordPress

pbstudent commented 7 years ago

Installed latest mPDF 1.6.1 - now the white screen has no text in upper left hand corner. However, as per your guidance - enabling wp-debug and installing wp-no-white-screen (https://github.com/stracker-phil/wp-no-white-screen/), I am able to submit the following debug.log file:

[09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: Illegal string offset 'mpdf_level' in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 641 [09-Feb-2017 09:32:54 UTC] PHP Warning: require_once(/var/www/html/wp-content/plugins/pressbooks-mpdf/symbionts/mpdf/mpdf.php): failed to open stream: No such file or directory in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 142 [09-Feb-2017 09:32:54 UTC] PHP Fatal error: require_once(): Failed opening required '/var/www/html/wp-content/plugins/pressbooks-mpdf/symbionts/mpdf/mpdf.php' (include_path='.:/usr/share/php') in /var/www/html/wp-content/plugins/pressbooks/includes/modules/export/mpdf/class-pb-pdf.php on line 142

hope that helps.

bdolor commented 7 years ago

It does help!

https://github.com/pressbooks/pressbooks/pull/654

pbstudent commented 7 years ago

I followed the fixes:

All working great now. Thanks.