I do not have much experience with AIR so I want to ensure what I am trying to archive is within reach with AIR. What I am trying to do is the following:
I will preface this by saying I am going to create an HTML/AJAX AIR app, not Flex.
The functionality that is in question is as follows:
1) I would like to call an external server to grab a PDF document.
2) Load that document into a hidden area ( I do not want to display it to the user ).
3) Once the PDF document is loaded, automatically send it to the default printer attached to the computer.
The complete flow of my application has 3 pages:
1) Welcome page.
2) Collect some data, the send to remote server for processing
3) Final thank you page - displaying a thank you message and loading the PDF into the hidden area and automatically printing it. (This is the core of what is in question)
Think of this kind of like a check in at the Airport, I just need the user to confirm something, then have the document (like boarding pass) printed while the thank you page is displayed.
Is this possible via AIR? I have been looking and think it *might* be possible by using something like:
To load the PDF:
if(HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK) { var htmlLoader:HTMLLoader = new HTMLLoader(); var url:URLRequest = new URLRequest(pathUrl); //URL to the file htmlLoader.width = windowWidth; //width of the content area htmlLoader.height = windowHeight; //height of the content area htmlLoader.load(url); //wrapping into UIComponent var holder:UIComponent = new UIComponent(); holder.addChild(htmlLoader); addChild(holder); //add it to any container }
Then perhaps use something like:
var pjob = new window.runtime.flash.printing.PrintJob; if ( pjob.start() ) { var poptions = new window.runtime.flash.printing.PrintJobOptions; poptions.printAsBitmap = true; try { pjob.addPage(window.htmlLoader, null, poptions); pjob.send(); } catch (err) { alert("exception: " + err); } } else { alert("PrintJob couldn't start"); }
The main thing I was not sure about is the window.htmlLoader above, is it possible to pass the hidden PDF content into that?
Thank you for your time and I look forward to hearing the comments.
Jason