Hi,

   Anyone any ideas about this one??

   Glen

Glen Pike wrote:
Hi

   I am having problems printing a scaled image using the printjob class.

tracing reports that my image has scaled, but it never prints scaled...

I have tried setting either the width / height or scale properties of the image and the image container, but nothing seems to work. Can anyone spot any "deliberate" (ahem) mistakes??

As a test, I put this on the stage - the image is scaled on stage when setting width / height or scale.

   Here is some code (printedImage is declared in mxml).

   public function printPages():void {
               var pj:PrintJob = new PrintJob();
               var pagesToPrint:int = 0;
               var options:PrintJobOptions = new PrintJobOptions();
               options.printAsBitmap = true;

               if(pj.start()) {
                                     //what's the orientation?
                   if(PrintJobOrientation.LANDSCAPE == pj.orientation) {
                       printedImg.rotation = -90;
                   }
//scale the width / height... is this affected by rotation??
                   var w:int = pj.pageWidth;
                   var h:int = pj.pageHeight;
var printWidth:int = printedImg.width;
                   var printHeight:int = printedImg.height;
                                     var origWidth:int = printWidth;
                   var origHeight:int = printHeight;
//If we are printing on twoPages we only want to scale the image to fit half on one page.
                   if(true == twoPages) {
printWidth = Math.ceil(Number(printWidth) / 2); }
                                     var pScaleX:Number = w / printWidth;
                   var pScaleY:Number = h / printHeight;
                   //
trace("w " + w + " h " + h + " printW " + printWidth + " printH " + printHeight + " pScaleX " + pScaleX + " pScaleY " + pScaleY);
                   if(pScaleX < pScaleY) {
/*printedImg.width = Math.floor(pScaleX * printedImg.width); printedImg.height = Math.floor(pScaleX * printedImg.height);*/
                       printedImg.scaleX = pScaleX;
                       printedImg.scaleY = pScaleX;
                   } else {
/*printedImg.width = Math.floor(pScaleY * printedImg.width); printedImg.height = Math.floor(pScaleY * printedImg.height);*/
                       printedImg.scaleX = pScaleY;
                       printedImg.scaleY = pScaleY;
                   }
trace("will print w " + printedImg.width + " h " + printedImg.height + " scale " + printedImg.scaleX + "," + printedImg.scaleY);
                   try
                   {
var rect:Rectangle = new Rectangle(0, 0, (this.width / 2), this.height);
                                                 if(true == twoPages) {
                           pj.addPage(printedImg, rect, options);
                       } else {
                           rect.width = printedImg.width;
                           pj.addPage(printedImg, rect, options);
                       }
                       pagesToPrint++;
                       if(true == twoPages) {
                           rect.x = rect.width = (printedImg.width / 2);
                           pj.addPage(printedImg, rect, options);
                           pagesToPrint++;
                       }
                   }
                   catch (error:Error)
                   {
                       trace("printJob error " + error.message);
                   }
                   if(0 < pagesToPrint) {
                       pj.send();                      }
                   printedImg.width = origWidth;
                   printedImg.height = origHeight;
                                 } else {
                   trace("print job cancelled");
               }
           }

--

Glen Pike
01326 218440
www.glenpike.co.uk <http://www.glenpike.co.uk>

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to