I have a php file which saves two images into server and creating a pdf of this saved images using dompdf. I am able to save the images into particular folder but not able to generate pdf. could someone tell me what am doing wrong here? Here is my code.
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE);
$data1 = $_POST['data1'];
$data2 = $_POST['data2'];
if(isset($data1)) {
$uri1 = substr($data1,strpos($data1,",")+1);
$uri2 = substr($data2,strpos($data2,",")+1);
$path =$_SERVER["DOCUMENT_ROOT"].'/divya/custom_product/sites/default/files/cart';
$id = "test";
$type ="order";
$file1 = $path .'/'.$id.'-'.$type.'1.png';
$file2 = $path .'/'.$id.'-'.$type.'2.png';
$a=base64_decode($uri1);
$b=base64_decode($uri2);
file_put_contents($file1, $a);
file_put_contents($file2, $b);
}
?>
<?php
require_once("dompdf_config.inc.php");
require_once("sites/all/modules/print/lib/dompdf/dompdf_config.inc.php");
$tbl = '<html style="margin:20px 20px 0px; padding:0;">
<body style="margin:0; padding:0;">
<table style="margin:0px 0px 5px 3px;">
<tr>
<td style="width:220px;vertical-align:top;">'.$file1.'</td>
<td style="width:220px;vertical-align:top;">'.$file2.'</td>
</tr>
</table>
</body>
</html>';
$dompdf = new DOMPDF;
$dompdf->load_html($tbl);
$dompdf->render();
$pdfoutput = $dompdf->output();
// Checks whether there is an output folder inside sites/default/files
if (!is_dir('public://output')) {
mkdir("public://output", 0777);
// Creates a folder and changes its permissions}
$filename = 'sites/default/files/output/' . 'sample.pdf'
$fp = fopen($filename, "w+");
fwrite($fp, $pdfoutput);
// Writes the pdf output to a file
fclose($fp);
?>