The following ColdFusion code produces the image below.
Negative Font Size Example
<cfset img = ImageNew("", 200, 100)>
<cfset attr = { font="Arial", style="bold", size="-20" }>
<cfset ImageDrawText(img, "Transform Me", 190, 10, attr)>
<cfimage action="writeToBrowser" source="#img#">

The one code gotcha is the x coordinate. Since the text is rotated 180 degrees, the x coordinate is now relative to the right hand side. So if the desired x position is 10, you must use x = ImageGetWidth(img)-10 instead of x = 10.
Now I have not seen this documented anywhere. So I would use ImageRotateDrawingAxis instead. But it was still an interesting find ;)
Update: I corrected a typo in example/function name.
ImageRotateDrawingAxis
<cfset img = ImageNew("", 200, 100)>
<cfset ImageRotateDrawingAxis(img, 180, 100, 10)>
<cfset attr = { font="Arial", style="bold", size="20" }>
<cfset ImageDrawText(img, "Transform Me", 10, 10, attr)>
<cfimage action="writeToBrowser" source="#img#">
You have a great blog here! I've been using iText for a couple years in a java environment. Over the past few weeks I've been doing a CF project that required a little iText work, and your blog has been invaluable!!
ReplyDeleteI have a question for you. Have you tackled extending PdfPageEventHelper in CF?
@Lemonhead,
ReplyDeleteThanks. I am very glad the CF examples were helpful :)
No, I have not. But you have piqued my curiosity. What are you trying to do with page events?
I use it to create page headers and footers.
ReplyDeleteBruno has a tutorial at http://itextdocs.lowagie.com/tutorial/directcontent/pageevents/index.php
There is an example on the right hand side showing how to use the onEndPage to create headers and footers.
Yes, I was trying something similar right before I saw your comment. The example I created seems to work so far. I will post in a few .. for posterity ;)
ReplyDelete@Lemonhead,
ReplyDeleteHere is the link Using iText's PdfPageEventHelper with ColdFusion.