pdf-forms icon indicating copy to clipboard operation
pdf-forms copied to clipboard

Fill Form Output as Temp File?

Open noahmatisoff opened this issue 2 years ago • 1 comments

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?

noahmatisoff avatar Aug 04 '22 02:08 noahmatisoff

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

calebfaruki avatar Sep 15 '24 18:09 calebfaruki