This commit is contained in:
Matthew Stamy 2018-03-12 14:33:06 -05:00
commit 94a208e292
3 changed files with 11 additions and 9 deletions

View File

@ -113,7 +113,7 @@ class PdfFileMerger(object):
if isString(fileobj):
fileobj = file(fileobj, 'rb')
my_file = True
elif isinstance(fileobj, file):
elif hasattr(fileobj, "seek") and hasattr(fileobj, "read"):
fileobj.seek(0)
filecontent = fileobj.read()
fileobj = StreamIO(filecontent)

View File

@ -2057,7 +2057,7 @@ class PdfFileReader(object):
if encrypt['/Filter'] != '/Standard':
raise NotImplementedError("only Standard PDF encryption handler is available")
if not (encrypt['/V'] in (1, 2)):
raise NotImplementedError("only algorithm code 1 and 2 are supported")
raise NotImplementedError("only algorithm code 1 and 2 are supported. This PDF uses code %s" % encrypt['/V'])
user_password, key = self._authenticateUserPassword(password)
if user_password:
self._decryption_key = key
@ -2226,7 +2226,8 @@ class PageObject(DictionaryObject):
return self
def _rotate(self, angle):
currentAngle = self.get("/Rotate", 0)
rotateObj = self.get("/Rotate", 0)
currentAngle = rotateObj if isinstance(rotateObj, int) else rotateObj.getObject()
self[NameObject("/Rotate")] = NumberObject(currentAngle + angle)
def _mergeResources(res1, res2, resource):
@ -2665,6 +2666,7 @@ class PageObject(DictionaryObject):
_text = operands[0]
if isinstance(_text, TextStringObject):
text += _text
text += "\n"
elif operator == b_("T*"):
text += "\n"
elif operator == b_("'"):

View File

@ -1,4 +1,4 @@
#PyPDF2
# PyPDF2
PyPDF2 is a pure-python PDF library capable of
splitting, merging together, cropping, and transforming
@ -10,22 +10,22 @@ as merge entire files together.
Homepage
http://mstamy2.github.io/PyPDF2/
##Examples
## Examples
Please see `sample code` folder
Please see the `Sample_Code` folder.
##Documentation
## Documentation
Documentation is available at
https://pythonhosted.org/PyPDF2/
##FAQ
## FAQ
Please see
http://mstamy2.github.io/PyPDF2/FAQ.html
##Tests
## Tests
PyPDF2 includes a test suite built on the unittest framework. All tests are located in the "Tests" folder.
Tests can be run from the command line by: