邪恶的PDF字体大小

Wicked PDF font size

我有一个 Rails 3 应用程序,它使用 gem 'wicked_pdf'.

创建 PDF

我有一个 HTML 页面在网上看起来不错。但是,转成pdf后字体太大了

这是我的控制器代码:

  def invoice_pdf
    @invoice = Invoice.find(params[:invoice_id])
    respond_to do |format|
      format.html # index.html.erb
      format.pdf do
        render pdf: "invoice.pdf",
               font_size: 8,
               disable_links: true,
               template: 'invoices/_invoice_pdf.html.erb'
      end
    end
  end

font_size: 8好像不行。我可以将它更改为任何值,pdf 文本看起来一样。

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

将此 css 添加到您的 html.erb 文件中。