hughbe / OfficeFileReader

Swift .doc and .ppt file reader
11 stars 2 forks source link

CompoundFileError.invalidSignature #1

Closed ladiesman218 closed 2 years ago

ladiesman218 commented 2 years ago

I'm trying to use this library to open a pptx file on iOS. The file is attached in the bundle, I can read out the data but when running the app, it crashes on initialize a ppt file. Here is the code:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let url = Bundle.main.url(forResource: "doc1", withExtension: "pptx")!
        let data = try! Data(contentsOf: url)

        let file = try! PptFile(data: data)

    }
}

And the error message:

PPT_Viewer/ViewController.swift:20: Fatal error: 'try!' expression unexpectedly raised an error: CompoundFileReader.CompoundFileError.invalidSignature(signature: 1688935826934608)
2022-07-02 16:07:20.519864+0800 PPT Viewer[13769:9033568] PPT_Viewer/ViewController.swift:20: Fatal error: 'try!' expression unexpectedly raised an error: CompoundFileReader.CompoundFileError.invalidSignature(signature: 1688935826934608)
hughbe commented 2 years ago

Hi, the file you’re trying to open is a pptx file which is a different format to ppt files.

You might be interested in https://stackoverflow.com/questions/20953584/how-to-open-view-view-doc-docx-rtf-ppt-pptx-xlsx-xls-file-in-ipho and https://blog.online-convert.com/the-difference-between-ppt-and-pptx-files/

I don’t on supporting the pptx file format in this library.