#NEWLINE# def get_page_count( self ) : #NEWLINE# #INDENT# super ( Python , self ) . get_page_count ( ) #NEWLINE# page_count = 1 #NEWLINE# if ( ( self . mime_type == 'application/pdf' ) or self . soffice_file ) : #NEWLINE# #INDENT# if self . soffice_file : #NEWLINE# #INDENT# file_object = IteratorIO ( self . soffice_file ) . file_buffer #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# file_object = self . file_object #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# page_count = len ( list ( PDFPage . get_pages ( file_object ) ) ) #NEWLINE# #UNINDENT# except Exception as exception : #NEWLINE# #INDENT# error_message = ( _ ( 'Exception determining PDF page count; %s' ) % exception ) #NEWLINE# logger . error ( error_message ) #NEWLINE# raise PageCountError ( error_message ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logger . debug ( 'Document contains %d pages' , page_count ) #NEWLINE# return page_count #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# file_object . seek ( 0 ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# image = Image . open ( self . file_object ) #NEWLINE# #UNINDENT# except IOError as exception : #NEWLINE# #INDENT# error_message = ( _ ( 'Exception determining PDF page count; %s' ) % exception ) #NEWLINE# logger . error ( error_message ) #NEWLINE# raise PageCountError ( error_message ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# self . file_object . seek ( 0 ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# image . seek ( ( image . tell ( ) + 1 ) ) #NEWLINE# page_count += 1 #NEWLINE# #UNINDENT# #UNINDENT# except EOFError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# return page_count