Hi Alf, i've found a workaround
I was trying to print a Canvas with Text components inside, the scaleX
and scaleY properties haven't had any effect on canvas output but was
ok for the Text components. So, doing some maths I've changed the
canvas width and height, then i changed the scaleX and scaleY of Text
using a relation between the final and the previous canvas size.
var print:FlexPrintJob = new FlexPrintJob();
//making the canvas bigger
var pixelPerMilimeter:Number = 2.8333333;
var originalWidth:Number = this.myCanvas.width;
var originalHeight:Number = this.myCanvas.height;
var finalWidthPx:Number = this.finalHeightOnMilimeters *
pixelPerMilimeter;
var finalHeightPx:Number = this.finalWidthOnMilimeters *
pixelPerMilimeter;
this.myCanvas.height = altoCartelPx;
this.myCanvas.width = anchoCartelPx;
var relation:Number = finalWidthPx / originalWidth;
//i've found some margin problems with my printer, you can ignore this
var xd:Number = 0;
var yd:Number = 0;
if(this.papel2.width > this.papel2.height){ //horizontal
xd = 1.621443962;//3 / 1,850202703;
yd = 1.621443962;//3 / 1,850202703;
} else {
xd = 3 / 1.850202703;
yd = 3 / 1.850202703;
}
//making the Text components bigger
var ch:Array = this.papel2.getChildren();
for(var i:Number=0; i < ch.length; i++){
var tmp:UIComponent = UIComponent(ch[i]);
if(tmp != null){
//again this is for margins problems
tmp.x = tmp.x - (xd * relation);
tmp.y = tmp.y - (yd * relation);
//scale
tmp.scaleX = relation;
tmp.scaleY = relation;
tmp.validateNow();
}
}
this.myCanvas.validateNow();
//well, at this point we are finally ready to print
if(print.start()){
print.addObject(this.myCanvas,FlexPrintJobScaleType.NONE);
print.send();
}
notice that i'm using no scale for printing
I hope this helps you,
Claudio
On 14 abr, 22:23, ALF <[email protected]> wrote:
> I'm having the same problem and am using PrintJob already.
> component.scaleX not having any effect on the output.
> Claudio have you found a solution?
>
> On Apr 11, 3:40 am, Flexing the brain <[email protected]> wrote:
>
> > Forscalinguse printJob and not flexprintJob... There is a small code
> > on my blog if you wish to use
>
> > flex-lcds.blogspot.com
>
> > On Apr 8, 5:56 pm, Claudio Corlatti <[email protected]> wrote:
>
> > > Hello everybody, i'm having some problems printing using the
> > > FlexPrintJob class.
> > > I'm trying here to scale a canvas object and thenprintit, in order
> > > to scale I'm using the scaleX and scaleY properties.
> > > The problem is that in the screen I see the canvas bigger, but, in the
> > > other hand, on printed version i didn't see any changes. I mean the
> > > canvas kept the original size ignoring the scale changes.
>
> > > Here is the code that i'm working on:
>
> > > //changing canvas scale
> > > this.myCanvas.scaleX = 1.85;
> > > this.myCanvas.scaleY = 1.85;
> > > this.myCanvas.setStyle("backgroundColor","#FFFFFF");
> > > this.myCanvas.validateNow();
> > > //print
> > > varprint:FlexPrintJob = new FlexPrintJob();
> > > if(print.start()){
> > > print.addObject(this.myCanvas,FlexPrintJobScaleType.NONE);
> > > print.send();
>
> > > }
>
> > > Could anyone help me? There are any limitations aboutscalingand
> > > printing that i should know?
>
> > > Thanks in advance
> > > Claudio
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---