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

Converted PDF cannot store on server

fahim wrote on 2012-06-20:
Hello,

I am trying to store converted PDF (based on given URI) file on the server. However, the generated PDF show message that it was corrupted or not supported file type. And on my web page it shows 'Pdfcrowd Error: Failed writing body (1073 != 1079)'. Below is the simple code i used.

$client = new Pdfcrowd("myname", "apikey");
$client->setPageWidth("8.27in");
$client->setPageHeight("11.69in");
$client->setVerticalMargin("0.9in");
$out_file = fopen("/path/to/dir/$filename.pdf", "wb");
$client->convertURI($url, $out_file);
fclose($out_file);

In contrast, I was trying to accomplish two tasks.
1) Automatically downloaded the converted PDF to my local computer using (echo $pdf;)
2) At the same time, able to store downloaded PDF on server (inside one of the given folder [I already granted 777 permission to the folder]so that user can download any time again)

Please help me. Thanks advance.
support wrote on 2012-06-20:
Could you to try to save the generated PDF to a file like this?
$pdf = $client->convertURI($url);
$out_file = fopen("/path/to/dir/$filename.pdf", "wb"); 
fwrite($out_file, $pdf);
fclose($out_file);

Does this work?
fahim wrote on 2012-06-20:
Thanks for you reply.
When I used fwrite() as u suggested, I was able to generate PDF file on server however when I open the file, the PDF doc said

"Cannot extract the embedded font 'RYUVQS+Arial-BoldMT'. Some characters may not display or print correctly".

And my PDF is almost empty on all pages.
support wrote on 2012-06-20:
Please send us the saved PDF to info@pdfcrowd.com, we will look into it.
fahim wrote on 2012-06-25:
Hi Admin,

I have manage to solve the issue by putting below line on top of my php script file.

set_magic_quotes_runtime(false);

Thank you.