如何在 Rails 中的 PDFKit 中使用 UTF-8?

发布于 2024-12-04 00:33:09 字数 75 浏览 2 评论 0原文

我在 Rails 应用程序中使用 PDFKit 来生成 PDF。问题是我的一些内容包含非 ASCII 字符。如何强制它使用 UTF-8?

I'm using PDFKit in my Rails app to generate PDF's. Problem is some of my content in contains non-ascii characters. How do I force it to use UTF-8?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ゃ人海孤独症 2024-12-11 00:33:10

通过将其添加到 html 头部来修复:

<meta http-equiv="Content-type" content="text/html; charset=utf-8" />

Fixed by adding this to in the html head:

<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
两个我 2024-12-11 00:33:10
You can write in PDFKIT configration.

 PDFKit.configure do |config|
        config.wkhtmltopdf = '/opt/wkhtmltopdf'
        config.default_options = {
          :encoding      => 'UTF-8'
          :page_size     => 'Letter',
          :margin_top    => '0.3in',          
          :margin_bottom => '0.1in',          
          :print_media_type => true                       
        }
 end
You can write in PDFKIT configration.

 PDFKit.configure do |config|
        config.wkhtmltopdf = '/opt/wkhtmltopdf'
        config.default_options = {
          :encoding      => 'UTF-8'
          :page_size     => 'Letter',
          :margin_top    => '0.3in',          
          :margin_bottom => '0.1in',          
          :print_media_type => true                       
        }
 end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文