1
votes

I know there's similar question on this forum but I've tried the ideas posted and they didn't work.

Basically we're trying to print a movieclip that contains graphics drawn by the user. We have a rectangle that serves as the canvas, and some of the drawing may be outside of this canvas. What we're trying to do is to print just what is in the canvas, which does not start at (0,0). The canvas also needs to be resized before printing to fit properly on the paper.

We were wondering if anyone has a solution to this? We've tried a lot of different things but things are always either cut off or sized wrong, or even stretched improperly.

Here's our super messy code!

    function startPrint(evnt: Event) {
printJob = new PrintJob();
var xNumber:Number = allGraphic.x; //saving the original x-value of the movieclip
var yNumber:Number = allGraphic.y; //saving y
var wNumber:Number = allGraphic.width; //saving width
var hNumber:Number = allGraphic.height; //saving height
var rect:Rectangle = new Rectangle (0,0,0,0); //printArea

var sucess = printJob.start();

if (sucess) {
if (printJob.orientation == PrintJobOrientation.LANDSCAPE) {
//allGraphic.rotation = 90;
rect.x = 115;
rect.y = 107;
rect.width = 792;
rect.height = 576;
allGraphic.width = 792;
allGraphic.height = 576;
} //end if (landscape)
             else {
rect.x = 110; //x coor of the printArea rectangle
rect.y = 85; //y coor
rect.width = 875; //width of printArea
rect.height = 475; // height of printArea
allGraphic.width = allGraphic.width *(576/wNumber); //scale the movieclip width (with the drawing)
allGraphic.height = allGraphic.height * (396/hNumber); // height scaling    
}//end else

printJob.addPage (allGraphic, rect);
}//end

 if success

//reset allGraphic back to original size
allGraphic.x = xNumber;
allGraphic.y = yNumber;
allGraphic.width = wNumber;
allGraphic.height = hNumber;
}
1

1 Answers

1
votes

The problem comes with using allGraphic.width. This is the complete width of the drawing area, including the negative and positives overlaps. You should also use scaleX and scaleY instead of setting a width and height for the scaling (Going back is only a call to scaleX = scaleY = 1).

I would advise to use the fixed dimensions of the canvas where the user can draw for your scale calculations. Also you can apply a mask with the size of your canvas to "cut" the overlapping drawings.