Question

I'm having problems getting started with Princexml. I am trying to create my first test PDF.

Here's my code:

require_once dirname(__FILE__).'/prince.php';

$prince = new Prince('/usr/local/bin/prince');

$prince->setHTML(1);
$prince->setLog("/log.txt");
$prince->setPDFTitle("Test File");

$html = file_get_contents(dirname(__FILE__)."/out/test.html");

header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="foo.pdf"');

$ret = $prince->convert_string_to_passthru($html);

The test.html file has this content:

<!DOCTYPE html>
<html>
<head></head>
<body>
    <h1>hello world!</h1>
</body>
</html>

The PDF is loading (if I use 'inline' instead of attachment), but it's a blank document. When I use 'attachment', the file is 0 bytes in size.

I can't figure out what I'm doing wrong here. Any ideas??

Was it helpful?

Solution

I found the answer. This is apparently an issue with MAMP:

http://www.princexml.com/forum/topic/1292/prince-on-os-x-mamp

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top