• i get this error after i click on PDF button> onr a new tab with this Error Message:

    “Failed to load PDF document”

    What is the solution? Thank you ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author fkrauthan

    (@fkrauthan)

    You need to check your PHP Error logs for any hints.

    I periodically encounter this error: The application works well most of the time, then fails on a certain instance type.

    I have previously cured the error by simplifying the code used to produce the content of the eventual document. I’m kind of at the end of that process now, and still getting the error. I can provide more details/access if you are interested in investigating and helping out further.

    The only information in error logs that hint at an mpdf problem are on the level of a “notice” referencing a deprecated “each” function:

    [27-Jan-2021 21:03:17 UTC] PHP Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/duffym5/public_html/pianorentals.com/wp-content/plugins/wp-mpdf/mpdf/mpdf.php on line 10894

    I tried switching to an earlier version of PHP (from 7.3 to 7.0), and the deprecation warning went away, but the failure to load error didn’t.

    Plugin Author fkrauthan

    (@fkrauthan)

    What failure to load do you see?

    The message used as the title of this thread, upon an attempt to load the generated PDF, in Chrome. As a side note, these occasional but repeatable failures occur across different browsers, although some browsers produce different failures than others: On Chrome, nothing loads at all, for example, other than the Acrobat background and the above-referenced message. Firefox manages to load some of the document header, and also offers some other options (that don’t do any good). Meanwhile, as noted, many similar or even nearly identical documents (or documents based on near-identical inputs) load as desired.

    Just to give you some background:

    I have two different documents, originally consisting of an HTML table or set of tables, with a few headings and a paragraph or two, with dynamic content derived from user and WooCommerce order and product data.

    I don’t know how much more detail would be useful for you. I’ll just say here that the document HTML is returned via ob_get_clean() in a shortcode function. Originally, I ran some logic after the original ob_start(). As errors popped up, I found that it helped to move all calculations, no matter how simple – many were of the general type echo $response ? $response : $no_response – outside of the object declaration.

    In other words, I am now deploying no PHP more complicated than echo $variable between ob_start() and ob_get_clean(). I still got another load failure this week. This time, I was able to clear the error by simplifying the document even further, converting two tables to just one.

    I wonder if there isn’t some memory- or capacity-related bottleneck interfering with PDF generation, though I’ve also tried increasing PHP memory limits without effect. However, I don’t understand that part of the process very well.

    If you want to look into this further, I can give you access and show you the PHP I’m using. I don’t really expect you to do that, though – I was really just hoping for some clues on where to look next.

    Plugin Author fkrauthan

    (@fkrauthan)

    You would see an error in the PHP log. So far the only thing you showed here was a Warning that in itself shouldn’t be of much of an issue. I recommend downloading the PDF and maybe try opening it in a Text Editor (maybe your system thinks it’s a PDF but its actually some PHP Error Message as text).

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Error Message: Failed to load PDF document.’ is closed to new replies.