2. Using PHP

To use the PDFreactor PHP API simply copy the PDFreactor.class.php and the ROClient.class.php to a directory of your webserver where PHP is enabled.

Then include the PDFreactor.class.php with:

include("/path/to/PDFreactor.class.php");

With just a few lines you can create and directly show PDFs inside your PHP webapplication:

<?php
include("../PDFreactor.class.php");
$pdfreactor = new PDFreactor();
$pdfreactor->setBaseURL("http://myserver.com".$_SERVER['PHP_SELF']);
$pdfreactor->setAuthor("Myself");
$pdfreactor->setTitle("My PDFreactor PHP application");
$pdfreactor->setAddLinks(true);
$pdfreactor->setAddBookmarks(true);
$result = $pdfreactor->renderDocumentFromURL("http://www.realobjects.com");

// Check if successfull
if ($pdfreactor->getError() != "") {
    // Not successful->print error and log
    echo "Error during rendering: <br/>".$pdfreactor->getError().
    "<br/><br/>".$pdfreactor->getLog();
} else {
    // Set the correct header for PDF output and echo PDF content
    header("Content-Type: application/pdf");
    echo $result;
}
?>

See:

PDFreactor methods in the PHP API docs for all avaible options.

PHP API specific issues. PHP Script timeout: Generally the timeout of PHP scripts is set to 30s within the php.ini. When rendering large documents this limit may be exceeded.

As of this version a SOAP client (ROClient.class.php) is built-in, so no installation of a third-party SOAP library is necessary in order to use the PHP API. It is however still possible to use the third-party library PEAR-SOAP or the built-in PHP 5 SOAP extension instead by specifying it in the PDFreactor constructor:

$pdfreactor = new PDFreactor("PEAR");
$pdfreactor = new PDFreactor("PHP");