Skip to content

Commit cd420e7

Browse files
committed
Update to 1.16.0
1 parent 3119eef commit cd420e7

File tree

2 files changed

+57
-57
lines changed

2 files changed

+57
-57
lines changed

README.md

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
RTF Parser Kit
2-
==============
3-
4-
I have often been frustrated by the lack of comprehensive support for working with RTF in Java, and the need to use RTF parsers which are incomplete and form part of larger projects whose libraries I don't want to import just to use the RTF parser. The RTF Parser Kit project is an attempt to address these points.
5-
6-
The idea is to provide a "kit" of components which can either be used "as-is", for example to extract plain text or HTML from an RTF file, or can be used as a component in a larger application which requires the capability to parse RTF documents.
7-
8-
What's currently included?
9-
--------------------------
10-
* Raw RTF Parser - parses RTF, sends events representing content to a listener. Performs minimal processing - you get the RTF commands and data exactly as they appear in the file.
11-
* Standard RTF Parser - parses RTF, sends events representing content to a listener. Handles character encoding, Unicode and so on, so you don't have to. This is probably the parser you want to use.
12-
* Text Converter - demonstrates very simple text extraction from an RTF file
13-
* RTF Dump - another demonstration, this time writing the RTF file contents as XML
14-
15-
Getting Started
16-
===============
17-
18-
To install the library, you can either download the latest JAR directly from the GitHub releases page,
19-
or you can add RTF Parser Kit as a dependency using Maven:
20-
21-
```xml
22-
<dependency>
23-
<groupId>com.github.joniles</groupId>
24-
<artifactId>rtfparserkit</artifactId>
25-
<version>1.12.0</version>
26-
</dependency>
27-
```
28-
29-
Once you have the library, you have a choice of two parsers to work with, the standard parser and the raw parser. The raw parser carries out minimal processing on the RTF, the standard parser handles character encodings, and translates commands which represent special characters into their Unicode equivalents. Most people will want to use the standard parser.
30-
31-
The parser is invoked like this:
32-
```java
33-
InputStream is = new FileInputStream("/path/to/my/file.rtf");
34-
IRtfSource source = new RtfStreamSource(is)
35-
IRtfParser parser = new StandardRtfParser();
36-
MyRtfListener listener = new MyRtfListener();
37-
parser.parse(source, listener);
38-
```
39-
You provide input to the parser via a class that implements the `IRtfSource` interface. Two implementations are provided for you, `RtfStreamSource`, for reading RTF from a stream, and `RtfStringSource` for reading RTF from a string.
40-
41-
The other thing you need to provide the parser with is a listener class. The listener class implements the `IRtfListener` listener interface. The interface consists of a set of methods which are called by the parser to inform you of when it encounters different parts of the docuent structure. The set of method, along with some comments describing their purpose can be seen [here](https://github.com/joniles/rtfparserkit/blob/master/RTF%20Parser%20Kit/src/com/rtfparserkit/parser/IRtfListener.java).
42-
43-
You don't need to implement all of the `IRtfListener` interface yourself, if you wish you can subclass `RtfListenerAdaptor` which provides empty methods for all of the `IRtfListener` methods. You can then just override the methods you are interested in.
44-
45-
An example text extractor is provided, you can invoke it like this:
46-
```java
47-
new StreamTextConverter().convert(new RtfStreamSource(inputStream), outputStream, "UTF-8");
48-
```
49-
This code reads an RTF file from the `inputStream` and writes the resulting text to the `outputStream` in the encoding specified by the last argument.
50-
51-
A second example text extractor is also provided, this one extracts text from the RTF file into a string:
52-
```java
53-
StringTextConverter converter = new StringTextConverter();
54-
converter.convert(new RtfStreamSource(inputStream));
55-
String extractedText = converter.getText();
56-
```
1+
RTF Parser Kit
2+
==============
3+
4+
I have often been frustrated by the lack of comprehensive support for working with RTF in Java, and the need to use RTF parsers which are incomplete and form part of larger projects whose libraries I don't want to import just to use the RTF parser. The RTF Parser Kit project is an attempt to address these points.
5+
6+
The idea is to provide a "kit" of components which can either be used "as-is", for example to extract plain text or HTML from an RTF file, or can be used as a component in a larger application which requires the capability to parse RTF documents.
7+
8+
What's currently included?
9+
--------------------------
10+
* Raw RTF Parser - parses RTF, sends events representing content to a listener. Performs minimal processing - you get the RTF commands and data exactly as they appear in the file.
11+
* Standard RTF Parser - parses RTF, sends events representing content to a listener. Handles character encoding, Unicode and so on, so you don't have to. This is probably the parser you want to use.
12+
* Text Converter - demonstrates very simple text extraction from an RTF file
13+
* RTF Dump - another demonstration, this time writing the RTF file contents as XML
14+
15+
Getting Started
16+
===============
17+
18+
To install the library, you can either download the latest JAR directly from the GitHub releases page,
19+
or you can add RTF Parser Kit as a dependency using Maven:
20+
21+
```xml
22+
<dependency>
23+
<groupId>com.github.joniles</groupId>
24+
<artifactId>rtfparserkit</artifactId>
25+
<version>1.16.0</version>
26+
</dependency>
27+
```
28+
29+
Once you have the library, you have a choice of two parsers to work with, the standard parser and the raw parser. The raw parser carries out minimal processing on the RTF, the standard parser handles character encodings, and translates commands which represent special characters into their Unicode equivalents. Most people will want to use the standard parser.
30+
31+
The parser is invoked like this:
32+
```java
33+
InputStream is = new FileInputStream("/path/to/my/file.rtf");
34+
IRtfSource source = new RtfStreamSource(is)
35+
IRtfParser parser = new StandardRtfParser();
36+
MyRtfListener listener = new MyRtfListener();
37+
parser.parse(source, listener);
38+
```
39+
You provide input to the parser via a class that implements the `IRtfSource` interface. Two implementations are provided for you, `RtfStreamSource`, for reading RTF from a stream, and `RtfStringSource` for reading RTF from a string.
40+
41+
The other thing you need to provide the parser with is a listener class. The listener class implements the `IRtfListener` listener interface. The interface consists of a set of methods which are called by the parser to inform you of when it encounters different parts of the docuent structure. The set of method, along with some comments describing their purpose can be seen [here](https://github.com/joniles/rtfparserkit/blob/master/RTF%20Parser%20Kit/src/com/rtfparserkit/parser/IRtfListener.java).
42+
43+
You don't need to implement all of the `IRtfListener` interface yourself, if you wish you can subclass `RtfListenerAdaptor` which provides empty methods for all of the `IRtfListener` methods. You can then just override the methods you are interested in.
44+
45+
An example text extractor is provided, you can invoke it like this:
46+
```java
47+
new StreamTextConverter().convert(new RtfStreamSource(inputStream), outputStream, "UTF-8");
48+
```
49+
This code reads an RTF file from the `inputStream` and writes the resulting text to the `outputStream` in the encoding specified by the last argument.
50+
51+
A second example text extractor is also provided, this one extracts text from the RTF file into a string:
52+
```java
53+
StringTextConverter converter = new StringTextConverter();
54+
converter.convert(new RtfStreamSource(inputStream));
55+
String extractedText = converter.getText();
56+
```

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.github.joniles</groupId>
66
<artifactId>rtfparserkit</artifactId>
7-
<version>1.15.0</version>
7+
<version>1.16.0</version>
88
<packaging>jar</packaging>
99

1010
<name>RTF Parser Kit</name>

0 commit comments

Comments
 (0)