This is an archived forum post. The information may be outdated. Contact us if you have any questions.
<?php session_start(); if(isset($_SESSION['userLoggedIn']) && $_SESSION['userLoggedIn'] ) { include_once $_SERVER['DOCUMENT_ROOT'].'/crm/inc/base.inc.php'; include $_SESSION['myroot'].'/inc/htmLawed/htmLawed.php'; $html = '<!DOCTYPE html> <html> <head> <style> // Add some styling elements </style> <title>Open Order Report</title> </head> <body>' .htmLawed(get_ship_history($d1, $d2, false, true)).' </body> </html>'; try { require $_SESSION['myroot'].'/inc/pdfcrowd/pdfcrowd.php'; // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("xxxxx", "my super duper top secret api code"); $client->setOrientation('landscape'); $client->setPageSize('A3'); $client->setMarginLeft('0.5in'); $client->setMarginRight('0.5in'); $pdf = $client->convertString($html); // set HTTP response headers header('Content-Type: application/pdf'); header('Cache-Control: no-cache'); header('Accept-Ranges: none'); header('Content-Disposition: attachment; filename="ShippingReport.pdf"'); echo $pdf; } catch(\Pdfcrowd\Error $why) { // report the error header('Content-Type: text/plain'); http_response_code($why->getCode()); echo "Pdfcrowd Error: {$why}"; } exit; } else { header('Location:/crm/user/'); exit(); } ?>
header('Content-Disposition: inline; filename="ShippingReport.pdf"');