Skip to content

Instantly share code, notes, and snippets.

@nixon1333
Created December 13, 2015 07:16
Show Gist options
  • Save nixon1333/bd41b34e8174115eb08c to your computer and use it in GitHub Desktop.
Save nixon1333/bd41b34e8174115eb08c to your computer and use it in GitHub Desktop.
how to parse a secured file in php and make it available in pdf using wkhtmltopdf
//if expected template available in string formate
if($string1)
{
//write the expected template in a unique html file
write_file("uploads/$classId/Result-$classId-part$number.html", $string1);
//make the unique url for the html
$fileUrl = base_url()."uploads/$classId/Result-$classId-part$number.html";
//run exec funtion and fee the html link to wkhtml function with requed pdf link(unique)
exec('"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe" '.$fileUrl. ' uploads/'.$classId.'/'.$number.".pdf");
//after execution remove the html file
unlink("uploads/$classId/Result-$classId-part$number.html");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment