Forum How do I...?

Trouble generating a PDF

sportsracer
Here's my code that is copied from another working codebase.

$reportFileName = 'Test - ' . date('His') . '.pdf';

$prince = new Prince($this->config->prince->path);

$prince->setHTML(true);
$pdfPath = "/tmp/". $reportFileName;

$this->view->pdfContent = $content;
$pdfView = $this->view->render('reports/PDFwrapper.phtml'); // intercept the view and capture it as a string

//*********** Just a real simple html string for testing. The stuff above results in the same conclusion **/
$pdfView = '<!DOCTYPE html>
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  </head>
  <body>
    This is Test
    </body>
</html>';

 //send the html string to prince
header('Content-Type: application/pdf');
if($inline){
     header('Content-Disposition: inline; filename="'. $reportFileName .'"'); // show in browser
}else{
     header('Content-Disposition: attachment; filename="'. $reportFileName .'"');
}
header('Pragma: private');
$result = $prince->convert_string_to_passthru($pdfView, $pdfPath);


What I get is an empty 0 byte PDF and a boolean false for $result.

Any ideas of what's going wrong here? Thanks!
mikeday
First, check that $this->config->prince->path is correct. Second, convert_string_to_passthru does not take a filename, as it emits the PDF as the output of the page back to the browser.
sportsracer
I had a big brain cramp. $this->config->prince->path was the problem, it was pointing to our production path and not the local.

I've removed $pdfPath from convert_string_to_passthru().

Sorry for the trouble and thanks for the help and the great product!