rtf-reader
Turns RTF bytes into events, plain text, or Markdown. This is the module most consumers start with.
Quick extract
import com.darkrockstudios.libs.rtfparserkmp.converter.extractPlainText
import com.darkrockstudios.libs.rtfparserkmp.converter.convertToMarkdown
val text: String = extractPlainText(rtfBytes)
val markdown: String = convertToMarkdown(rtfBytes)Content copied to clipboard
Drive the event stream
import com.darkrockstudios.libs.rtfparserkmp.parser.parseRtf
for (event in parseRtf(rtfBytes)) {
when (event) {
is RtfEvent.Text -> append(event.text)
else -> {}
}
}Content copied to clipboard
parseRtf has two forms: one returns a List<RtfEvent>, the other pushes to an RtfListener you supply. For full control over the input, instantiate StandardRtfParser and call parse with an RtfSource — a faithful, SAX-style port of RTFParserKit's Standard parser. Malformed input throws RtfParseException.