How to specify size when taking screenshot in wkhtmltoimage?

10.8k views Asked by At

This is my first time using wkhtmltoimage. I am trying to take screenshots of urls. But I need the images to be of width 1024 and height 768; is it possible? Currently it is giving me an image of width 1024 and height 431.

The command I am current using is

"C:/Program Files (x86)/wkhtmltopdf/wkhtmltoimage.exe  --width 1024 --height 768" http://www.google.com/ D:/example.jpg

but it is saying:

'"C:/Program Files (x86)/wkhtmltopdf/wkhtmltoimage.exe --width 1024 --height 768"' is not recognized as an internal or external command, operable program or batch file.

I am using quotations because I using Windows localserver.

3

There are 3 answers

1
Lokesh On BEST ANSWER

Try this,

C:\Program" "Files" ("x86")"\wkhtmltopdf\wkhtmltoimage.exe  --width 1024 --height 768 http://www.google.com/ D:\example.jpg

or

"C:\Program Files (x86)\wkhtmltopdf\wkhtmltoimage.exe"  --width 1024 --height 768 http://www.google.com/ D:\example.jpg

you need to combine single parameter as single string.

0
Joel Peltonen On

Try this

"C:\Program Files (x86)\wkhtmltopdf\wkhtmltoimage.exe" --width 1024 --height 768 http://www.google.com/ D:\example.jpg

You might need quotations around google and example too.

0
kmas On

You should add the path of your wkhtmltoimage.exe to your PATH environment variable.

Thus, you could call your wkhtmltoimage from everywhere just like that :

wkhtmltoimage --width 1024 --height 768 http://www.google.com D:\example.jpg
  1. Execute control sysdm.cpl
  2. Click on the Advanced system settings tab
  3. Then Environment variables
  4. Edit the Path system variable, and add the directory C:\Program Files (x86)\wkhtmltopdf to it.

Then restart your console, and execute your command.