Search in sources :

Example 1 with RtfDocument

use of com.lowagie.text.rtf.document.RtfDocument in project itext2 by albfernandez.

the class RtfDestinationInfo method handleCloseGroup.

/* (non-Javadoc)
	 * @see com.lowagie.text.rtf.direct.RtfDestination#handleGroupEnd()
	 */
public boolean handleCloseGroup() {
    if (this.text.length() > 0) {
        Document doc = this.rtfParser.getDocument();
        if (doc != null) {
            if (this.elementName.equals("author")) {
                doc.addAuthor(this.text);
            }
            if (this.elementName.equals("title")) {
                doc.addTitle(this.text);
            }
            if (this.elementName.equals("subject")) {
                doc.addSubject(this.text);
            }
        } else {
            RtfDocument rtfDoc = this.rtfParser.getRtfDocument();
            if (rtfDoc != null) {
                if (this.elementName.equals("author")) {
                    Meta meta = new Meta(this.elementName, this.text);
                    RtfInfoElement elem = new RtfInfoElement(rtfDoc, meta);
                    rtfDoc.getDocumentHeader().addInfoElement(elem);
                }
                if (this.elementName.equals("title")) {
                    Meta meta = new Meta(this.elementName, this.text);
                    RtfInfoElement elem = new RtfInfoElement(rtfDoc, meta);
                    rtfDoc.getDocumentHeader().addInfoElement(elem);
                }
                if (this.elementName.equals("subject")) {
                    Meta meta = new Meta(this.elementName, this.text);
                    RtfInfoElement elem = new RtfInfoElement(rtfDoc, meta);
                    rtfDoc.getDocumentHeader().addInfoElement(elem);
                }
            }
        }
        this.setToDefaults();
    }
    return true;
}
Also used : Meta(com.lowagie.text.Meta) RtfInfoElement(com.lowagie.text.rtf.document.RtfInfoElement) RtfDocument(com.lowagie.text.rtf.document.RtfDocument) Document(com.lowagie.text.Document) RtfDocument(com.lowagie.text.rtf.document.RtfDocument)

Example 2 with RtfDocument

use of com.lowagie.text.rtf.document.RtfDocument in project itext2 by albfernandez.

the class RtfWriter2 method close.

/**
 * Closes the RtfDocument. This causes the document to be written
 * to the specified OutputStream
 */
public void close() {
    if (open) {
        rtfDoc.writeDocument(os);
        super.close();
        this.rtfDoc = new RtfDocument();
    }
}
Also used : RtfDocument(com.lowagie.text.rtf.document.RtfDocument)

Example 3 with RtfDocument

use of com.lowagie.text.rtf.document.RtfDocument in project itext2 by albfernandez.

the class RtfParser method outputDebug.

public static void outputDebug(Object doc, int groupLevel, String str) {
    System.out.println(str);
    if (doc == null)
        return;
    if (groupLevel < 0)
        groupLevel = 0;
    char[] a;
    Arrays.fill(a = new char[groupLevel * 2], ' ');
    String spaces = new String(a);
    if (doc instanceof RtfDocument) {
        ((RtfDocument) doc).add(new RtfDirectContent("\n" + spaces + str));
    } else if (doc instanceof Document) {
        try {
            ((Document) doc).add(new RtfDirectContent("\n" + spaces + str));
        } catch (DocumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
Also used : RtfDirectContent(com.lowagie.text.rtf.direct.RtfDirectContent) DocumentException(com.lowagie.text.DocumentException) RtfDocument(com.lowagie.text.rtf.document.RtfDocument) RtfDocument(com.lowagie.text.rtf.document.RtfDocument) Document(com.lowagie.text.Document)

Aggregations

RtfDocument (com.lowagie.text.rtf.document.RtfDocument)3 Document (com.lowagie.text.Document)2 DocumentException (com.lowagie.text.DocumentException)1 Meta (com.lowagie.text.Meta)1 RtfDirectContent (com.lowagie.text.rtf.direct.RtfDirectContent)1 RtfInfoElement (com.lowagie.text.rtf.document.RtfInfoElement)1