Improve office documents page number detection
This commit is contained in:
@@ -15,6 +15,7 @@ from converter.literals import DIMENSION_SEPARATOR
|
||||
from converter.literals import FILE_FORMATS
|
||||
from converter.utils import cleanup
|
||||
from converter.runtime import office_converter
|
||||
from converter.exceptions import OfficeConversionError
|
||||
|
||||
HASH_FUNCTION = lambda x: hashlib.sha256(x).hexdigest()
|
||||
|
||||
@@ -61,7 +62,7 @@ def convert(input_filepath, output_filepath=None, cleanup_files=False, mimetype=
|
||||
# Recycle the already detected mimetype
|
||||
mimetype = office_converter.mimetype
|
||||
|
||||
except OfficeConverter:
|
||||
except OfficeConversionError:
|
||||
raise UnknownFileFormat('office converter exception')
|
||||
|
||||
if size:
|
||||
@@ -98,14 +99,15 @@ def convert(input_filepath, output_filepath=None, cleanup_files=False, mimetype=
|
||||
|
||||
|
||||
def get_page_count(input_filepath):
|
||||
office_converter = OfficeConverter()
|
||||
office_converter.convert(input_filepath)
|
||||
if office_converter:
|
||||
try:
|
||||
input_filepath = office_converter.output_filepath
|
||||
except OfficeConverter:
|
||||
raise UnknownFileFormat('office converter exception')
|
||||
|
||||
office_converter.convert(input_filepath)
|
||||
if office_converter.exists:
|
||||
input_filepath = office_converter.output_filepath
|
||||
|
||||
except OfficeConversionError:
|
||||
raise UnknownFileFormat('office converter exception')
|
||||
|
||||
return backend.get_page_count(input_filepath)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user