Skip to main content
Inspiring
May 18, 2012
Question

Slow multi-page printing

  • May 18, 2012
  • 1 reply
  • 1532 views

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.width=pj.pageWidth;

               a.scaleY=a.scaleX;

               pj.addPage(a);

               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.

This topic has been closed for replies.

1 reply

sinious
Legend
May 18, 2012

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..

RothrockAuthor
Inspiring
May 19, 2012

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.

sinious
Legend
May 20, 2012

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.