Convert RTF to text

Introduction

This example shows how to use the rtf.lua module to convert an RTF file to plain text. The module contains an rtfToTxt() function that takes an RTF document, and strips out all the formatting and non-text objects to produce plain text.

If you have any questions please contact us at support@interfaceware.com.

Using the Code [top]

  • Import the Convert RTF to text channel from the Builtin: Iguana Files repository
  • Experiment with the code to find out how it works
  • Then add the module to your Translator project
  • Copy the require statement from the channel and add it at the top of your script
    Note: This module uses require to return a single function
  • Adapt the code to your own requirements
  • Use the rtfToTxt() function to convert an rtf file to plain text
  • Interactive scripting help is included for this module

This is the github code for the main module:

How it works [top]

Converting from RTF with this module is very straightforward, you simply read in the file and then convert it to plant text using the rtfToTxt() function. This function parses the RTF and strips out all the formatting and non-text objects to produce a plain text version.

More information [top]

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.