Hi guys,
I'm trying to create pdf file from URI using PHP. Here is my code,
require_once("include/pdfcrowd.php");
try
{
$client = new Pdfcrowd("my_username", "my_api_key");
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="google.pdf"');
$client->convertURI('http://www.google.com', fopen('google.pdf', 'wb'));
echo "remaining tokens: " . $client->numTokens();
}
catch(PdfcrowdException $e)
{
echo $e->getMessage();
}
Pdf file I've got is always 1KB and cannot open with adobe reader correctly. The error shows by adobe reader when I tried to open is "Adobe Reader could not open 'google.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)."
Please let me know which part I missed? or give me some suggestion please.
(Note: without the 2 header() lines, the file has not been forced to download, so I put it as you mentioned in https://pdfcrowd.com/forum/archive/read/?3,143)
By the way, thanks for your hard working to give us a nice and easy tool like this! :)