This is an archived forum post. The information may be outdated. Contact us if you have any questions.
function printPDF(){ try { // create an API client instance $client = new Pdfcrowd("lsaul", "9425dc76600b63a829ddb12ad715f8c5"); // convert a web page and store the generated PDF into a $pdf variable $pdf = $client->convertURI('http://example.com/dev.charts/pages/testfile.html'); // set HTTP response headers header("Content-Type: application/pdf"); header("Cache-Control: no-cache"); header("Accept-Ranges: none"); header("Content-Disposition: attachment; filename=\"apoll_table.pdf\""); // send the generated PDF echo $pdf; } catch(PdfcrowdException $why) { echo "Pdfcrowd Error: " . $why; } }
header("Cache-Control: max-age=0");
<?php $print = $_POST['outputpdf']; $table_content = $_POST['pdf_table']; ?> <!DOCTYPE html> <html> <head> <title></title> </head> <body> <?php echo "<h3 style='color: #0275d8;' class='container'>Click on 'Print PDF' to create a PDF of this table, or click 'Back' to restart.</h3>"; echo $table_content; $myfile = fopen("testfile.html", "w"); $txt = "<!DOCTYPE html><html><head><title>Table Output</title></head><body> <link href='../bower_components/bootstrap/dist/css/bootstrap.min.css' rel='stylesheet'>"; fwrite($myfile, $txt); $txt = $table_content; fwrite($myfile, $txt); $txt = "</body></html>"; fwrite($myfile, $txt); fclose($myfile); ?> <div class="container"> <button class="btn btn-danger" onclick="history.go(-1);" style="display:inline-block; float: left;">Back</button> <form id="output" method="post" action="http://www.example.com/dev.charts/pdf-print.php"> <label><img id="loadingimg" style="display: none;" src="http://dev.cloudcell.co.uk/bin/loading.gif"/> </label> <input id="printButton" class="btn btn-success" type="Submit" value="Print PDF" name='outputpdf'> </form> </div> </body> </html>