2 years ago

#60332

test-img

shreyansh saxena

wkhtmltopdf not creating pdf from PHP code

I am trying to create PDF from HTML using wkhtmltopdf, However when I do it using PHP script It doesn't create PDF but when I paste that same command on terminal it generates the pdf, don't know what's happening.

$html_file_url = 'http:127.0.0.1/assessment/testreport.html';
$pdf_file_base_url = 'C:\xampp\htdocs\assessment'; 

$slash = '\\';
$user = $_SESSION['email'];
$pdf = '.pdf';
$pdf_file_url = $pdf_file_base_url.$slash.$user.$pdf;

$cmd = 'C://xampp//htdocs//assessment//wkhtmltopdf//bin//wkhtmltopdf --page-height 193.14583333 --page-width 157.42708333 --javascript-delay 3000 --
cookie PHPSESSID np6btqg4lvr02k62us9pbcrote http://127.0.0.1/assessment/testreport.html C://xampp//htdocs//assessment//work7.pdf';
exec($cmd);
echo $cmd;

Currently the command stored in $cmd variable is the one using which I am able to generate report from terminal. (Above variables are just those using which I was creating customised URL so currently they do not play any role)

Also It doesn't give any error just echoes my command.

php

html

pdf

cmd

wkhtmltopdf

0 Answers

Your Answer

Accepted video resources