2017 © Pedro Peláez
 

library pdfcrowd-php

image

radweb/pdfcrowd-php

  • Friday, March 14, 2014
  • by rmlewisuk
  • Repository
  • 9 Watchers
  • 1 Stars
  • 39,095 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 43 Forks
  • 0 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

Pdfcrowd HTML to PDF API client

This package is no longer maintained, use this https://github.com/pdfcrowd/pdfcrowd-php instead., (*1)

The Pdfcrowd API lets you easily create PDF from web pages or raw HTML code in your PHP applications., (*2)

To use the API, you need an account on http://pdfcrowd.com, if you don't have one you can sign up here. This will give you a username and an API key., (*3)

Installation

Copy pdfcrowd.php to your source directory., (*4)

Example

Server side PDF generation. This code converts a web page and sends the generated PDF to the browser (don't forget to use your "username" and "apikey"):, (*5)

require 'pdfcrowd.php';

try
{   
    // create an API client instance
    $client = new Pdfcrowd("username", "apikey");

    // convert a web page and store the generated PDF into a $pdf variable
    $pdf = $client->convertURI('http://example.com/');

    // set HTTP response headers
    header("Content-Type: application/pdf");
    header("Cache-Control: no-cache");
    header("Accept-Ranges: none");
    header("Content-Disposition: attachment; filename=\"created.pdf\"");

    // send the generated PDF 
    echo $pdf;
}
catch(PdfcrowdException $e)
{
    echo "Pdfcrowd Error: " . $e->getMessage();
}

Other basic operations:, (*6)

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

// convert an HTML file
$pdf = $client->convertFile('/path/to/local/file.html');

The Versions

14/03 2014

dev-master

9999999-dev

  Sources   Download

MIT

by Robb Lewis