Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wkhtmltopdf stylesheets

can anybody tell me how to include user-style-sheet ind wkhtlmtopdf v. 0.10?

I'm refering to a local file, but that doesn't effect my Pdf anyway.

switches += "--user-style-sheet \User\...\style.css "
like image 740
Flg Avatar asked Apr 25 '12 09:04

Flg


3 Answers

What about using a 'real' URL syntax with your switch? Something like

switches += "--user-style-sheet file:///User/.../style.css"
like image 66
Kurt Pfeifle Avatar answered Sep 29 '22 20:09

Kurt Pfeifle


Another option to using the argument is to inject the stylesheet programmatically before the PDF conversion happens. Perhaps by using a URL parameter that identifies if a page is being fed to wkhtmltopdf or by downloading the page, injecting the CSS reference and then regurgitating the page for wkhtmltopdf.

like image 26
Joel Peltonen Avatar answered Sep 29 '22 20:09

Joel Peltonen


In terminal

wkhtmltopdf -V
wkhtmltopdf 0.12.2.4

Command

 wkhtmltopdf --user-style-sheet yourcssfile.css yourhtmlfile.html outputfile.pdf
like image 20
muthukumar selvaraj Avatar answered Sep 29 '22 20:09

muthukumar selvaraj