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

Failed to Load PDF Document Error

chowk128 wrote on 2014-08-13:
I am using the example code to generate the www.google.com website and I am getting the Failed to Load PDF Document. I am currently running the code on a member's only area of Drupal Commerce. Would that affect this?

require 'pdfcrowd.php';
try
{
// create an API client instance
$client = new Pdfcrowd("***", "***");

// convert a web page and store the generated PDF into a $pdf variable
$pdf = $client->convertURI('http://www.yahoo.com/');

// set HTTP response headers
header("Content-Type: application/pdf");
header("Cache-Control: max-age=0");
header("Accept-Ranges: none");
header("Content-Disposition: attachment; filename=\"google_com.pdf\"");

// send the generated PDF
echo $pdf;
}
catch(PdfcrowdException $why)
{
echo "Pdfcrowd Error: " . $why;
}
support wrote on 2014-08-14:
Hello,

Please send the PDF file you are unable to open to support@pdfcrowd.com and we will look into it.
ramubujji wrote on 2014-08-19:
Hi,

I'm using the example code from the site and when we tried the save to pdf the pdf is generating and the pdf file is showing failed to load the document , because the file is damaged. please check this issue asap , I can't able to upload the pdf file also because the file size is around 240 kb. I'm integrating the this code in joomla 3.0.

The code which I'm using is as follows

public function print_pdf()
{
//require 'pdfcrowd.php';
require JPATH_SITE.'/components/com_rsform/helpers/pdfcrowd.php';
try
{
// create an API client instance
$client = new Pdfcrowd("xxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxx");

//$pdf = $client->convertURI($a);
$pdf = $client->convertURI('http://www.google.com');
//echo '<pre>';print_r($client);exit;
// set HTTP response headers
header("Content-Type: application/pdf");
header("Cache-Control: max-age=0");
header("Accept-Ranges: none");
header("Content-Disposition: attachment; filename=mecha.pdf");
// send the generated PDF
echo $pdf;
}
catch(PdfcrowdException $why)
{
echo "Pdfcrowd Error: " . $why;
}
}

and i'm calling this function once user clicks on the savepdf button.

Regards,
Ramu Chinta.
support wrote on 2014-08-20:
Hello,

As I wrote before, please send the corrupted PDF to support@pdfcrowd.com (do not attach it here in the forum) and we will look into it.