0

Trying to convert the HTML content into image using ImgKit and wkhtmltoimage. Image is converted successfully but facing the issues with fonts (Font Awesome).

The image is not look as it as HTML content.

Attaching 2 images one which have HTML content (HTML-CONTENT.png) and other one is converted to image (HTML-Converted-To-IMAGE.png). You can see the difference in fonts between the 2 images.

enter image description here

enter image description here

Could you please anyone suggest me on this, how can I achieve exact html conversion into image.

Thanks for the help in advance.

Ankush Kataria
  • 323
  • 4
  • 13

1 Answers1

0
kit = IMGKit.new(html)
kit.stylesheets << '/path/to/css/file.css'

I think you shoud make sure that the stylesheets used in image are the same in html.

孙悟空
  • 1,215
  • 1
  • 11
  • 26
  • Thank for your response. But I am converting HTML from Web URL into Image. It already have all the CSS, Fonts. The issue is when converting to image, some of the fonts are not loaded. Thanks – Ankush Kataria May 23 '16 at 06:06
  • Maybe CSS paths aren't absolute path? try to save font-awesome in local server and call it with absolute path. – 孙悟空 May 23 '16 at 08:59