PrintJob sent to the printer although I never called send()

Go To


I have to do some printing in as3, obviously with flash.printing.PrintJob but I have a problem with it.

I have to validate that the settings set by the user in the printing dialog showed by PrintJob.start() match some stored in the database, and there is no way to get that info other than calling PrintJob.start().

If the page settings are invalid, I never call neither addPage() nor send(), but after some seconds (15 aprox) a blank document is printed.

Any idea? How can I cancel a PrintJob? In AIR there is a PrintJob.terminate() but I'm targeting flash.

Thank you!

2012-04-04 19:14
by alcuadrado
This blank page... it might be a stupid question but, are you clicking "ok" on the print dialogue that is coming up or cancel - NoName 2012-04-05 03:25
I am unable to reproduce your issue. Weather I click "OK" or "cancel", and weather I explicitly free/delete the print job in the VM or not, as long as I do not send any pages to the job it times out after a few seconds and does not print anything. It could be a printer-driver specific issue we're dealing with in which case no amount of AS3 code in the universe is going to solve your problem - NoName 2012-04-05 03:29
@Ascension Systems: I click OK, when I press cancel it works properly. I'll test in in a few different OS's and with different drivers. I hope it's a driver bug : - alcuadrado 2012-04-05 05:47
Moreover, I'm developing under linux. And flash player for linux developers doesn't seem to have cared much about printing on this platform; it doesn't even uses the native printing dialog and replaces it with a much limited one - alcuadrado 2012-04-05 05:48
That is most likely the issue then. Adobe basically doesn't care about linux and it's sad. They dropped AIR for linux support as well - NoName 2012-04-05 06:02


Im a little puzzled what your actually trying to do, but cant you do it like this? (from printjob docs, the start function example)

var myPrintJob:PrintJob = new PrintJob();
if(myPrintJob.start()) {
// addPage() and send() statements here

This way you can check the settings, if you dont send() it really shouldnt print. (are you sure you dont have send somewhere in a old spot in your code??) A possible fix (though not the best, it should work) is to force your printjob to reset if its settings dont match your preferences, like so;

myPrintJob = new PrintJob();

If the above doesnt help, please supply snippets and more details. Good luck!

2012-11-13 10:38
by suicidal.banana
I don't have that code at hand. By I found many places on the internet where it's said that there is a maximum time from start() to send(), and if it's exceeded the printjob would be sent anyway. It sounds crazy, almost unbelievable, but sadly it's true - alcuadrado 2012-11-15 00:24