Quantcast

what is the proper way to use setTextMatrix when you really mean it?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

what is the proper way to use setTextMatrix when you really mean it?

iamchris

I have a chicken-and-the-egg type problem. I won't know how large an artifact
will be until I apply the transformation. I also won't know how to translate
the artifact to keep it within the clipping area of the template until it is
transformed. I'm almost there, but I need a nudge on how to get the proper
transformation.


//with an active Document and PdfContentByte


BaseFont fontArial = BaseFont.createFont("c:\\windows\\fonts\\arial.ttf",
"winansi", BaseFont.NOT_EMBEDDED);

float fontSize = 24;

AffineTransform at = AffineTransform.getRotateInstance(Math.PI/-4);
double [] mx = new double[6];
at.getMatrix(mx);

String textValue = "Rotation";

Rectangle.Double r = new
Rectangle.Double(0,0,(double)fontArial.getWidthPoint(textValue,
fontSize),(double)fontArial.getAscentPoint(textValue, fontSize));

Shape s = at.createTransformedShape(r);

PdfTemplate t =
contentByte.createTemplate(s.getBounds().width,s.getBounds().height);

t.beginText();
t.setColorFill(Color.black);
t.setFontAndSize(fontArial, fontSize);
t.setTextMatrix(float)mx[0], (float)mx[1], (float)mx[2], (float)mx[3],
(float)mx[4], (float)mx[5]);
t.showText(textValue);
t.endText();



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Loading...