1

I'm working on getting PDF handling to work correctly with our app. Essentially the steps we're doing are:

  1. Render selected PDF form and pre-populate some form fields from server data
  2. User edits remaining PDF form-fields in browser
  3. User edited PDF is posted to the server as a temp file
  4. 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

Upload file in iFrame

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

Community
  • 1
  • 1
Matt H
  • 710
  • 1
  • 7
  • 10
  • 1
    Not looking to be contrarian here but why does the user need to edit a PDF in the first place? Why not just create a html form which is tied to record in rails and create a PDF when it is finished. Seems a heck of a lot easier that dealing with the cross browser issues and potential headaches. – max Jan 13 '17 at 23:37
  • Yeah that would be ideal but unfortunately a no go. We're in healthcare where the user has to fill out and print the PDF for the patient to take to the lab/imaging location. There's a requirement to keep the PDF data in case the user needs to re-send the requisition, see what was ordered previously etc. There are also PDFs that users have used for 10+ years and are used to - from a marketing perspective we're hooped if we can't use these "familiar forms" for our users. – Matt H Jan 14 '17 at 00:01
  • @MattH, This doesn't sound like a constricting requirement. New PDF data can still be created using a web form (it can be designed to look the same as those old PDF forms). Maybe old PDF data shouldn't be editable? – Myst Feb 02 '17 at 01:09
  • So I ended up changing gears and working on other features and then came back to this - I actually ended up going this route - thanks for the suggestion! For anyone else struggling with PDFs - we ended up using a JAVA framework from IDRSoultions and then rendered HTML and saved the fields as a serialized column in our DB. There's issues with mobile responsiveness but it's the cleanest solution we could find thus far. – Matt H Jul 06 '17 at 01:13

0 Answers0