This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Pdf: | |
def __init__(self, pdfParameter): | |
self._pdfParameter = pdfParameter | |
self._currentPage = 0 | |
@property | |
def fileObject(self): | |
return self._fileObject | |
@property | |
def currentPage(self): | |
return self._currentPage | |
@property | |
def numOfPages(self): | |
return self._numOfPages | |
def load(self): | |
self._fileObject = open(self._pdfParameter.filename, "rb") | |
self._numOfPages = PdfFileReader(self._fileObject).getNumPages() | |
# client has to call next() first. | |
# the page number begins with 0 | |
if self._pdfParameter.reverse: | |
self._currentPage = self._numOfPages | |
else: | |
self._currentPage = -1 | |
def next(self): | |
if self._pdfParameter.reverse: | |
self._currentPage = self._currentPage - 1 | |
else: | |
self._currentPage = self._currentPage + 1 | |
if self._currentPage < 0 or self._currentPage >= self._numOfPages: | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment