I am looking for a simple C++ library for tokenizing and parsing RTF (Rich Text Format) files. I am planning to edit them with Qt's QTextEdit.
More the Formatting preserved the better -- but actually I am planning to use Bold and Italics only.
In perl I would use RTF::Tokenizer.
It would be nice if the module had some sort of interface for writing also, but I am able to brute force that with a template and some regular expressions.
Many Linux distributions include an office suite like LibreOffice that can open RTF files. If yours doesn't, you can install it through the command line or go to https://www.libreoffice.org/ to download the package directly. Also, most online word processors can open RTF files.
OpenRTF is a Java library for creating and editing RTF (Rich Text Format) files with a LGPL and MPL open source license. We welcome contributions from other developers.
RTF file is a cross-platform document format that stands for "rich text format." These documents can save additional information about text styles, fonts, images and formatting while normal text files save only plain text. Most word processing applications can save and open these types of documents.
The primary advantage of using RTF is that it is a cross-platform format. This means that you can open and edit RTF files on any word processor that supports the format.
I helped writing the RTF import export filter in KOffice. You can have a look at the code at https://cgit.kde.org/koffice.git/tree/filters/kword/rtf. The code is modular and it depends only on Qt.
A quick SourceForge search suggests librtf. It hasn't been developed in a while, but is listed as stable and is under the LGPL. I don't know whether it will support what you need, but I always suggest searching SourceForge for libraries.
You can ask the #koffice
guys on irc.freenode.org
over irc. Their program kword
is able to open RTF files, and is indeed also written in Qt. I'm sure they would be glad to tell you about how they do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With