After upgrading some modules print stopped working, so I upgraded it to 7.2

Now I cannot generate PDF and watchdog says:

Notice: Undefined variable: print a include() (línia 36 de /home/user/public_html/sites/all/themes/mytheme/templates/print.tpl.php).

The template uses a variable named $print. Was it removed between 7.1 and 7.2?

How can I solve this?

I can code, just not familiar with this module and any hint is wellcome.

CommentFileSizeAuthor
#4 patch2.0.patch2.54 KBftorredeflot

Comments

enboig’s picture

after looking at #1941772 I executed the shell command directly and it works, so I don't know why is it failing:

wkhtmltopdf ["/home/user/public_html/sites/all/modules/print/lib/wkhtmltopdf-amd64" --page-size A4 --orientation portrait --dpi 96 --disallow-local-file-access --footer-font-size 7 --footer-right '[page]' - -] (returned 1): No stderr output available. Command was: "/home/user/public_html/sites/all/modules/print/lib/wkhtmltopdf-amd64" --page-size A4 --orientation portrait --dpi 96 --disallow-local-file-access --footer-font-size 7 --footer-right '[page]' - -

I changed the input and de output and it works:
wget -O - -o /dev/null http://www.google.com | /home/user/public_html/sites/all/modules/print/lib/wkhtmltopdf-amd64 --page-size A4 --orientation portrait --footer-font-size 7 --footer-right '[page]' - google.pdf

Any hint?

enboig’s picture

Ok, my old print module was patched to use temporary files and not pipes. I have recreated the patch and now it works. Is somebody is interested in the code I paste it here:

  
    // Write the data to a temporary file.
  $temp_path = realpath(file_directory_temp()) . '/';
  $temp_html =  false;
  $temp_pdf = false;
  $retries=0;
  while (($temp_html==false) && ($retries<10)) {
    $temp_html =  drupal_tempnam($temp_path, 'c_html_');
    if (rename($temp_html, $temp_html.'.html')) {
      $temp_html = $temp_html.'.html';
    }
    
    $retries++;
  }
  while (($temp_pdf==false) && ($retries<20)) {
    $temp_pdf =  drupal_tempnam($temp_path, 'c_pdf_');
    if (rename($temp_pdf, $temp_pdf.'.pdf')) {
      $temp_pdf = $temp_pdf.'.pdf';
    }
    $retries++;
  }
  watchdog('devel', "temp_html: $temp_html temp_pdf: $temp_pdf");
  if (file_put_contents($temp_html, $html) === FALSE) {
    return FALSE;
  }
  $cmd2= '"' . realpath($pdf_tool[1]) . "\" --page-size $paper_size --orientation $page_orientation --dpi $dpi $wkhtmltopdf_options $temp_html $temp_pdf";
  watchdog('devel2', $cmd2);
  exec($cmd2);

  $pdf= file_get_contents($temp_pdf);
  unlink($temp_html);
  unlink($temp_pdf);
enboig’s picture

Assigned: Unassigned » enboig
Status: Active » Closed (works as designed)
ftorredeflot’s picture

StatusFileSize
new2.54 KB

Hi,
I've been adapting enboig's patch, this adapted patch it works with print module 7.x-2.0