1

我正在创建一个 java 应用程序,它将提取 Powerpoint (PPTX) 文档中的嵌入式缩略图。由于 pptx 文件是 zip 档案,我正在尝试使用 TrueZip 来获取在档案内找到的缩略图。不幸的是,每当我尝试运行我的应用程序时,它都会抛出一个 IOException 说明文件丢失C:\Users\test-user\Desktop\DocumentsTest\Hello.pptx\docProps\thumbnail.jpeg (missing file)

下面是我用来获取缩略图的代码:

public Boolean GetThumbPPTX(String inFile, String outFile)
{
    try 
    {
        TFile srcFile = new TFile(inFile, "docProps\\thumbnail.jpeg");
        TFile dstFile = new TFile(outFile);

        if(dstFile.exists())
            dstFile.delete();

        srcFile.toNonArchiveFile().cp_rp(dstFile);

        return dstFile.exists();

    } catch (IOException ex) {
        Logger.getLogger(DocumentThumbGenerator.class.getName()).log(Level.SEVERE, null, ex);
    }

    return false;
}

whereinFile是 pptx 文件的绝对路径,outFile是缩略图将被复制到的路径。我可以验证档案内部是否在相同的确切路径中有一个缩略图。

有人可以帮忙吗?

4

1 回答 1

1

我刚刚找到了答案。看来我没有正确配置 Zip 驱动程序。我将它添加到我的类构造函数中,现在一切正常:

TConfig.get().setArchiveDetector(new TArchiveDetector(
            TArchiveDetector.NULL,
            new Object[][] {                
                { "zip|pptx", new ZipDriver(IOPoolLocator.SINGLETON)},
            }));
于 2015-09-02T06:47:57.437 回答