[Bf-extensions-cvs] [de1d5d82] master: Fix T49281 PDF importer fails to read first page sometimes.
Howard Trickey
noreply at git.blender.org
Fri Oct 6 15:06:15 CEST 2017
Commit: de1d5d82367d2d3ae9c35bf9950a958d9d9b2913
Author: Howard Trickey
Date: Fri Oct 6 09:03:33 2017 -0400
Branches: master
https://developer.blender.org/rBACde1d5d82367d2d3ae9c35bf9950a958d9d9b2913
Fix T49281 PDF importer fails to read first page sometimes.
Fixed a case of chained trailer dictionaries, and then another
problem where decoder on byte string got errors on 8 bit bytes.
===================================================================
M io_vector/__init__.py
M io_vector/pdf.py
===================================================================
diff --git a/io_vector/__init__.py b/io_vector/__init__.py
index 9c7015d3..74696ee4 100644
--- a/io_vector/__init__.py
+++ b/io_vector/__init__.py
@@ -21,8 +21,8 @@
bl_info = {
"name": "Adobe Illustrator / PDF / SVG",
"author": "Howard Trickey",
- "version": (1, 1),
- "blender": (2, 78, 0),
+ "version": (1, 2),
+ "blender": (2, 79, 0),
"location": "File > Import-Export > Vector files (.ai, .pdf, .svg)",
"description": "Import Adobe Illustrator, PDF, and SVG",
"warning": "",
diff --git a/io_vector/pdf.py b/io_vector/pdf.py
index 57f15b69..e2e31991 100644
--- a/io_vector/pdf.py
+++ b/io_vector/pdf.py
@@ -454,7 +454,6 @@ def GetPDFTrailerAndCrossrefs(s):
crossrefs = {}
d = None
last_trailerdict = None
- print("looking for crossref at", crossrefi)
if s[crossrefi:crossrefi+4] != b'xref':
# Could be Crossref stream
(obj, j) = GetPDFObject(s, crossrefi)
@@ -555,7 +554,9 @@ def GetPDFTrailerAndCrossrefs(s):
if last_trailerdict is None:
last_trailerdict = trailerdict
if 'Prev' in trailerdict:
- crossrefi = trailerdict['Prev']
+ crossrefi = GetTypedValFromDictEntry(trailerdict, 'Prev', ONUM, s, crossrefs)
+ if crossrefi is None:
+ crossrefi = -1
else:
crossrefi = -1
return (last_trailerdict, crossrefs)
@@ -842,7 +843,7 @@ def GetPDFStreamContents(contentsobj, s, crossrefs, dodecode=True):
crossrefs: dict - maps (obj_number, gen_number) to byte offset in s
dodecode: bool - should we decode too?
Returns:
- string - the contents (if dodecode, decoded using default (UTF-8) decoder)
+ string - the contents (if dodecode, decoded using latin1 decoder)
"""
if not PDFObjHasType(contentsobj, OSTREAM):
@@ -902,7 +903,7 @@ def GetPDFStreamContents(contentsobj, s, crossrefs, dodecode=True):
print("FlateDecode with prediction didn't consume all bytes")
ans = ''.join(ansbytes)
if dodecode:
- ans = ans.decode()
+ ans = ans.decode(encoding='latin1', errors='ignore')
else:
if WARN:
print('unhandled stream filter', fname)
More information about the Bf-extensions-cvs
mailing list