Hello Iam使用pdfCrowd Api转换为pdf。如果我使用convertfile指定视图它说路径无效?如何将视图传递给pdfCrowd的转换文件功能?
function download() { require('pdfcrowd.php'); $user_id=$this->session->userdata('user_id'); $data = array(); $data['result']=$this->user_data_model->getcertificate($user_id); try { // create an API client instance $client = new Pdfcrowd('username','api');
// convert a web page and store the generated PDF into a $pdf variable $pdf = $client->convertFile('certificate_template'); // 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; } }

function download() {
require('pdfcrowd.php');
$user_id=$this->session->userdata('user_id');
$data = array();
$data['result']=$this->user_data_model->getcertificate($user_id);
try
{
// create an API client instance
$client = new Pdfcrowd('username','api');
// convert a web page and store the generated PDF into a $pdf variable
$pdf = $client->convertFile('certificate_template');
// 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;
}
}

答案 0 :(得分:0)
convertFile方法仅接受本地HTML文件,不能作为模板。
您有2个选择:
或