Last Updated: 07/20/2011 10:38:00 AM

Creating Vertical Text Image

Creating Vertical Text Image

A co-worker had a need of creating PDF using CFDocument that included vertical text.  We could not find any styling that would make text vertical that CFDocument supported.  Style: writing-mode:tb-rl didn't work.  It seemed the best solution was to use CFIMAGE to dynamically convert text passed in as an argument and turn it into an image of vertical text and then embed that image in the CFDOCUMENT for conversion into a PDF.

 

The trickiest part for me was figuring out how to make CFIMAGE write vertically. The key is line 23: imageRotateDrawingAxis. It turns the image the number of degrees you supply. Then any drawing functions called after will follow along this line:

 

Code is also avaialble to download on Github Gist: https://gist.github.com/1094983

VertText.CFC image