28 Replies Latest reply on May 22, 2013 8:02 AM by kglad

    Check Printer status- Print

    DK1120 Level 1

      Hi All

       

      would anyone beable to direct me in the right direction when it comes to printing from flash?

       

      Is there some script that would beable to check the status of a printer before it prints and give a pop up message saying something like 'Printing...Please wait' then a pop up saying 'Printing Complete' that kind of thing?

       

      Any thoughts and help would be great appreciated

       

      Many thanks

        • 1. Re: Check Printer status- Print
          kglad Adobe Community Professional & MVP

          the start() method of the printjob class returns a boolean indicating if a printer is available but there's no way to check when printing is complete.

          1 person found this helpful
          • 2. Re: Check Printer status- Print
            DK1120 Level 1


            hey there

             

            thanks for the reply, this is what I found in relation to printjob, but again, don't quite understand how it would have indicated if printing is finished. So you are saying it is not possible to detect when the printing is finished


            printBtn.onRelease = function()
            {
            var my_pj = new PrintJob();
            var myResult = my_pj.start();
            if(myResult){
            myResult = my_pj.addPage (0, {xMin : 0, xMax: 400, yMin: 0,
            yMax: 400});
            myResult = my_pj.addPage ("printArea", {xMin : 0, xMax: 400,
            yMin: 400, yMax: 800},{printAsBitmap:true}, 1);
            myResult = my_pj.addPage (1, null,{printAsBitmap:false}, 2);
            myResult = my_pj.addPage (0);
            my_pj.send();
            }
            delete my_pj;
            }

            • 3. Re: Check Printer status- Print
              DK1120 Level 1

              or

              • 4. Re: Check Printer status- Print
                DK1120 Level 1

                this


                myButton.onRelease = function() {
                var my_pj = new PrintJob();
                var myResult = my_pj.start();
                if (myResult) {
                myResult = my_pj.addPage(0, {xMin:0, xMax:924, yMin:0, yMax:719});
                my_pj.send();
                }
                delete my_pj;
                };

                • 5. Re: Check Printer status- Print
                  DK1120 Level 1

                  what would you suggest as the best way to show(if possible) that the status of the printer is ready, when using the start() in other words...create an MC and pop up some text at the time the Boolean returns a true or false?

                   

                  Question:
                  How would flash determine whether it is true or false...when using start()?

                  • 6. Re: Check Printer status- Print
                    kglad Adobe Community Professional & MVP

                    you can use:

                     

                     

                    var my_pj:PrintJob;

                    var tl:MovieClip=this;

                     

                    myButton.onRelease = function() {
                    my_pj = new PrintJob();

                    tl.createTextField("tf", 1, 100, 100, 300, 100);

                    var myResult:Boolean = my_pj.start();

                    if (myResult) {

                    tl.tf.text="Printing... Please wait";

                    myResult = my_pj.addPage(0, {xMin:0, xMax:924, yMin:0, yMax:719});
                    my_pj.send();
                    } else {

                    tl.tf.text="Please turn on your printer".

                    }
                    delete my_pj;
                    };

                    1 person found this helpful
                    • 7. Re: Check Printer status- Print
                      DK1120 Level 1

                      thanks for that, will try that and let you know how I get on...thank you

                      • 8. Re: Check Printer status- Print
                        DK1120 Level 1

                        I'm getting an error;

                         

                        Scene=Scene 1, layer=action, frame=1, Line 72 Expected a field name after '.' operator.

                         

                        this is my script;

                         

                        stop();

                        setProperty("_root.mc_flag", _visible, false);
                        setProperty("_root.mc_flame", _visible, true);
                        setProperty("_root.mc_rim1", _visible, false);
                        setProperty("_root.mc_rim2", _visible, false);
                        setProperty("_root.mc_rim3", _visible, true);

                        flamebtn.onRelease = function() {
                        setProperty("_root.mc_flag", _visible, false);
                        setProperty("_root.mc_flame", _visible, true);

                        };

                        flagBtn.onRelease = function() {
                        setProperty("_root.mc_flame", _visible, false);
                        setProperty("_root.mc_flag", _visible, true);

                        };

                        btn_rim1.onRelease = function() {
                        setProperty("_root.mc_rim1", _visible, true);
                        setProperty("_root.mc_rim2", _visible, false);
                        setProperty("_root.mc_rim3", _visible, false);

                        };

                        btn_rim2.onRelease = function() {
                        setProperty("_root.mc_rim1", _visible, false);
                        setProperty("_root.mc_rim2", _visible, true);
                        setProperty("_root.mc_rim3", _visible, false);

                        };

                        btn_rim3.onRelease = function() {
                        setProperty("_root.mc_rim1", _visible, false);
                        setProperty("_root.mc_rim2", _visible, false);
                        setProperty("_root.mc_rim3", _visible, true);

                        };


                        //########PRINT JOB##########
                        var my_pj:PrintJob;
                        var tl:MovieClip=this;

                         

                        myButton.onRelease = function() {
                        my_pj = new PrintJob();
                        tl.createTextField("tf", 1, 100, 100, 300, 100);
                        var myResult:Boolean = my_pj.start();
                        if (myResult) {
                        tl.tf.text="Printing... Please wait";
                        myResult = my_pj.addPage(0, {xMin:0, xMax:924, yMin:0, yMax:719});
                        my_pj.send();
                        } else {
                        tl.tf.text="Please turn on your printer".
                        }
                        delete my_pj;
                        };

                        ##############################

                        • 9. Re: Check Printer status- Print
                          kglad Adobe Community Professional & MVP

                          this line:

                           

                          tl.tf.text="Please turn on your printer".

                           

                          should be:

                           

                          tl.tf.text="Please turn on your printer";

                          1 person found this helpful
                          • 10. Re: Check Printer status- Print
                            DK1120 Level 1

                            Hey there

                             

                            Sorry for the late reply, yes that was the line and yes that works great now thank you!

                             

                            Another question I have is, is there a way to stop the default print window appearing as this now gets in the way of the flash movie?

                             

                            Many thanks for your help!

                            • 11. Re: Check Printer status- Print
                              DK1120 Level 1

                              ...also the print request that I would like to print is this,

                               

                               

                              http://127.0.0.1/print.cgi?panel_id=123&display_id=1&voucher_skin_id=1&voucher_id=12345

                               

                              so, when you click print, it prints this link request, it's a bitmap image.

                               

                              is there away to incorprate this into the printjob?

                              • 12. Re: Check Printer status- Print
                                DK1120 Level 1

                                would it somehow have to be set up as a URL link?

                                • 13. Re: Check Printer status- Print
                                  kglad Adobe Community Professional & MVP

                                  no, you can't prevent the user's printer window from appearing unless you're creating an air or projector app.

                                   

                                  to print a bitmap image, you should load it first.  you can then print it.

                                  • 14. Re: Check Printer status- Print
                                    DK1120 Level 1

                                    is there another way to print an API without using printjob, or is printjob the only method of printing?

                                    • 15. Re: Check Printer status- Print
                                      kglad Adobe Community Professional & MVP

                                      it's the only way of printing using actionscript.

                                       

                                      you could use javascript too but would require you app be open in a browser window and it would trigger the print dialog box to open too.

                                       

                                      what kind of app is this?  air, projector or web-page?

                                      • 16. Re: Check Printer status- Print
                                        DK1120 Level 1

                                        its a web API, this is the URL that when in browser triggers printer http://127.0.0.1/print.cgi?panel_id=123&display_id=1&voucher_skin_id=1&voucher_id=12345

                                         

                                        did originally have in in an xml file, loading into flash, but with cgi can't trigger the URL action

                                        • 17. Re: Check Printer status- Print
                                          DK1120 Level 1

                                          web-page

                                          • 18. Re: Check Printer status- Print
                                            kglad Adobe Community Professional & MVP

                                            there's no way to avoid the print dialogue, then.

                                            1 person found this helpful
                                            • 19. Re: Check Printer status- Print
                                              DK1120 Level 1

                                              no way of triggering a URL in what we have already?

                                              • 20. Re: Check Printer status- Print
                                                kglad Adobe Community Professional & MVP

                                                you can use getURL to call that url but you may trigger a security sandbox issue and i'm not sure how that local program could possibly work with a web-based app.

                                                 

                                                if that's just for testing and you're going to have a server-side executable when you deploy your app, you can use loadVars to call that executable.

                                                • 21. Re: Check Printer status- Print
                                                  DK1120 Level 1

                                                  within the existing code we already have, within printjob?

                                                  • 22. Re: Check Printer status- Print
                                                    kglad Adobe Community Professional & MVP

                                                    no.

                                                     

                                                    if you want to print something from flash, use printjob and whatever you want to print should be in flash.

                                                    • 23. Re: Check Printer status- Print
                                                      DK1120 Level 1

                                                      I think that's one of the issues as what I'm printing is not in flash but an external file....mmmh!

                                                      • 24. Re: Check Printer status- Print
                                                        kglad Adobe Community Professional & MVP

                                                        load the external file's contents and then print the contents.

                                                        • 25. Re: Check Printer status- Print
                                                          DK1120 Level 1

                                                          would like to try an keep from loading images into flash the, can I post you some of the script I have for when loading in the xml and printing from the URL Link?

                                                          • 26. Re: Check Printer status- Print
                                                            kglad Adobe Community Professional & MVP

                                                            yes, as long as it's not too lengthy.

                                                            • 27. Re: Check Printer status- Print
                                                              DK1120 Level 1

                                                              great, I can just send you little bits

                                                              ;

                                                               

                                                              this is in the flash for loading in the xml nodes;

                                                              .......................................................................................... .........................

                                                              function loadEventsXML () {
                                                              var xml : XML = new XML ();
                                                              xml.ignoreWhite = true;
                                                              xml.onLoad = function (success : Boolean) {
                                                                if (success) {
                                                                 var nodes = xml.firstChild; // get nodes

                                                                 var i = 0
                                                                 for (var n = 0; n < nodes.childNodes[0].childNodes.length; n ++) {
                                                                  eNodes = nodes.childNodes[0].childNodes[n]
                                                                  trace(eNodes.nodeName)
                                                                  if (eNodes.nodeName == "item") {
                                                                   if (eNodes.childNodes[0].nodeName == "title") {
                                                                    getTitle = eNodes.childNodes[0].childNodes[0].nodeValue
                                                                    getOrder = eOrder.childNodes[1].childNodes[0].nodeValue
                                                                    getImage = eNodes.childNodes[2].childNodes[0].nodeValue
                                                                    getShortDesc = eNodes.childNodes[3].childNodes[0].nodeValue
                                                                    getDescription = eNodes.childNodes[4].childNodes[0].nodeValue
                                                                    getDate = eNodes.childNodes[5].childNodes[0].nodeValue
                                                                    getRemoveDate = eNodes.childNodes[6].childNodes[0].nodeValue
                                                                    getPrintingVP = eNodes.childNodes[7].childNodes[0].nodeValue //VP PRINTING ADDED
                                                                    eventsList.push({ID: n, eTitle: getTitle, eOrder: getOrder, eImage: getImage, eShortDesc: getShortDesc, eDescription: getDescription, ePDate: getDate, eDate: getDate, eRemoveDate: getRemoveDate, ePrintingVP: getPrintingVP})
                                                                   }
                                                                  }
                                                                 }
                                                                 eventsList.sortOn(["eRemoveDate"])
                                                                 gotoAndPlay("showVouchers")
                                                                }  else {
                                                                 trace ("ERROR : XML DID NOT LOAD");
                                                                 gotoAndPlay("failEvents")
                                                                }

                                                              }


                                                              xml.load ("vouchers.xml");

                                                              }

                                                              ..............................................................................

                                                               

                                                              THIS IS THE XML:

                                                              ...................................................................................

                                                              <item>

                                                                    <title><![CDATA[Voucher 2]]></title>

                                                                    <order>8</order>

                                                                    <image><![CDATA[vp02.jpg]]></image>

                                                                 <shortdesc><![CDATA[Collect your Voucher and get 20% of]]></shortdesc>

                                                                    <description><![CDATA[Collect your Voucher and get 20% off Eye Wear when you print this voucher and take into a boots store.

                                                                 <img src="IMAGES/vouchers/voucher01.jpg">

                                                                 <b></b>

                                                                 <b></b>

                                                                 20% OFF EYE WEAR.

                                                                 <a href="http://127.0.0.1/print.cgi?panel_id=123&display_id=1&voucher_skin_id=1&voucher_id=12345" target="">CLICK HERE TO PRINT</a>]]></description>

                                                                    <pubDate><![CDATA[21th Apr 2013 to 3rd May 2013]]></pubDate>

                                                                 <removeDate>20140430</removeDate><!-- NOTE: IS REMOVED ON THIS DATE -->

                                                                  </item>

                                                               

                                                              .......................................................

                                                               

                                                              So this loads in the xml and I have the link to print within the xml nodes here

                                                              <a href="http://127.0.0.1/print.cgi?panel_id=123&display_id=1&voucher_skin_id=1&voucher_id=12345" target="">CLICK HERE TO PRINT</a>]]></

                                                               

                                                              I'm thinking the way to maybe do it is use similar script from the printjob(but not using printjob) script where it pulls up a message(MOVIECLIP) if the printer is not turned on.

                                                               

                                                              does this make any sense?

                                                              • 28. Re: Check Printer status- Print
                                                                kglad Adobe Community Professional & MVP

                                                                as long as users know how to print whatever they're looking at after clicking your link, that should work.