Page 1

Created with RealObjects PDFreactor(R) Evaluation Version

This is a demonstration of the PDFreactor PHP API This PDF was created with the code shown below: <?php // The content to render $content = "<html><head><title>PDFreactor PHP API Sample Document</title></head>"; $content .= "<body><h3>This is a demonstration of the PDFreactor PHP API</h3>"; $content .= "<p>This PDF was created with the code shown below:</p>"; $content .= "<pre style=\"font-size: 8pt;\">" . htmlentities(implode(file('index.php')), ENT_COMPAT, "UTF-8") . "</pre>"; $content .= "<p>Please see the <a href=\"../apidoc/PDFreactor-PHP/PDFreactor.html\">API documentation</a> for more information.</p></body></html>"; // Include PDFreactor class require_once("../lib/PDFreactor.class.php"); // Create new PDFreactor instance $pdfReactor = new PDFreactor();

$pdfReactor->setLicenseKey("<license> <licensee> <name>print service</name> </licensee> <product>PDFreactor</product> <majorversion>6</majorversion> <minorversion>0</mi $result = $pdfReactor->renderDocumentFromContent($content); // Set a base URL for images, style sheets, links $pdfReactor->setBaseURL("http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]); // Set an appropriate log level $pdfReactor->setLogLevel(LOG_LEVEL_WARN); // Set the title of the created PDF $pdfReactor->setTitle("Demonstration of PDFreactor PHP API"); // Sets the author of the created PDF $pdfReactor->setAuthor("Myself"); // Enables links in the PDF document. $pdfReactor->setAddLinks(true); // Enables bookmarks in the PDF document. $pdfReactor->setAddBookmarks(true); // Set some viewer preferences $pdfReactor->setViewerPreferences(VIEWER_PREFERENCES_FIT_WINDOW | VIEWER_PREFERENCES_PAGE_MODE_USE_THUMBS); // Add user style sheets // e.g. format landscape $pdfReactor->addUserStyleSheet("@page { size: A4 landscape;" . "@bottom-center {" . "text-align: center;" . "font: 12px Arial, Helvetica, sans-serif;" . "color: #7F7F7F;" . "content: 'Created on " . date("D M j Y G:i:s") . "';" . "margin-bottom: 1cm;" . "}" . "}", "", "", ""); $pdfReactor->addUserStyleSheet("h3 { color: red; }", "", "", ""); // Render document and save result to $result

Created on Fri Dec 6 2013 11:54:12 Created with RealObjects PDFreactor(R) Evaluation Version


Created with RealObjects PDFreactor(R) Evaluation Version

$result = $pdfReactor->renderDocumentFromContent($content); // Check if successful if (is_null($result)) { // Not successful, print error and log echo "<h1>Error During Rendering</h1>"; echo "<h2>" . $pdfReactor->getError() . "</h2>"; echo "<pre>" . $pdfReactor->getLog() . "</pre>"; } else { // Set the correct header for PDF output and echo PDF content //header("Content-Type: application/pdf"); header('Content-Disposition: attachment; filename=analytics.pdf'); echo $result; } ?>

Please see the API documentation for more information.

Created on Fri Dec 6 2013 11:54:12 Created with RealObjects PDFreactor(R) Evaluation Version

Analytics  
Read more
Read more
Similar to
Popular now
Just for you