This is an archived forum post. The information may be outdated. Contact us if you have any questions.

How to Set the PDF Name

ckeilson wrote on 2013-09-27:
I do not know how to incorporate the code to set the PDF name. Below is my code. If you can tell me where to set the PDF name that would be great. It is not working when I put it under the "header section. The PDF still says it is an untitled document.


<?php
	$product_ID = $_GET['product_ID'];
?>

<?php

require 'pdfcrowd.php';




try
{   

$url = "http://keilsonconsulting.com/ejbco/specsheet.php?product_ID=" . $product_ID;

    // create an API client instance
    $client = new Pdfcrowd("XXXXX", "XXXXX");
$client->setPageWidth("8.5in");
$client->setPageHeight("11in");

    // convert a web page and store the generated PDF into a $pdf variable
    $pdf = $client->convertURI($url);

    // set HTTP response headers
    header("Content-Type: application/pdf");
    header("Cache-Control: no-cache");
    header("Accept-Ranges: none");
    header("Content-Disposition: attachment; filename=\"Spec Sheet from EJB Plastics.pdf\"");
	
    // send the generated PDF 
    echo $pdf;
}

catch(PdfcrowdException $why)
{
    echo "Pdfcrowd Error: " . $why;
}
?>
support wrote on 2013-09-30:
Hello,

The PDF title is taken from the <title> tag. Example:
<html>
  <head>
    <title>Document Title</title>
    ..
  </head>
  <body>
    ..
  </body>
</html>