This is an archived forum post. The information may be outdated. Contact us if you have any questions.
$doc =& JFactory::getDocument(); $doc->setMimeEncoding('application/pdf');
<?php /*bring needed data from form $name = $_POST['name']; $email = $_POST['email']; $company = $_POST['company']; $body1 = $_POST['body1']; $body2 = $_POST['body2']; /*create html page echo $body1; echo $body2; /*set doc as pdf $doc =& JFactory::getDocument(); $doc->setMimeEncoding('application/pdf'); include 'pdfcrowd.php'; function generatePDF() { if (!$_GET["pdf"]) return False; try { // build the url and remove the pdf field from the query string $url = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"]; if (count($_GET) > 1) { unset($_GET["pdf"]); $url = $url . "?" . http_build_query($_GET, '', '&'); } // call the API $client = new Pdfcrowd("user", "apikey"); $pdf = $client->convertURI($url); // send the generated pdf to the browser header("Content-Type: application/pdf"); header("Cache-Control: no-cache"); header("Accept-Ranges: none"); header("Content-Disposition: inline; filename=\"created.pdf\""); echo $pdf; } catch(PdfcrowdException $why) { echo "PDF creation failed: ".$why."\n"; } return True; } try { // create an API client instance $client = new Pdfcrowd("***", "***"); if (generatePDF()) return; } catch(PdfcrowdException $why) { echo "Pdfcrowd Error: " . $why; } ?>
4043 bytes of html code 140393 bytes of pdf received from the api 53 bytes of html code