diff --git a/PyPDF2/merger.py b/PyPDF2/merger.py index 27702ad..c3373e4 100644 --- a/PyPDF2/merger.py +++ b/PyPDF2/merger.py @@ -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) diff --git a/PyPDF2/pdf.py b/PyPDF2/pdf.py index d1751a7..9fff2a8 100644 --- a/PyPDF2/pdf.py +++ b/PyPDF2/pdf.py @@ -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_("'"): diff --git a/README.md b/README.md index 7301307..233201b 100644 --- a/README.md +++ b/README.md @@ -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: