My test data contains a file with a broken xref table.
The code appears to crash when I call the fitz.New() method on my file.
Here is the output-
error: cannot find startxref
warning: trying to repair broken xref
warning: repairing PDF document
error: array not closed before end of file
error: aborting process from uncaught error!
My function let's call it read_pdf() takes in a file path and returns (string, error). It is completely functional for all types of pdfs (text, images etc.). However when a corrupted file is passed it panics and halts program execution.
I have already tried putting in a
defer func() {
if err := recover(); err != nil {
logrus.Errorf("Error parsing PDF file %v", fpath)
}
}()
inside my read_pdf function but it appears the function still panics. The panic occurs in fitz.New() for sure because any lines after it are not executed.
My test data contains a file with a broken xref table. The code appears to crash when I call the fitz.New() method on my file.
Here is the output-
My function let's call it read_pdf() takes in a file path and returns (string, error). It is completely functional for all types of pdfs (text, images etc.). However when a corrupted file is passed it panics and halts program execution.
I have already tried putting in a
inside my read_pdf function but it appears the function still panics. The panic occurs in fitz.New() for sure because any lines after it are not executed.