*/
public static void main(String[] args) {
System.out.println("Demonstrates creating new, user-defined paragraph stylesheets");
try {
Document document = new Document();
RtfWriter2 writer = RtfWriter2.getInstance(document, new FileOutputStream("ExtendingStylesheets.rtf"));
// Create the new RtfParagraphStyle. The second parameter is the name of
// the RtfParagraphStyle that this style will inherit default properties from.
RtfParagraphStyle incorrectStyle = new RtfParagraphStyle("Incorrect", "Normal");
// Change the desired properties
incorrectStyle.setColor(Color.RED);
incorrectStyle.setStyle(Font.STRIKETHRU);
// Register the new paragraph stylesheet with the RtfWriter2.
writer.getDocumentSettings().registerParagraphStyle(incorrectStyle);
// Create a new RtfParagraphStyle that does not inherit from any other style.
RtfParagraphStyle correctStyle = new RtfParagraphStyle("Correct", "Arial",
12, Font.NORMAL, Color.GREEN);
// Register the new paragraph stylesheet with the RtfWriter2.
writer.getDocumentSettings().registerParagraphStyle(correctStyle);
// Change the default font name. This will propagate to the paragraph stylesheet
// that inherits, but not the other one.
RtfParagraphStyle.STYLE_NORMAL.setFontName("Times New Roman");