Created
November 26, 2015 02:10
-
-
Save dergachev/4938d1faa1bfdd347c93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/sites/all/modules/contrib/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.pages.inc b/sites/all/modules/contrib/print/print_pdf/lib_ | |
index 3e86f97..87fdfc8 100644 | |
--- a/sites/all/modules/contrib/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.pages.inc | |
+++ b/sites/all/modules/contrib/print/print_pdf/lib_handlers/print_pdf_wkhtmltopdf/print_pdf_wkhtmltopdf.pages.inc | |
@@ -49,21 +49,30 @@ function print_pdf_wkhtmltopdf_print_pdf_generate($html, $meta, $paper_size = NU | |
$wkhtmltopdf_options .= ' --username ' . check_plain($_SERVER['PHP_AUTH_USER']) . ' --password ' . check_plain($_SERVER['PHP_AUTH_PW']); | |
} | |
- $descriptor = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'a')); | |
- $cmd = '"' . realpath($pdf_tool[1]) . "\" --page-size $paper_size --orientation $page_orientation --dpi $dpi $wkhtmltopdf_options - -"; | |
+ $file = drupal_tempnam("/tmp/", "wkhtmltopdf_"); | |
+ $file .= ".html"; | |
+ $fd = fopen($file, 'w'); | |
+ fwrite($fd, $html); | |
+ fclose($fd); | |
+ # die($file); | |
+ | |
+ $descriptor = array(0 => array('file', '/dev/null', 'r'), 1 => array('pipe', 'w'), 2 => array('file', '/dev/null', 'w')); | |
+ $cmd = '"' . realpath($pdf_tool[1]) . "\" --page-size $paper_size --orientation $page_orientation --dpi $dpi $wkhtmltopdf_options $file -"; | |
$process = proc_open($cmd, $descriptor, $pipes, NULL, NULL); | |
if (is_resource($process)) { | |
- fwrite($pipes[0], $html); | |
+ # fwrite($pipes[0], $html); | |
fclose($pipes[0]); | |
+ | |
+ fclose($pipes[2]); | |
$pdf = stream_get_contents($pipes[1]); | |
fclose($pipes[1]); | |
- stream_set_blocking($pipes[2], 0); | |
- $error = stream_get_contents($pipes[2]); | |
- fclose($pipes[2]); | |
+ // stream_set_blocking($pipes[2], 0); | |
+ // $error = stream_get_contents($pipes[2]); | |
+ // fclose($pipes[2]); | |
$retval = proc_close($process); | |
if (!empty($error) || ($retval != 0)) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment