pdf-forms
pdf-forms copied to clipboard
Fill Form Output as Temp File?
I'm using this gem for filling PDF forms running on Render (similar to Heroku). Due to how the environment works, I can't write files to disk.
Is there anyway to have the output file be a file in memory to then upload to S3? Whether or not the gem supports it, is there a way to do this with the API as is?
Do this:
template = 'template.pdf'
pdftk = PdfForms.new('/usr/local/bin/pdftk')
temp_output_file = Tempfile.new('temp_output.pdf')
final_output_file = Tempfile.new('final_output.pdf')
stamp_path = Rails.root.join('public', 'leadguard_stamp.pdf')
pdftk.fill_form template, temp_output_file.path, data = {}, flatten: true
pdftk.multistamp temp_output_file.path, stamp_path, final_output_file.path