PHPBuilder - Convert a web page or raw HTML to PDF



RSS Twitter
Snippets File Management

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: http://pdfcrowd.com/html-to-pdf-api/



// convert a web page
require 'pdfcrowd.php'
$client = new Pdfcrowd("your-username", "your-apikey");
$client->convertURI('http://www.example.com/', 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.

Author:
Jarda Gresula

Comment:



Comment:

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