Blogs about Jazz

Blogs > Jazz Team Blog >

Handling RTF code in IBM Engineering Lifecycle Optimization – Publishing

For IBM Engineering Lifecycle Optimization – Publishing (PUB) to generate rich text, we need the rich text data in a format that PUB accepts. If you consider UseCase description or Class Description returned by IBM Engineering Systems Design Rhapsody (Rhapsody), it is in RTF format. The Rhapsody data source schema allows us to choose the ‘descriptionRTF’ attribute. However, documents generated from PUB using this attribute shows the RTF code instead of the formatted text.

In this article, you can find 2 approaches to handle RTF code in PUB so that the document generated will show the text with proper formatting and not the actual RTF code.

1. Include .rtf file dynamically

With this approach, the RTF code returned by Rhapsody is written into a temporary .rtf file. Echo command is used to write descriptionRTF to tmpDataFile.rtf file. The same can be done using Java code within a JavaScript Code element. This rtf file is included using an Include File element so that its content (formatted text) is added in the generated document.

Note: The execution of commands is disabled by default. You can enable command execution in PUB by setting the com.ibm.rational.rpe.enable_commands property to true in %rpe_home%\studio\rpe-studio.ini and %rpe_home%\launcher\rpe-launcher.ini.

2. Use macro that converts the RTF code into formatted text

Use Script Expression so that descriptionRTF (RTF code) is printed within #RTFStart# and #EndRTF# tags.

Run a post processing macro that looks for #RTFStart# and #EndRTF# tags in the document. The macro finds the RTF code within these tags, copies it to the clipboard, and then pastes the RTF string into the document. You can refer the link for the macro.

Subramanya Prasad Pilar
IBM Engineering Lifecycle Optimization – Publishing