My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 71 attachment: pdfsizeopt-20121012.pat (1.9 KB)

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
40
41
42
43
44
45
46
47
--- pdfsizeopt-20121012/pdfsizeopt.py- 2012-10-12 15:44:40.879227789 -0400
+++ pdfsizeopt-20121012/pdfsizeopt.py 2012-10-12 21:56:11.497748823 -0400
@@ -3637,7 +3637,8 @@
if not f0: # A free object, ignore it.
continue
if obj_num in obj_starts:
- raise PdfXrefStreamError('duplicate obj %d' % obj_num)
+ print >>sys.stderr, (
+ 'warning: duplicate obj %d in xref stream' % obj_num)
if f0 == 1: # f1 is the object offset in the file.
if f2:
if not do_ignore_generation_numbers:
@@ -3682,7 +3683,12 @@
if (old_value != new_value and
trailer_obj.CompressValue(old_value) !=
trailer_obj.CompressValue(new_value)):
- duplicate_names.add(name)
+ if name == 'ID':
+ # Allow duplicate /ID
+ print >>sys.stderr, (
+ 'warning: duplicate /ID in xref streams')
+ else:
+ duplicate_names.add(name)
else:
trailer_obj.Set(name, new_value)
if duplicate_names:
@@ -3725,7 +3731,9 @@
for obj_num in sorted(obj_streams):
obj_start = obj_starts.get(obj_num)
if obj_start is None:
- raise PdfXrefStreamError('missing obj stream %d' % obj_num)
+ print >>sys.stderr, (
+ 'warning: missing xref obj stream %d' % obj_num)
+ continue
if not isinstance(obj_start, int):
raise PdfXrefStreamError('in-object-stream obj stream %d' % obj_num)
try:
@@ -3767,7 +3775,8 @@
'%d 0 obj\n%s\nendobj\n' % (obj_num, compressed_obj_headbufs[i]))

for obj_num in sorted(obj_streams):
- del obj_starts[obj_num]
+ if obj_starts.get(obj_num) is not None:
+ del obj_starts[obj_num]
obj_starts['trailer'] = trailer_obj
return obj_starts, has_generational_objs

Powered by Google Project Hosting