Come posso modificare l'orientamento del mio file pdf
che viene generato con Wkhtmltopdf
. Invoco in PHP come segue:Utilizzare wkhtmltopdf per impostare l'orientamento orizzontale
$file = fopen("tmp/html/pdfTmp_$numRand.html",
"w") or exit("Unable to open file!");
fwrite($file, $html);
fclose($file);
exec("..\library\wkhtmltopdf\wkhtmltopdf " .
"tmp/html/pdfTmp_$numRand.html tmp/pdf/pdfTmp_$numRand.pdf");
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment; filename=".$nom."_".$residence.".pdf");
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize("tmp/pdf/pdfTmp_$numRand.pdf"));
ob_clean();
flush();
readfile("tmp/pdf/pdfTmp_$numRand.pdf");
$html
contiene tutta la mia pagina in html, e questo apre un file temporaneo.
Questo genera un .pdf
in orientamento verticale. So che wkhtlktopdf ha un'opzione -O landscape
per cambiare orientamento, ma non so dove e come posso scrivere questo nel mio script PHP. Sto usando Windows 7.
Passare i due flag '-O landscape' subito dopo il comando wkhtmltopdf, ad esempio:' wkhtmltopdf -O landscape foobar.html foobar.pdf' –