A wrapper for the DocRaptor HTML to PDF/XLS service.

1.3.0 2017-11-21 19:33 UTC

This package is not auto-updated.

Last update: 2020-07-10 19:23:21 UTC


Build Status

DocRaptor PHP Native Client Library

This is a PHP package for using DocRaptor API to convert HTML to PDF and XLSX.

Composer Installation

composer require docraptor/docraptor

Manual Installation

If you do not wish to use Composer, you can download the latest release, unzip in your project and require autoload.php.



See examples for runnable examples with file output, error handling, etc.

$configuration = DocRaptor\Configuration::getDefaultConfiguration();
$configuration->setUsername("YOUR_API_KEY_HERE"); // this key works for test documents
// $configuration->setDebug(true);
$docraptor = new DocRaptor\DocApi();

$doc = new DocRaptor\Doc();
$doc->setTest(true);                                                   // test documents are free but watermarked
$doc->setDocumentContent("<html><body>Hello World</body></html>");     // supply content directly
// $doc->setDocumentUrl(""); // or use a url
$doc->setName("docraptor-php.pdf");                                    // help you find a document later
$doc->setDocumentType("pdf");                                          // pdf or xls or xlsx
// $doc->setJavascript(true);                                          // enable JavaScript processing
// $prince_options = new DocRaptor\PrinceOptions();                    // pdf-specific options
// $doc->setPrinceOptions($prince_options);
// $prince_options->setMedia("screen");                                // use screen styles instead of print styles
// $prince_options->setBaseurl("");                    // pretend URL when using document_content

$create_response = $docraptor->createDoc($doc);

Docs created like this are limited to 60 seconds to render, check out the async example which allows 10 minutes.

We have guides for doing some of the common things:

More Help

DocRaptor has a lot more styling and implementation options.

Stuck? We're experts at using DocRaptor so please email our support team if you run into trouble.


The majority of the code in this repo is generated using swagger-codegen on docraptor.yaml. You can modify this file and regenerate the client using script/generate_language php.

Release Process

  1. Pull latest master
  2. Merge feature branch(es) into master
  3. script/test
  4. Increment version in code:
  • swagger-config.json
  • lib/Configuration.php (2 places)
  1. Update
  2. Commit "Release version vX.Y.Z"
  3. Push to GitHub
  4. Tag version: git tag 'vX.Y.Z' && git push --tags (GitHub packagist integration will tell packagist to release a new version)
  5. Verify update on
  6. Refresh documentation on

Version Policy

This library follows Semantic Versioning 2.0.0.


  • Joel Meador
  • Elijah Miller
  • James Paden
  • Jason Gladish
  • Nikola Nikolov