2

I have an image of 2490x3510 pixels (300dpi A4) and I need to print it from flash-as3. By the look of it Printjob / options does not have a DPI setting or value ( thanks adobe :-/ ).

So does anyone know how print at 300 dpi straight from as3?

Note: I do need to print straight from as3. I already have an option to output to PDF @ 300dpi but I also want to allow the users to print straight away from flash.

Many Thanks.

5 Answers 5

4

it appears that flash.printing.PrintJobOptions.pixelsPerInch is AIR only and that if you're not using AIR then you are limited to the settings of the user's printer.

3

You can set any image resolution for printing in web application. You just do it before the PrintJob. Here is the way that works for me. After you download your image with Loader (at whatever resolution you want), set the variables for PrintJob.

        var btm:Bitmap = Bitmap(yourLoader.content);
        var btmData:BitmapData = btm.bitmapData;
        var matrix:Matrix = new Matrix();
        matrix.scale(612/btmData.width, 791/btmData.height); // '612' and '791' ensure that the image would fit standard page
        yourImagePrintSprite.graphics.beginBitmapFill(btmData, matrix, false);
        yourImagePrintSprite.graphics.lineStyle(1,0x000000, 0); // this rectangle (frame) serves as canvas for the BitmapFill; without it the image is not rendered.
        yourImagePrintSprite.graphics.drawRect(0, 0, 612, 791); 
        yourImageSprite.graphics.endFill();

Naturally, the higher the resolution - the better the print, but at the expense of bigger file size, so try different resolutions to find which minimal gives you acceptable results.

HTH, Igor Borodin

1
  • Surely this does not work? Since the printer will STILL only put 72 dots per inch?
    – WORMSS
    Sep 16, 2011 at 8:20
2

Seems the best thing you can do is to ask your users to make sure they check "shrink to page" option unless you're using AIR.

1

My own answer after lots of research and wasted hours/days:

AS3 Printjob is useless, it will sometimes produce the right DPI, sometimes it will not, it all depends on your printer settings, OS and browser. (Thanks Adobe for making my life a nightmare).

Now, you can also use FlexPrintJob, add your image as an element/child (source 300dpi), warn user that they need to set 300dpi on their 'printer settings' then it all works (Win + MacOS tested) :-)

I'm very disappointed at Adobe, they should just scrap PrintJob and start all over again.

Hope this helps (well at least for flex).

2
0

had the same problem. this one helped me a lot http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7cc6.html

quote from link "If you want to scale a Sprite object before you print it, set the scale properties (see Manipulating size and scaling objects) before calling the PrintJob.addPage() method, and set them back to their original values after printing. The scale of a Sprite object has no relation to the printArea property. In other words, if you specify a print area that is 50 pixels by 50 pixels, 2500 pixels are printed. If you scale the Sprite object, the same 2500 pixels are printed, but the Sprite object is printed at the scaled size."

in other words - you should use printJob.pageHeight and printJob.pageWidth and scale your Sprite according to those values before printJob.addPage call

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.