yyn0210 / alivepdf

Automatically exported from code.google.com/p/alivepdf
0 stars 0 forks source link

Rotating multiple EPS files stacks the rotation with every instance #289

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Adding multiple EPS files (myPDF.addEPSImage();) on one page 
(myPDF.addPage();)
2.
3.

What is the expected output? What do you see instead?
// This is an exmaple how to add EPS files in Flash IDE. FlexSDK libs are 
required for this to work.
import org.alivepdf.pdf.PDF;
import org.alivepdf.layout.Orientation;
import org.alivepdf.layout.Size;
import org.alivepdf.layout.Unit;
import org.alivepdf.display.Display;
import org.alivepdf.saving.Method;
import flash.utils.ByteArray;

// Embed the .eps file into the swf (the only way to do this in Flash IDE is to 
add FlexSDK libs beforehand).
[Embed(source="test.eps", mimeType="application/octet-stream")]
var testSource:Class;
var testEps:ByteArray = new testSource() as ByteArray;

var myPDF:PDF = new PDF(Orientation.LANDSCAPE,Unit.MM,Size.LETTER);
myPDF.setDisplayMode( Display.REAL );
myPDF.addPage();

for (var i:uint = 0; i < 4; i++) {
    myPDF.rotate(10*i, 0, 0);
    myPDF.addEPSImage(testEps);
}
myPDF.save(Method.REMOTE, "http://www.yz.pl/bohner/work/pdf/pdf.php", 
"generated.pdf" );
//
If you run this code, you should get a generated .pdf in your browser looking 
like the attached pdf. The problem is that the rotation stacks when iterating 
through the loop (like the transformMatrix is not reseting). The lines have 
wrong rotations. Instead of:
i:0-> 10*0 = 0; Line1.rotation = 0; (this one is correctly rotated)
i:1-> 10*1 = 0; Line1.rotation = 10; (this one also)
i:2-> 10*2 = 0; Line1.rotation = 20; (this one is actually rotated by 10+20=30 
degrees)
i:3-> 10*3 = 0; Line1.rotation = 30; (and this is actually rotated by: 
10+20+30=60 degrees;

The problem doesn't show up if I add the each EPS on a sepperate page (by 
adding: myPDF.addPage(); in the for(){} loop). But that is not what I want!

What version of the product are you using? On what operating system?
1.5, W7

Please provide any additional information below.
Please help, what am I doing wrong?

Original issue reported on code.google.com by enstr...@gmail.com on 3 Dec 2010 at 1:55

Attachments: