Hi, i tested plugin ,but i had exproted broken PDF file when im try to use functionf for images rewrite.
Show us the code in question
view,php:
$download = optional_param('download', false, PARAM_BOOL);
if ($download) {
$printid = required_param('printid', PARAM_INT);
$slotid = required_param('slotid', PARAM_INT);
$document = timetable_generate_document($printid, $slotid);
//echo $document;
$pdf = \local_dompdf\api\pdf::createnew();
$pdf->loadHtml($document);
$pdf->render();
send_file(
$pdf->output(), 'document.pdf', null, 0, true, true, 'application/pdf'
);
}
if ($download) {
$printid = required_param('printid', PARAM_INT);
$slotid = required_param('slotid', PARAM_INT);
$document = timetable_generate_document($printid, $slotid);
//echo $document;
$pdf = \local_dompdf\api\pdf::createnew();
$pdf->loadHtml($document);
$pdf->render();
send_file(
$pdf->output(), 'document.pdf', null, 0, true, true, 'application/pdf'
);
}
and generating of content in function:
$template->body = \local_dompdf\api\pdf::file_rewrite_image_urls($template->docbody, $template->id, 'body', $context->id, 'mod_timetable');
$options = [
'noclean' => true, 'para' => false, 'filter' => true,
'context' => $context, 'overflowdiv' => true
];
$template->body = format_text($template->body, $template->docbodyformat, $options, null);
$options = [
'noclean' => true, 'para' => false, 'filter' => true,
'context' => $context, 'overflowdiv' => true
];
$template->body = format_text($template->body, $template->docbodyformat, $options, null);
Nothing looks wrong but I do not have access to complete module you are using so I can not really tell.
I just added an example to the plugin that exports forum posts. Any forum post that you have you can export with this and if it does contain images they will be exported as well.
See https://github.com/kiklop74/moodle-local_dompdf/blob/master/examples/testimage.php
Make sure that context you use is the right one, make sure that filearea is the right one. See how I create it in my example
I just added an example to the plugin that exports forum posts. Any forum post that you have you can export with this and if it does contain images they will be exported as well.
See https://github.com/kiklop74/moodle-local_dompdf/blob/master/examples/testimage.php
Make sure that context you use is the right one, make sure that filearea is the right one. See how I create it in my example
Hi, i found the source of error, it is a debug messaging:
Warning: Use of undefined constant LIBXML_HTML_NOIMPLIED - assumed 'LIBXML_HTML_NOIMPLIED' (this will throw an Error in a future version of PHP) in /var/www/htmlcel/local/dompdf/classes/api/xmlutil.php on line 84
Warning: Use of undefined constant LIBXML_HTML_NODEFDTD - assumed 'LIBXML_HTML_NODEFDTD' (this will throw an Error in a future version of PHP) in /var/www/htmlcel/local/dompdf/classes/api/xmlutil.php on line 84
Warning: A non-numeric value encountered in /var/www/htmlcel/local/dompdf/classes/api/xmlutil.php on line 84
Warning: Use of undefined constant LIBXML_HTML_NOIMPLIED - assumed 'LIBXML_HTML_NOIMPLIED' (this will throw an Error in a future version of PHP) in /var/www/htmlcel/local/dompdf/classes/api/xmlutil.php on line 84
Warning: Use of undefined constant LIBXML_HTML_NODEFDTD - assumed 'LIBXML_HTML_NODEFDTD' (this will throw an Error in a future version of PHP) in /var/www/htmlcel/local/dompdf/classes/api/xmlutil.php on line 84
Warning: A non-numeric value encountered in /var/www/htmlcel/local/dompdf/classes/api/xmlutil.php on line 84
What PHP version are you using?
El lun., 17 jun. 2019 06:35, Lukas Celinak (via Moodle.org) <
El lun., 17 jun. 2019 06:35, Lukas Celinak (via Moodle.org) <
Im usign PHP 7.2
but ithing problem is in DOM or libxml. We are on centos 6.10 ande s libxml version is 2.7.6.
Just fetch the latest code from github. I removed those constants.
I fetched it, but i think, i need uprage libxml anyway, because:
Generating document with images trough MOODLE FILE API:
Using:
file_rewrite_pluginfile_urls($template->docbody, 'pluginfile.php', $context->id, 'mod_timetable', 'body', $template->id);
it is working in bowser, document is full loaded with images
local_dompf is generating pdf with broken image: "Image not found or type unknown"
Using:
\local_dompdf\api\pdf::file_rewrite_image_urls($template->body, $template->id, 'body', $context->id, 'mod_timetable');
it is working in browser, generated link is in some kind of hash, document is full loaded with images
local_dompf is generating broken pdf
Generating document with images trough MOODLE FILE API:
Using:
file_rewrite_pluginfile_urls($template->docbody, 'pluginfile.php', $context->id, 'mod_timetable', 'body', $template->id);
it is working in bowser, document is full loaded with images
local_dompf is generating pdf with broken image: "Image not found or type unknown"
Using:
\local_dompdf\api\pdf::file_rewrite_image_urls($template->body, $template->id, 'body', $context->id, 'mod_timetable');
it is working in browser, generated link is in some kind of hash, document is full loaded with images
local_dompf is generating broken pdf
Can you try the testimage script in examples directory to see how it behaves in general.
I am using the same code on some of my projects and so far had no issues whatsoever. Please open the issue on github and let's continue there.
Hi,
thank you, and im sorry, i had started header before pdf generating, there was a problem. Everything works fine now.
Good job.
thank you, and im sorry, i had started header before pdf generating, there was a problem. Everything works fine now.
Good job.
It seems that you use old version of libxml
https://php.net/manual/en/libxml.constants.php#constant.libxml-html-noimplied
El lun., 17 jun. 2019 06:35, Lukas Celinak (via Moodle.org) <
https://php.net/manual/en/libxml.constants.php#constant.libxml-html-noimplied
El lun., 17 jun. 2019 06:35, Lukas Celinak (via Moodle.org) <
Anyways I removed those things and that should cover distributions that use older libxml2.