Utilisez wkhtmltopdf pour définir l'orientation paysage
Comment je peux changer l'orientation de mon pdf
fichier qui est généré avec Wkhtmltopdf
. J'invoque en PHP comme suit:
$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
contient l'ensemble de ma page en html, et cela ouvre un fichier temporaire.
Cela génère un .pdf
en orientation portrait. Je sais wkhtlktopdf a une option -O landscape
à changer d'orientation, mais je ne sais pas où et comment je peux écrire ceci dans mon script PHP. Je suis sous Windows 7.
source d'informationauteur Daykeras
Vous devez vous connecter pour publier un commentaire.
Option
-O landscape
fera l'affaire.Juste chage
à quelque chose comme
Je pense que c'est aussi intéressant de mentionner ici:
J'ai eu du mal avec ce trop mais j'avais mis --orientation "Paysage" et a également créé l' --page-hauteur 210mm "et --page-largeur 297 mm'
Mon pdf est tenu à venir dans le Portrait, c'est très frustrant.
J'étais trop explicite. En prenant sur la page de la hauteur et de la page options de largeur résolu le problème pour moi