php - Generate PDF with base64 encode string -
i using api provides me base64 encoded content. mentioned can download pdf file saving content .pdf file.
in api documentation, it's mentioned
a pdf contains contents of invoice. encode content base64 string create base64-encoded .pdf file.
you can query field download invoice pdf specific invoice. after query it, can save string .pdf file, view file in pdf reader.
i using tcpdf write content in pdf file. generates blank pdf file.
$pdf = new pdf('test title', 'test subject');
$pdf->gettcpdf()->write(0, 0, '', '', base64_decode($this->get(self::body)), 0, 1, 0, true, '', true);
$pdf->download();
am doing wrong?
i think should use code pdf file :
$data = base64_decode($this->get(self::body)); file_put_contents('mypdf.pdf',$data);
then can open it.
or can echo content page :
$data = base64_decode($this->get(self::body)); header('content-type: application/pdf'); echo $data;
good luck
Comments
Post a Comment