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 anonkeypress
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 aPdfWriter
).
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.