-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpypdf4.patch
39 lines (38 loc) · 1.68 KB
/
pypdf4.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
diff --git PyPDF4/pdf.py PyPDF4/pdf.py
index 8bfd312..1f9942f 100644
--- PyPDF4/pdf.py
+++ PyPDF4/pdf.py
@@ -499,8 +499,12 @@ class PdfFileWriter(object):
assert len(key) == (len(self._encrypt_key) + 5)
md5_hash = md5(key).digest()
key = md5_hash[:min(16, len(self._encrypt_key) + 5)]
- obj.writeToStream(stream, key)
- stream.write(b_("\nendobj\n"))
+
+ try:
+ obj.writeToStream(stream, key)
+ stream.write(b_("\nendobj\n"))
+ except:
+ pass
# xref table
xref_location = stream.tell()
@@ -1122,7 +1126,7 @@ class PdfFileReader(object):
``warnings.py`` module with a custom implementation (defaults to
``True``).
"""
- def __init__(self, stream, strict=True, warndest = None, overwriteWarnings = True):
+ def __init__(self, stream, strict=False, warndest = None, overwriteWarnings = True):
if overwriteWarnings:
# have to dynamically override the default showwarning since there are no
# public methods that specify the 'file' parameter
@@ -1692,8 +1696,8 @@ class PdfFileReader(object):
else:
warnings.warn("Object %d %d not defined."%(indirectReference.idnum,
indirectReference.generation), utils.PdfReadWarning)
- #if self.strict:
- raise utils.PdfReadError("Could not find object.")
+ if self.strict:
+ raise utils.PdfReadError("Could not find object.")
self.cacheIndirectObject(indirectReference.generation,
indirectReference.idnum, retval)
return retval