#native_company# #native_desc#
#native_cta#

Convert a web page or raw HTML to PDF

By Jarda Gresula
on 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'));