Velocity Templates in RTF
For most of this week, I've been developing Velocity templates for rendering resumes in HTML and RTF (Word). Thanks for Mathias once again for showing me this was possible. The HTML part has been pretty easy, but the RTF stuff has been a bear. Mostly because I want to hide/show different sections of a person's resume based on whether they've entered information or not. In order to do this, I first created a rough draft of the RTF template in Word and then I began hand editing it with a text editor (HomeSite and BBEdit). And if you look at the RTF syntax, it's pretty damn ugly. The main thing I'm struggling with now is showing hiding rows of a table based on whether data exists or now. In HTML - it's easy - you just put your #if statement before a <tr> and you can easily hide the row. In RTF - it seems like the number of rows/columns/borders, etc. is all defined at the beginning of the table - but I can't really read the syntax well enough to understand it.
Therefore, my question is - does anyone know RTF well enough to tell me how I can hide a row? Is there something in the beginning of the table definition I can modify with Velocity #if statements? For now, I'm simply putting "Not Specified" text in rows where no data exists.
Finally, how about some RTF syntax I've learned in this process:
{\f116\fs20 = Verdana 10pt Font The document must end with " }}" (no quotes) on the same line as the last bit of text Escape "\n" with "\\par " {\b\f116\fs24\cf17 = Bold, Verdana, 12pt, Ocean colored Font
How's that for a bunch of useless information! ;-)
Posted by jeje on March 11, 2004 at 06:03 PM MST #
I *do* like XML Resume and I do plan to support its DTD/Schema/Stylesheets in Struts Resume someday. However, for the time being, I'd rather deal with getting the database populated with user input and then displaying that information with Velocity templates. I figure it shouldn't be too hard to eventually manipulate that data into XML format.
I realize I could use an XML database, but I think my client would ever going to go for that. They've spent too much on DB2 and WebSphere to do something different. Besides, when's the last time you heard of an XML database DBA? ;-)
Posted by Matt Raible on March 11, 2004 at 06:20 PM MST #
Posted by Damien Bonvillain on March 11, 2004 at 11:01 PM MST #
- add an additional (empty) column
- delete everything from your target column, flag the cell as hidden
- enter the keyword which gets velocity parsed in your target column - be careful NOT to mark the cell
- delete the helper column if you like - otherwise flag it's cell as hidden
When initializing your keywords with \webhidden the whole row is hidden (your helper columns cell if you kept it, the cell of your target column AND the text within the target column) and effectivly ceases to exist.Posted by Joern Barthel on March 15, 2004 at 12:03 AM MST #