Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mstamy2 committed Mar 12, 2018
2 parents 772ef3f + a4279cf commit 94a208e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion PyPDF2/merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def merge(self, position, fileobj, bookmark=None, pages=None, import_bookmarks=T
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)
Expand Down
6 changes: 4 additions & 2 deletions PyPDF2/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,7 @@ def _decrypt(self, password):
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
Expand Down Expand Up @@ -2226,7 +2226,8 @@ def rotateCounterClockwise(self, angle):
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):
Expand Down Expand Up @@ -2665,6 +2666,7 @@ def extractText(self):
_text = operands[0]
if isinstance(_text, TextStringObject):
text += _text
text += "\n"
elif operator == b_("T*"):
text += "\n"
elif operator == b_("'"):
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#PyPDF2
# PyPDF2

PyPDF2 is a pure-python PDF library capable of
splitting, merging together, cropping, and transforming
Expand All @@ -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:

Expand Down

0 comments on commit 94a208e

Please sign in to comment.