ScroogeXHTML for Delphi 6.12 released

ScroogeXHTML for Delphi is a library which can convert a subset of the RTF standard to XHTML and HTML5. It is compatible with Delphi 2009+ and Free Pascal 3.0. Version 6.12 introduces support for space before and after paragraphs. It also fixes “mailto:” protocol hyperlinks.

As a special offer, every purchase of a Single Developer license now includes Server Deployment licenses for 2000 concurrent users – see blog article

Home page, API, Getting Started PDF and demo download:


ScroogeXHTML 7.0 preview: table conversion example

The online demo for ScroogeXHTML 7.0 (development snapshot) now contains improved support for RTF table conversion. Here is the screenshotof of a test conversion result:

Bildschirmfoto am 2017-05-20 um 19.55.55-fullpage

Some highlights are shown:

  • new: cell background color
  • new: paragraph background color
  • merged cells (since v6.2)
  • table row height (since v6.1)
  • left table margin (since v6.0)
  • cell width (since v6.0)

More table conversion improvements are still in development (planned for milestone two).

ScroogeXHTML 7.0 snapshot binary size is now ≈ 120 KB (up 15 KB since v6.3).


RTF hyperlink conversion with ScroogeXHTML (XPath based post processing)

ScroogeXHTML for the Java platform supports hyperlink conversion to HTML in two ways. Many RTF documents use special RTF keywords which include the hyperlink target as “invisible” text, so that the HTTP address was already available in the document. Other RTF documents however only use underlined and blue text, but no hidden HTTP link addresses. In this case, the conversion requires a different solution.

Earlier versions of ScroogeXHTML used a hard-coded solution for text-to-hyperlink conversion, which did not support advanced tweaks and manipulations of the result HTML.

Now, the next release of ScroogeXHTML provides an XPath based post processor class, as a starting point for customized blue/underlined hyperlink conversion.

One line of code is required to add the post processor class:

       .add(new ConvertUnderlinedToHyperlinks());

The post processor will locate all text elements which are underlined and blue, and turn it into a hyperlink.

With some custom code, the post processor may be adjusted to your special needs, for example it may use a dictionary (map) to assign specific URLs to the blue/underlined text.

Note: this is a breaking change, the next version will no longer have the property ConvertHyperlinksForBlueUnderlinedText.

Source code excerpt:

  public void postProcess(PostProcessEventObject e) {
    try {
      XPathFactory xpathFactory = XPathFactory.newInstance();

      String exp = String.format("//span[contains(@style, 'color:%s;') and contains(@style ,'text-decoration:underline;') ]", color);
      XPathExpression xpathExp = xpathFactory.newXPath().compile(exp);

      NodeList hyperlinkNodes = (NodeList) xpathExp.evaluate(e.getDocument(), XPathConstants.NODESET);

      // Iterate over all found nodes
      for (int i = 0; i < hyperlinkNodes.getLength(); i++) {
        Element linkNode = (Element) hyperlinkNodes.item(i);

        // remove the hyperlink style
        String style = linkNode.getAttribute("style");
        style = style.replace("color:" + color + ";", "");
        style = style.replace("text-decoration:underline;", "");
        if (style.isEmpty()) {
        } else {
          linkNode.setAttribute("style", style);

        // create anchor with href attribute
        Element anchor = e.getDocument().createElement("a");
        String linkText = linkNode.getTextContent();
        anchor.setAttribute("href", linkText);

        // insert the a element
        Node parent = linkNode.getParentNode();

        if (linkNode.getAttributes().getLength() == 0) {
        } else {
          parent.insertBefore(anchor, linkNode);
    } catch (XPathExpressionException ex) {
      LOGGER.error(ex.getMessage(), ex);

Server Deployment licenses included with ScroogeXHTML for Delphi

ScroogeXHTML for Delphi is a library which can convert a subset of the RTF standard to XHTML and HTML5 at high speed.

As a special offer, every new purchase of a a Single Developer license now includes Server Deployment licenses for 2000 concurrent users at no extra costs. Server Deployment licenses do not expire, and are valid for all applications built with the library.

ScroogeXHTML is also available for the Java platform.


Wingdings bullets workaround (XPath based post-processing)

Some RTF writers (such as WPTools) use the Wingdings font for bullet signs in unnumbered lists. Wingdings is not a web-safe font, so additional tweaking is required to transform a document generated by ScroogeXHTML to web-safe HTML5.

The library already includes post-processing classes, so we can build a workaround based on existing code and clean up the intermediate DOM.

A basic implementation is shown below. It iterates all nodes which carry a font-family:Wingdings style and does two things:

  • replace the ‘l’ character with a Unicode bullet sign
  • replace the ‘Wingdings’ font name with ‘serif’

Note: older versions of WPTools 7 emitted the font name as “WingDings” (with capital D) and used a “Ÿ” character instead of “l” for the bullet. The code example below has been simplified for newer WPTools versions for better readability.

public void postProcess(PostProcessEventObject e) {
  try {
    XPathFactory xpathFactory = XPathFactory.newInstance();
    // XPath to find Wingdings text nodes.
    XPathExpression xpathExp = xpathFactory.newXPath().compile(
       "//span[contains(@style, 'font-family:Wingdings')]");
    NodeList nodes = (NodeList) xpathExp
      .evaluate(e.getDocument(), XPathConstants.NODESET);

    for (int i = 0; i < nodes.getLength(); i++) {
      Element node = (Element) nodes.item(i);

      // replace the bullet
      String textContent = node.getTextContent();
      if ("l".equals(textContent)) {

      // replace the font name
      String style = node.getAttribute("style");
      style = style.replace("Wingdings", "serif");
      node.setAttribute("style", style);
  } catch (XPathExpressionException ex) {
      LOGGER.error(ex.getMessage(), ex);

Tiny RTF Viewer 2.7 using ScroogeXHTML RTF to HTML5 converter

Habarisoft released Tiny RTF Viewer 2.7 for Android™. This small viewer app converts RTF documents (which can be stored locally or accessed by choosing a hyperlink in a web browser) to HTML5, and displays them in the internal web browser.

Google play

For the internal conversion from Rich Text Format to HTML5, it uses ScroogeXHTML for the Java™ platform version 6.3. More information and an on-line demo of the converter library are available at


Android is a trademark of Google Inc. ♦ Google Play is a trademark of Google Inc.