Skip navigation
Jfill
Currently Being Moderated

Load External PDF Content then automatically print via runtime.flash.printing.PrintJob

Aug 3, 2010 6:13 AM

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

 
Replies
  • Chris Campbell
    9,454 posts
    May 4, 2010
    Currently Being Moderated
    Aug 3, 2010 1:55 PM   in reply to Jfill

    Hi Jason,

    This sounds possible, check out my response on this thread for approaches that might work for you.

     

    Chris

     
    |
    Mark as:
  • Chris Campbell
    9,454 posts
    May 4, 2010
    Currently Being Moderated
    Aug 4, 2010 5:30 PM   in reply to Jfill

    Hi,

    Glad that helped!  For printing without the print dialog, take a look at the PrintJob's start2() method.

     

    Chris

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points