0
votes

My requirement is I am generating PDF out of the pre-rendered HTML template. This template is a multi-lingual page and uses custom fonts from our clients.

Following approaches tried:

  • I used wicked_pdf (internally uses wkhtmltopdf-binary) gem to achieve this, but the issues I face are: font kerning arent proper as every other character get overlapped on other. The same font appears proper on actual PDF. I included all CSSes directly into the HEAD -> STYLE, tried various tricks by setting letter-spacing, etc. but nothing worked.

  • So, now using flying_ruby_saucer. Font kerning looks proper. But neither characters from Arabic OR HINDI is printed on PDF nor custom font is picked up. I have declared custom font as:

    @font-face {
      font-family: 'My Font';
      src: url('http://localhost:3000/assets/MyFont.ttf');
    }
    body{ font-family:"My Font"; }
    

But this doesnot work either as PDF generated shows default font family. Non-ascii characters arent printed too.

Could anyone please help me fixing this (include foreign characters as well as include custom fonts)?

Thanks.

1
Have you tried wicked_pdf gem? - Kanna
Yes, I have tried wicked_pdf, This isnt giving me the results I needed. Also I highlighted libraries in the question above. - Kavita Kanojiya

1 Answers

0
votes

I assume you have a problem with UTF-8 based fonts, you could use prawn gem because this gem actually supports UTF-8 encoding also l18n is supported.