gpt4 book ai didi

wicked-pdf - 如何使用 wicked-pdf 保存 pdf 并将其作为 html 检查

转载 作者:行者123 更新时间:2023-12-04 17:48:30 27 4
gpt4 key购买 nike

我正在创建一个 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 的 url,在末尾添加一个 ?debug

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

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

关于wicked-pdf - 如何使用 wicked-pdf 保存 pdf 并将其作为 html 检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47056082/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com