如何使用RTFEditorKit读取页眉和页脚行

问题描述 投票:1回答:1

有人知道如何获得RTF文件的页眉/页脚?我试过这样的事情(使用RTfEditorKit):

    RTFEditorKit rtf = new RTFEditorKit();

    DefaultStyledDocument docIn = (DefaultStyledDocument) rtf.createDefaultDocument();

    try {

        FileInputStream fi = new FileInputStream("zf_static_follow.out.rtf");
        rtf.read(fi, docIn, 0);

    } catch (IOException e) {

        e.printStackTrace();
    } catch (BadLocationException e) {

        e.printStackTrace();
    }

    docIn.getProperty("header");//  <-- null
    System.out.println(docIn.getProperty("headerf")); //   <--null
    System.out.println(docIn.getProperty("headerl")); //   <--null
    System.out.println(docIn.getProperty("headerr")); //   <--null

在此先感谢您的帮助。马库斯

java swing rtf
1个回答
1
投票

使用public Dictionary<Object,Object> getDocumentProperties()AbstractDocument方法,并查看Document的所有现有属性。

© www.soinside.com 2019 - 2024. All rights reserved.