0

I want to use wkhtmltopdf to convert an html file to pdf. I was trying with various options with the wkhtmltopdf but its not giving the proper output what i wanted. I want to have the pdf with the same format as looking by saving it using control+p The url is http://raindrops.in/subhashini/view/524e5aa14251df44518b4567

Please help me out how to use it.

Rohit Singhal
  • 429
  • 1
  • 3
  • 17

1 Answers1

2

If the problem is that you don't have the layout you're looking for, it is probably because you don't use wkhtmltopdf with the correct settings as far as screen size, margins etc. is concerned.

Check the available options here http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf-0.9.9-doc.html

Check your own screen settings (width/height), and use them in wkhtmltopdf.

Pixou
  • 1,719
  • 13
  • 23
  • I have tried using width/height options, its giving correct result except the formattting of the text. I have seen some question, where people are worrying so the solution was to use truetype format in css. I used it but still its not taking the correct font, what the html is using. Please help me. – Rohit Singhal Jan 02 '14 at 13:44
  • which font is it ? it is possible that wkhtmltopdf has trouble rendering it. There are several issues with fonts as you can see here http://stackoverflow.com/questions/15746240/helvetica-font-not-working-in-wkhtmltopdf One solution would be to switch to google web font – Pixou Jan 02 '14 at 13:48
  • The font, I am using is LibreBaskerville for h2. Only for h2, it is not taking the desired font type. The problem is same what that link says but it is not solving my problem. Please tell me the correct solution so that i can add to my css directly and after converting that to pdf, it will give the correct output. – Rohit Singhal Jan 02 '14 at 13:58
  • LibreBaskerville is a google web font. So try the solution here http://blog.shahariaazam.com/use-google-web-fonts-for-wkhtmltopdf-tools/ – Pixou Jan 02 '14 at 14:09
  • I have already gone through this solution but I am not getting what is the encoded string(written after base64) and where to find it to add to my css – Rohit Singhal Jan 02 '14 at 14:15
  • not that difficult : download http://www.google.com/fonts/download?kit=4ozF6MzjnDLW7G0aKe2bkTqy0YPSWWIczvXDfclDmfg , unzip, use the .ttf file in the base64 encoder, get the String and replace it in the css code given by http://blog.shahariaazam.com/use-google-web-fonts-for-wkhtmltopdf-tools/ – Pixou Jan 02 '14 at 15:10
  • Now, I have tried this one too..but its not working and all the h2 texts are not coming.. I have followed each step given by the Shahariaazam. Can anyone tell me what to add exactly in my CSS? – Rohit Singhal Jan 03 '14 at 05:30