Malformed input RTF for the ScroogeXHTML convert method may cause unexpected errors, exceptions, or empty output documents. If you need to see and verify the RTF code which is actually sent to the convert() method, you may add this code just before the conversion:


The RTF will be written to a new file in the current directory. Please note: the code will replace an existing file with the same name.

Full example code

package com.scroogexhtml.examples;

import com.scroogexhtml.ScroogeXHTML;

import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;

public class Test {

    public static void main(String[] args) throws IOException {

        String rtf = "{\\rtf1 ... }";

        // create a converter instance
        ScroogeXHTML scrooge = new ScroogeXHTML();

        // configure conversion options


        // convert RTF and write HTML to file
        scrooge.convert(rtf, new File("example.html"));

File content of example.rtf

{\rtf1 ...}

File content of example.html

<!DOCTYPE html>
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Untitled document</title>
    <meta content="ScroogeXHTML for the Java(tm) platform 8.0" name="generator">

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.