I'm working on getting PDF handling to work correctly with our app. Essentially the steps we're doing are:
- Render selected PDF form and pre-populate some form fields from server data
- User edits remaining PDF form-fields in browser
- User edited PDF is posted to the server as a temp file
- We use PDFtk to extract the form data and save it to the database
We're stuck on step 3 - I'm unable to post the completed form back to the server using a regular html button. Once it's on the server it'll be easy to manipulate it.
The view looks something like this:
#_form.html.erb
<object data=<%= select_pdf_path(blank_pdf_id: params[:blank_pdf_id], employee_id: params[:employee_id]) %> type="application/pdf" id="filled-pdf"></object>
I imagine I might have to submit the edited document as a file upload, however, I'm not sure how to grab the edited file and upload it to the back end.
Some of the other solutions I have found require the post buttons to be placed within the PDF form. Unfortunately as we could have thousands of forms this wouldn't be a feasible option. It looks like there are third party options for PHP but nothing I can see for RoR.
Fill up and update an uploaded PDF form online and save it back to the server - Ruby on Rails
Embed PDF in a website, allow user to modify editable fields in PDF, and save back to the server
Edit pdf embedded in the browser and save the pdf directly to server