Trying to use Wicked PDF.
I have this code in the controller
def pdf
pdf = WickedPdf.new.pdf_from_string(
render_to_string(
pdf: 'filename.pdf',
template: '/pages/poa.html.slim',
layout: '/layouts/pdf'),
header: {
content: render_to_string({
template: '/pdfs/poa_header.html.slim',
layout: '/layouts/pdf'
})
})
save_path = [Rails.root, '/public/pdf/', 'filename.pdf'].join
File.open(save_path, 'wb') do |file | file << pdf
end
end
I am getting this error message when trying to execute the action above
RuntimeError (Failed to execute:
Error: "\xFE" from ASCII-8BIT to UTF-8):
I already tried to empty the content of templates and layout I am rendering but still got the error.
File
andTempfile
objects. – Cajolery