How to fill a PDF field in the client-side (Javascript) - javascript

I need to create a application that needs to get information from the user using HTML text fields and fill-it to PDF fields. The fill-able PDF can be obtained from the server. The data filled in by the user cannot be submitted to the server (Sensitive information / legal problems). I need a way in which the JavaScript can take the information filled by the user, and fill it to the PDF, and make it available for the user to print/download.
(Initially, I tried to to just have HTML+PRINTCSS and avoid using a PDF, but then I had the issue of headers added by browsers to HTML that is printed. I don't want the worry the user to check his browser print settings - as most of them are computer illiterate)

I don't think this is doable via JavaScript alone. Some PDF readers do support JS, but many do not or allow the user to toggle it, and even then the PDF wouldn't have access to variables in the browser window. You'd be better off pre-filling the fields serverside. PHP in particular has robust PDF handling available out of the box.
You could, for instance, let the user fill in the form online - the "Print" button could use AJAX to submit the form to the server, and point the window at the resulting PDF download link. You could also simply submit the form without JavaScript, and let the server handle the redirection by setting the header.

Related

How to generate a pre-filled fillable PDF, change its content and parse the content

Could you please try to direct me which way should I be aiming in order to achieve the following high level requirement related to creating a fillable PDF for a user. The user can open this PDF, change some content, save the PDF, send it back to us via email and our system will parse the content and upload it to a database.
basic steps:
- the user clicks on a web button and the system behind this online web application sends an email to the user with a PDF document having all details from the user's saved application, e.g. full name, postcode, dob, answers to some questions (tickboxes), free text comments area
- the user opens this PDF, changes some details e.g. updates text in the comments area, unticks some check boxes, changes post code
- the user saves the changes and sends the PDF back to us.
- the system reads the PDF, parses the content and updates the data in a database.
Is the above possible? If so, please try to advise which technology can be used.
Thank you.
As mentioned in the other message, why send the filled PDF back? (well, unless you need a digitally signed version for your records).
Instead use the Submit function of PDF/Acrobat, which submits just the data. This is possible (among other ways) using HTML POST, and therefore working as if the data were sent by a HTML form. Updating the database should not be a big deal anymore in this case.
If you have to insist on sending back a filled form, there are AFAIK utilities which can extract the form data, and then, again, updating the database should not be difficult.
I don't really understand why you want to email a PDF for a user to fill out and then try to parse it in the first place? Why not just make some sort of web app that prints nicely for this?
If you really need a PDF, you might want to design your form in TeX and use something like this example.

dynamic scraping in nativescript? need to scrape page, with ability to click html button

do any package exist/ or process exist in native-script, for scraping dynamic content, means ability to click HTML button?
or
do i need to switch to cordova, for this ability?
From what I understand from your question (and subsequent comments) you want to (in a NativeScript app):
Load a website
Select a value in two select boxes
Press the submit button
The big question here is what happens when you press the submit button. Most probably this will result in a POST/PATCH being sent to a server.
The way of solving this would be:
Use the HTTP Module of NativeScript to download the web page.
Use Cheerio (or just plain regular expressions) to get the data needed to render the two select boxes and the URI to where to post the form.
Based on the data from (2) create and populate the two select boxes in NativeScript and save the POST uri somewhere.
Create an "on-submit" function which, based on the select boxes, creates the payload in the format the server wants it and then use HTTP Module again to post it to the URI.
To see the network traffic going on between the client (your browser) and the server, just open up the Networks Panel of your web browser, e.g. for Chrome or Firefox.
Looking at the network data should get tell you where to POST the data and how the payload should look like.
This can, of course, also be seen by looking at the code of the webpage.

Save state of view of page in grails

I have a page that is generated from a bunch of grails templates being rendered, with javascript widgets and stuff, that specify parameters for a search engine we are developing. The problem is, if someone clicks on a person returned in the search results and it takes them to another page, and then they hit the browser back button, the search parameters and dynamically created widgets and previous search results are all gone.
I dont really want to have to programmatically re-build the page based on the search parameters (which I can save as a session variable), and I would then have to re-run the search query again to get the results back. is there a way to save a page just as it was created?
Thanks
Popup a javascript window with information about that person instead of taking them to another page. In the worst case set the target of the person link to _new and that will force open a new browser window/tab.
At some place the search parameters have to be saved. Either on server or client side. On the server side you only have the options session or flash scope.
On the client side you could store those values in a cookie. This needs some bits of javascript.
However theoretically the browser will keep manually changed form field-values out of the box. He is identifying the form fields by its name/id. It should not be necessary to do any programmatically things, except if you are loading some parts of the page via AJAX. Maybe you can doublecheck, that the input fields have static name/id pairs or you have some meta/cache/html settings, which prohibit such mechanism (double check, that your form does not have autocomplete="off" setting set. This will prevent the browser to refill your form fields.
Grails itself does not offer things like you need out-of-the-box (and I do not know if other frameworks have - maybe except for Seam, which has a concept of conversation scope; but even this feature will not work out-of-the-box if the user uses the browser back button). The easiest way is to make your search page some kind of cacheable (for the browser, by settings HTTP-headers or meta tags), so that the browser is not trying to reload the page from the server again, if the user presses the browser back button. And double check the autocomplete="off" setting.

How to Submit PDF through email

We have a complex form that we created as a PDF. We want users to be able fill out the PDF and then either print it out and mail it in or click a Submit button and have it emailed to the client. What's the best way to do this?
I understand that we can attach javascript to the Submit button on the form. I'm thinking we could use Javascript to submit the form to the website and then write a REST type page that would handle emailing the PDF to the appropriate place. We are using ASP.NET/DotNetNuke on the backend of the site.
Dave,
You have a few options on this but a lot of it is going to be depending on how you want the user to handle input.
If you want the user to fill the ACTUAL PDF themselves, then you have a lot less control. But it can submit to a location and go from there, but saving it as a modified filled PDF requires either licensing for the document, OR for the users to have the full version of acrobat.
Another option is for you to build an input form for the user, then fill the PDF and commit the information, then either send them the file if they want to print or e-mail it off yourself.
I've done both in the past for previous clients/jobs. Feel free to ping me directly with a bit more detail if this doesn't help.
Edit - More detail based on comment
In this situation you have a few options.
Actually it looks like you can get to part of this now via the PDF create process - http://help.adobe.com/en_US/Acrobat/9.0/Standard/WS58a04a822e3e50102bd615109794195ff-7e0d.w.html
From a server side sending you have a few options. They can save it and upload it, which isn't best.
You can have a form post action, this will submit their answers to your server, you could then plug them into a PDF, save it, then forward it on
In the end it will depend on the true workflow.
Have you considered this SaaS? http://www.pdfescape.com/what/publishing/

How to edit PDFs in Javascript?

Based on my Google and stackoverflow search I'm guessing there are no library for this purpose.
The goal is: store some blank forms on my server. Then present these to the user, who edits the form in the browser with Javascript and submits the form back to the server.
The client wants to reuse parts of an old system (the forms) in which users would download an editable PDF, edit it, and email it back to a secretary. Our users aren't very computer savvy and many don't realize they need to email the forms back, assuming instead the forms somehow get submitted when they save their local changes (or something).
I haven't seen the forms yet, so I cannot assess the viability of an alternative.
I don't know of any Javascript libraries but you can use the FDF/XFDF files to do something like this. The idea is that you basically link your PDF file to an external FDF or XFDF (XML version) file. When the PDF is downloaded, so is the associated FDF/XFDF file. You place form fields on the PDF (which it sounds like already exist). They fill that information in and (if you add a button to the PDF form) click on the button which basically does a POST back to the server with these fields.
At that point you can save them to a database, merge them with a PDF, etc.
BTW - the XFDF/FDF files aren't really necessary to just fill in a form. You would only need them if you want to be able to display a PDF that has form fields and to fill those form fields in automatically. If you are always displaying a blank PDF for them to fill in you can get away with just adding a button which posts back to the server.
How about editing the PDF forms to add a submit button?
http://help.adobe.com/en_US/Acrobat/8.0/Professional/help.html?content=WS3593E0A4-C5E2-4cde-A09E-2A984346DDD2.html

Categories