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

Resize page

coniston wrote on 2017-03-01:
Hello.
I am a new user. I have checked the different parameters to set the format of the page. Here they are:

$client->setPageWidth("8.5in");
$client->setPageHeight("14in");
$client->setHorizontalMargin("0.5in");
$client->setVerticalMargin("0.5in");

But how do I integrate them in the basic example code to do their job. Where and how should they be put in the code hereafter to do the job? Can you please help me out?

[....]

<?php
require '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("username", "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: attachment; filename=\"created.pdf\"");

echo $pdf;
}
catch(PdfcrowdException $why) {
echo "PDF creation failed: ".$why."\n";
}

return True;
}
?>

[....]
support wrote on 2017-03-01:
Hello,

Any PDF customization API methods must be called right before $client->convertURI().