【问题标题】:How to update keywords metadata in DOC如何更新 DOC 中的关键字元数据
【发布时间】:2014-09-19 03:15:23
【问题描述】:

我正在尝试更新 DOC 文件元数据中的 keyword。我已经能够使用下面的代码更新 category 元数据,但我没有看到任何更改 keywords 的方法

我正在使用poi:3.10-FINAL

void updateProperties(String filepath) {
        POIFSFileSystem poifs = new POIFSFileSystem(new FileInputStream(filepath));
        DirectoryEntry dir = poifs.getRoot();
        DocumentSummaryInformation dsi;
        try
        {
            DocumentEntry dsiEntry = (DocumentEntry) dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
            DocumentInputStream dis = new DocumentInputStream(dsiEntry);
            PropertySet ps = new PropertySet(dis);
            dis.close();
            dsi = new DocumentSummaryInformation(ps);
        }
        catch (FileNotFoundException ex)
        {
            dsi = PropertySetFactory.newDocumentSummaryInformation();
        }
        dsi.setCategory("New Category set");


        dsi.write(dir, DocumentSummaryInformation.DEFAULT_STREAM_NAME);
        OutputStream out = new FileOutputStream(filepath);
        poifs.writeFilesystem(out);
        out.close();
    }

【问题讨论】:

    标签: java apache-poi doc


    【解决方案1】:

    关键字不存储在DocumentSummaryInformation,它们存储在另一个属性流SummaryInformation

    如果您查看 SummaryInformation 的 JavaDocs,您会发现它具有您搜索的方法 setKeywords(String)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-23
      • 1970-01-01
      • 2021-08-18
      • 2016-04-10
      相关资源
      最近更新 更多