Open GoogleCodeExporter opened 9 years ago
Here is how I did to correct it in my app:
// for all children
for (var i:int = 0; i < num; i++) {
cur = MyImage(paper.getElementAt(i));
// work with percentages as my custom component has nearly the same
// dimensions as an A4 page
px = cur.x / paperW; // x
py = cur.y / paperH; // y
pw = cur.width * cur.scaleX / paperW; // width
ph = cur.height * cur.scaleY / paperH; // height
// keep an eye on the rotation (rad)
teta = cur.rotation * 0.01745329251994329576923690768489; // Pi / 180;
cos = Math.cos(teta);
sin = Math.sin(teta);
// rotate the page (degree)
pdf.rotate(cur.rotation, 0, 0);
// coords on the non-rotated page
tmpX = px * pageW;
tmpY = py * pageH;
// in the rotated one
finalX = cos * tmpX + sin * tmpY;
finalY = -sin * tmpX + cos * tmpY;
// add the object with no rotation
pdf.addImageStream(cur.byteArray, ColorSpace.DEVICE_RGB, null, finalX, finalY, pw * pageW, ph * pageH, 0);
// return to the normal page
pdf.rotate(-cur.rotation, 0, 0);
}
I would have like to do it directly into the source code, but I have no time
for that.
I hope it will help someone to correct it!
attached: an output. There are stills some imperfections, but i think that they
are due to percentages and scales of my component (maybe not a perfect scaled
A4 page)!
Original comment by delamare...@yahoo.fr
on 10 Aug 2010 at 11:40
Attachments:
I tried this and It works, tnx. Do you know how I could change the
transformation point of the image so it rotates it from middle?
Original comment by radu.fl...@gmail.com
on 19 Sep 2012 at 7:04
Sorry, it has been a long time since I didn't use AS3...
However, I think that I computed my rotations myself, then did the
transformations in order to have my values for the uppon left corner... but not
really sure... (and I do not have access to this project anymore...)
Original comment by delamare...@yahoo.fr
on 12 Oct 2012 at 3:25
Original issue reported on code.google.com by
delamare...@yahoo.fr
on 6 Aug 2010 at 10:03Attachments: