@anttiviljami hi - i know this is not your main gig and that you don't use this much these days.
i have spent tons of time trying to solve this issue.
i read all the forums posts on WP, and a lot of stackoverflows about this.
i have this working just fine on a VPS, on several websites, with the same hosting company (MT), exact same code.
on MANAGED HOSTING, the PDF returns blank. the error logs show nothing I can solve:
errors.zip
errors.log
i was told by the hosting's support that this can't work on this type of hosting, but i didn't believe it since file_get_content works, curl works, and i actually managed to generate a pdf with this test file:
<?php
$test = file_get_contents('https://DOMAIN_NAME_REMOVED/professionals/erica-wolff/pdf-preview', false);
require_once 'wp-content/plugins/wp-pdf-templates/vendor/autoload.php';
$dompdf = new Dompdf\Dompdf();
define("DOMPDF_ENABLE_HTML5PARSER", true);
$dompdf->loadHtml($test);
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
// stream(filename [without .pdf], 1 compress, 1 force save dialog)
$dompdf->stream('/var/www/wp-content/test123f.pdf',array('compress'=>0,'attachment'=>1));
?>
...going around all the Wordpress stuff found in the actual plugin.
the result is very close the functioning one we have on our dev server, but only if i try to read from -template, from -preview it fails.
test123f.pdf (16).pdf
what i am asking is this:
- obviously dompdf works on this environment
- i am able to generate a pdf with the layout that we want from the wordpress post
- /pdf-template and /pdf-preview work fine
- the pdf is blank, the stream part is blank, i attached it if someone speaks PDF :D
if anybody has any insight on how to solve this, i would be grateful. i tried swapping dompdf versions, i tried outputting just the default template that comes with the plugin, i tried debugging verbosely... (by the way, how to get the same output as the debugger found on http://eclecticgeek.com/dompdf/debug.php ? the one that shows dependencies? i wasn't able to do that
i am able to generate basic pdfs with just things like "hello world" — what fails is when i try to read content from an html.
if anybody has had experience with that and solved it, i am willing to try your solution!
my guess is that the managed hosting restrictions prevent from reading or writing the temp file
i have to disable cache to make my test work, and the font cache folder never gets the .inc file or the font files.
happy to jump on a discord if you want to check this out with me, i am totally stuck.
thanks!