开发者

Mac OSX Convert library (html file to pdf) works via terminal but not PHP

I'm trying to take a generated html file and convert it to PDF on the fly with PHP. It's going开发者_开发技巧 on my localhost and staying there so for the PDF conversion I'm using a Mac OSX utility, I guess you would call it.

The terminal command being:

/System/Library/Printers/Libraries/convert -f temporary.html -o destination/final.pdf

This works properly via terminal (produces a simple 20kb PDF file); however, when I run it inside PHP via passthru() the file (final.pdf) is created though it is a Zero KB file (corrupt).

The /destination folder is CHMOD 777, temporary.html is CHMOD 755.

Any help would be greatly appreciated.

Edit (Additional Detail): Now in the error log, amongst the debug lines there is an error of "ERROR: xhtmltopdf (PID 13204) crashed on signal 6!"


I like to share what I do to generate PDF file on the fly. We use UNIX server to host.

I use tcpdf - a php library to convert HTML to PDF file. I use it in my projects and it works very well. TCPDF supports css, javascript, forms, images and lot more.

Website: http://www.tcpdf.org/

Demos: http://www.tcpdf.org/examples.php


When I need convert HTML in PDF I use this very nice software: http://www.princexml.com

You could have a look, it's free for personal use.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜