Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I save a pdf with wicked-pdf and inspect it as an html

Tags:

wicked-pdf

I am creating a pdf file and saving it.

 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

Is it possible to open that with chrome as an html and inspect the css ?

like image 535
Petran Avatar asked Oct 29 '25 15:10

Petran


1 Answers

You should change your show_as_html: true to show_as_html: params.key?('debug')

After that, try to visit the url of pdf adding a ?debug at the end.

For example: http://localhost:3000/controller/file.pdf?debug

Now you can inspect the HTML as usual.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!