Skip to content

Instantly share code, notes, and snippets.

@joaopfsilva
Created March 3, 2023 07:57
Show Gist options
  • Save joaopfsilva/22fb8ced2e187838e80f43f086ff4520 to your computer and use it in GitHub Desktop.
Save joaopfsilva/22fb8ced2e187838e80f43f086ff4520 to your computer and use it in GitHub Desktop.
# require gem wicked-pdf
# create a pdf from a string
pdf = WickedPdf.new.pdf_from_string('<hI>Hi Ruby! I am WickedPdf</h1>')
# save the pdf file
File. open(save_path, 'w') do |file| file << pdf end
# if you want to return a pdf from controller
pdf = WickedPdf.new.pdf_from_string('<h1>Hi Ruby! I am WickedPdf Gem</h1>')
send_data pdf, filename: 'filename.pdf'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment