I am creating a very basic HTML page that can be accessed off-line. The goal is that the user fills in a form in that HTML file and after pressing a (submit) button, the form entries are downloaded to the user's PC in PDF.
I have tried already to create something, but I cannot get further than a new window > print function, which creates a new browser screen, puts the data there and prompts the user to print it; then the user can save as PDF iso printing.
But I would like to have a button that saves the form as PDF so to not give the end user that hassle.
var mywindow = window.open('','PRINT','height=800,width=800');
mywindow.document.write("here all the text");
Related
I have a page with embedded PDF.
<object data="/files/documents/somepdf.pdf" type="application/pdf"></object>
The embedded PDF has a form that user can edit.
This PDF view has a button (top right save/print icon) that allows user to download edited document.
Question - is there a way to manually download or save edited PDF with JavaScript?
My goal is for user to be able to click on "Submit" button and it takes the filled out form and sends it to some API end point in my system.
Question - is there a way to manually download or save edited PDF with JavaScript?
That's a loaded question, As with ALL PDFs the Form has been downloaded into the users browser or external pdf viewer, so no your JavaScript cannot touch it, see the downloaded address at the top.
The other implied question is can the file be saved after edit by the user clicking the icon, and that answer is perhaps. See the Adobe banner when a user attempts to edit the restricted form.
Thus the user must print the form with handwritten entries and signature, then mail it using their choice of US snail mail or web mail provider.
It also depends very much on which Browser and form they are using since here the user Fred has printed some entries and thus can continue another time after going bowling
Note the forms layout has changed overtime. :-) and the wrong surname that needs re-edit later.
I have PDF form hosted on a local server
I created a web page where this form is embedded via iFrame
I have a submit button on that page said page
What I need to figure out:
If submitBtn is clicked > save the PDF with the user's changes to a
predetermined location on our network with a unique name (could be a
simple numeric iteration) > generate a link to that file for the user
to copy
If this possible? I'm very new to JS.
Thanks!
I have a link to a URL that returns a download PDF dialog box
It takes about 30 seconds to load so I would like to present some visual indication to the user that they've clicked the button and that the PDF has been requested.
As the PDF loads in a dialog box so it can be saved, the user isn't redirected to another URL in their browser. After they've clicked the save the PDF they remain on the same page.
Is there anything I can do with Javascript (or jQuery) to detect when the PDF has loaded and the dialog box has been presented? If so, then when I receive this event then I can hide the loading icon that I'd like to display when the link is first clicked.
I'm currently using PHP for retrieving data and the JavaScript print function for my inventory reports and my staff saves it in pdf form. This is the sample output:
Everything works perfectly but I have a security issue. I want my staff to not be able to open the pdf, thus securing it with a password.
Is there, by any chance, a way to do this? Like whenever they click a button, instead of the print dialog box (ctrl+ P) opening, it will directly open a save to dialog box and it will automatically have a password so that I can be the only one who can view and print it.
Or is there a PDF library for this?
Any help would be much appreciated.
Found a library and it works as expected.
http://www.html2pdf.fr/en/download
This is somewhat of a return to my 2012 question - Is it possible to fire a keypress event for an iframe that has been used to load a PDF file, I think I may have been mistaken accepting the answer there.
The current situation is this -
The document of the main page has an onkeypress event attached to it which will load a PDF into an object when the user scans a particular barcode.
The PDF is created using iTextSharp and has the open action set - writer.SetOpenAction(new PdfAction(PdfAction.PRINTDIALOG)) (writer is a PdfWriter).
So a user will scan the barcode which automatically loads a PDF file which opens it's print dialog. The user will then choose the printer and print the PDF. The problem comes when the user wants to scan the next unit they need to click somewhere within the html body (but outside of the PDF object) and then scan the barcode for the new PDF to be loaded.
I had a look at this and saw that it is possible to setup some kind of communication between the PDF plugin and the browser but is is possible to tell the plugin to surrender control to the browser/javascript
EDIT
Some extra background information -
I've tried using both objects and and iframes.
Using the debugger, if I type document.activeElement.id gives the ID of an element an appropriate element however (in the case of text inputs) any key presses do not appear.
Using the debugger I can use blur the active element bring focus to another element even change the value of an input but no user input is seen by the HTML/javascript when the user types/scans.
This is a legacy application runs in Internet Explorer compatibility mode.
Just to sum up - I want to scan a barcode which will open a PDF (already done) which opens it's print dialog automatically (already done) the user prints the PDF and then without any further human interaction with the page (i.e. the user does not need to use the mouse or keyboard after clicking the print button in the print dialog) the user should be able to scan another barcode which will open a new PDF.
Rather than render the PDF inside an iframe/object, why not take advantage of modern HTML5 and Mozilla's hard work and render it using https://github.com/mozilla/pdf.js/ - it is a fully HTML5/javascript PDF renderer and does not require any plugins.
There is a nice online demo at http://mozilla.github.io/pdf.js/web/viewer.html
Then you would be on the same page with JavaScript all the way down and could avoid having to pass focus/events etc between the two environments, so you could catch events anywhere on the page easily enough.