如何使用邪恶的pdf保存pdf并将其检查为html



我正在创建一个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 ?

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

之后,尝试访问pdf的网址,并在末尾添加一个?debug

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

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

最新更新