wicked_pdf font size too large in production

前端 未结 1 1612
难免孤独
难免孤独 2021-01-14 20:08

I am experiencing an issue where the font sizing for rendered PDFs is larger in production. Everything looks great on the PDF generated in development.

相关标签:
1条回答
  • 2021-01-14 20:45

    wkhtmltopdf can (and will) use system fonts to render content through its headless wekbkit browser.

    So your issue is really an issue of differing environments in development and production.

    If you have some control over your server, you might try installing freetype and fontconfig packages to get extra fonts on your server, or serving your fonts in your stylesheets as OTF files like this:

    # in application.css.erb
    @font-face {
      font-family: 'OpenSansRegular';
      src: url('<%= font_url('OpenSans.otf') %>');
      font-weight: normal;
      font-style: normal;
    }
    

    and telling the stylesheet to use that:

    body {
      font-family: 'OpenSansRegular';
      font-size: 13px;
    }
    

    If you don't have the font in OTF, here's a service to convert them.

    0 讨论(0)
提交回复
热议问题