I'm using the PrintJob class in AS3 to print a multipage list. There is a little graphic header, my company logo in the footer and then just a long text list. It varies from 2 to 6 or so pages.
Everything seems to be working, but it seems to take an awful long time to get all the pages out. I'm wondering if anybody has any ideas of where to look? Or is it just always slow?
Here is the code I'm using:
private function doPrint(a:Array) {
var pj:PrintJob=new PrintJob();
if (pj.start()) {
var orgScale:Number=a[0].scaleX;
var count:Number=0;
for (var i=0; i<a.length; i++) {
a[i].width=pj.pageWidth;
a[i].scaleY=a[i].scaleX;
pj.addPage(a[i]);
count++;
}
if (count>0) {
pj.send();
}
}
pj=null;
a[0].scaleX=a[0].scaleY=orgScale;
}
The array is an array of the various movieclips that make up the pages.
The code looks sound. How complex are the pages? You might get a speed bump yet sacrifice text crispness a pinch if you convert your clips to bitmaps and print those instead of the vectors. It's more data to send to the printer but easier to process inside Flash which would likely be the cause of slow printing. Of course your machines speed makes a big difference too..
Thanks. The pages are pretty simple except for a lot of text. I had tried printing it as a bitmap but that didn't seem to help. Do you mean using the addPage printJobOptions parameter? Or do you mean drawing them to a bitmapdata kind of thing?
The slowness doesn't seem to be in the Flash processing part. The print dialog comes up quickly and then while I watch my print monitor I'll see all the pages showing up -- it'll say "printing 1/6." It just seems to take forever to spool to the printer. Much longer than if I print from something like Word or my browser, and those pages are usually far more complex that what I'm sending from Flash.
I don't expect that it will be super quick, but it just seems like there is something going on. And I'm not even sure where to look.
Check your processes and watch the CPU usage during spooling. See if Flash is continuously using CPU as it does it. If Flash is utilizing <5% processor it sounds like it's just a lot of transfer. If it's uing more than 5% CPU it's probably flash itself translating the pages to a suitable print job.
Flash.exe is bouncing around between 1 and 3% while waiting for the pages to print. So I'm pretty sure the problem is something about how our network deals with the kind of pages that Flash produces.
In fact in the print monitor I see an error status while the document is being sent to the printer. The monitor didn't tell me any more about the error, but the pages came out with:
ERROR: syntaxerror
OFENDING COMMAND: binary token, type=133
STACK:
164
350
166
347
Anybody have any ideas?
North America
Europe, Middle East and Africa
Asia Pacific