Hi there,
We are running Prince 8.1 on an server running Ububtu 10 which is serving up PDF versions of content on our Drupal web site using a custom module. I have set it up so that I can create PDFs directly using convert_string_to_passthru and indirectly using convert_string_to_file and generating a link to the file in the HTML output.
Because the content may change and we are not expecting a large volume of PDF requests we would much prefer to use the convert_string_to_passthru method to provide direct downloads rather than saving the PDFs on the server.
This is working perfectly on Mac and Ubuntu browsers, but on Windows XP running Chrome or IE8 (I haven't had a chance to test Windows 7 or 8 or other browsers on XP) the resulting file opened in Adobe Acrobat Reader reports the following error:
"Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem."
And indeed we get no content in the PDF except the page background colour.
The same process using the convert_string_to_file method does produce a valid PDF on XP, so I figured the problem must be in the way we are serving the files using the convert_string_to_passthru method. But I checked the headers and cleaned the output buffer but nothing seems to help.
The log file reports no errors during this process:
This is the PHP code we are currently using to output the PDF:
Any idea what the problem is or how to fix it?
We are running Prince 8.1 on an server running Ububtu 10 which is serving up PDF versions of content on our Drupal web site using a custom module. I have set it up so that I can create PDFs directly using convert_string_to_passthru and indirectly using convert_string_to_file and generating a link to the file in the HTML output.
Because the content may change and we are not expecting a large volume of PDF requests we would much prefer to use the convert_string_to_passthru method to provide direct downloads rather than saving the PDFs on the server.
This is working perfectly on Mac and Ubuntu browsers, but on Windows XP running Chrome or IE8 (I haven't had a chance to test Windows 7 or 8 or other browsers on XP) the resulting file opened in Adobe Acrobat Reader reports the following error:
"Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem."
And indeed we get no content in the PDF except the page background colour.
The same process using the convert_string_to_file method does produce a valid PDF on XP, so I figured the problem must be in the way we are serving the files using the convert_string_to_passthru method. But I checked the headers and cleaned the output buffer but nothing seems to help.
The log file reports no errors during this process:
Wed Jul 31 15:03:15 2013: ---- begin
Wed Jul 31 15:03:15 2013: Loading document...
Wed Jul 31 15:03:16 2013: Converting document...
Wed Jul 31 15:03:16 2013: finished: success
Wed Jul 31 15:03:16 2013: ---- end
This is the PHP code we are currently using to output the PDF:
switch ($output_mode) {
case OUTPUT_SCREEN:
drupal_deliver_html_page($input_node);
break;
case OUTPUT_DOWNLOAD:
ob_start();
$result = $prince->convert_string_to_passthru($input_html);
$pdf = ob_get_contents();
ob_end_clean();
if (!strlen($result)) {
// handle errors
} else {
header("Content-Transfer-Encoding: binary");
// header("Pragma: public"); // required
// header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
// header("Cache-Control: private", FALSE); // required for certain browsers
header("Content-Type: application/pdf");
header('Content-Disposition: attachment; filename="'.$output_filename.'";');
// header("Content-Length: ".$fsize);
print $pdf;
ob_end_flush(); //now the headers are sent
}
break;
case OUTPUT_FILE:
// check the output folder exists, create it if it doesn't
// file_prepare_directory() passes the $dir by reference, so can't use
// the constant dirstly
$dir = DOWNLOAD_PATH;
file_prepare_directory($dir, FILE_CREATE_DIRECTORY);
@$prince->convert_string_to_file($input_html, $output_realpath, $msgs);
$input_node = '<h3><a href="' . $output_url . '?' . time() . '">Download the PDF</a></h3><br /><hr /><br />' . $msgs . $input_node;
drupal_deliver_html_page(drupal_render_page($input_node));
break;
}
Any idea what the problem is or how to fix it?