【问题标题】:How can I save a pdf with wicked-pdf and inspect it as an html如何使用 wicked-pdf 保存 pdf 并将其检查为 html
【发布时间】:2017-11-01 13:31:40
【问题描述】:

我正在创建一个 pdf 文件并保存它。

 pdf=WickedPdf.new.pdf_from_string(
  html,
  header: {content: html_header},
  footer: {content: html_footer},
  page_height: '11in',
  page_width: '8.5in',
  show_as_html: true
)

save_path = Rails.root.join('example.pdf')
File.open(save_path, 'wb') do |file|
  file << pdf
end
return

是否可以用 chrome 作为 html 打开它并检查 css ?

【问题讨论】:

  • 为什么您认为可以将 PDF 作为 HTML 进行检查?
  • 因为 wicked pdf 支持调试模式,您可以在其中将其预览为 html。
  • 所以,这在文档中有所介绍。 github.com/mileszs/wicked_pdf#debugging 什么不起作用?
  • 部分覆盖,但没有明确的例子。
  • 我试过了,但是没有用。

标签: wicked-pdf


【解决方案1】:

您应该将您的 show_as_html: true 更改为 show_as_html: params.key?('debug')

然后,尝试访问pdf的url,在末尾添加?debug

例如:http://localhost:3000/controller/file.pdf?debug

现在您可以像往常一样检查 HTML。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-04
    • 2014-05-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多