PHPBuilder - Convert a web page or raw HTML to PDF

RSS Twitter

Convert a web page or raw HTML to PDF

by: Jarda Gresula
January 16, 2011

Version: 1.0

Type: Sample Code (HOWTO)

Category: File Management

License: Other

Description: You can use the Pdfcrowd API to easily create PDF from HTML. The API fully supports HTML/CSS2, you can find the documentation here:

// convert a web page
require 'pdfcrowd.php'
$client = new Pdfcrowd("your-username", "your-apikey");
$client->convertURI('', fopen('example.pdf', 'wb'))

// convert an HTML string
$html = "<html><body>In-memory html.</body></html>";
$client->convertHtml($html, fopen('html.pdf', 'wb'));

// convert an HTML file
$client->convertFile('/path/to/local/file', fopen('file.pdf', 'wb'));

Comment and Contribute

Your comment has been submitted and is pending approval.

Jarda Gresula



(Maximum characters: 1200). You have characters left.