Skip to content

Instantly share code, notes, and snippets.

Last active May 21, 2022 02:07
What would you like to do?
class Pdf:
def __init__(self, pdfParameter):
self._pdfParameter = pdfParameter
self._currentPage = 0
def fileObject(self):
return self._fileObject
def currentPage(self):
return self._currentPage
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
self._currentPage = -1
def next(self):
if self._pdfParameter.reverse:
self._currentPage = self._currentPage - 1
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