This is an archived forum post. The information may be outdated. Contact us if you have any questions.
<form action="" method="post"> <input type="submit" value="Save HTML" /> <input type="hidden" name="button_pressed" value="1" /> </form> <form action="savepdf.php" method="post"> <input type="submit" value="Save PDF" /> <input type="hidden" name="button_pressed" value="1" /> </form> <?php try if (isset($_POST['button_pressed'])) { file_put_contents('newpage2.html', ob_get_contents()); } ?>
<?php require 'inc/pdfcrowd.php'; ob_start(); ?> <form action="" method="post"> <input type="submit" value="Save 2 PDF" /> <input type="hidden" name="button_pressed" value="1" /> </form> <?php try { if (isset($_POST['button_pressed'])) { file_put_contents('newpage2.html', ob_get_contents()); $client = new Pdfcrowd("***", "***"); $pdf = $client->convertFile("newpage2.html"); header("Content-Type: application/pdf"); header("Cache-Control: no-cache"); header("Accept-Ranges: none"); header("Content-Disposition: inline; filename=\"newPDF2.pdf\""); echo $pdf; } } catch(PdfcrowdException $why) { echo "Pdfcrowd Error: " . $why; } ?>