summaryrefslogtreecommitdiff
path: root/debian/patches/06_fix_pdf_xref.dpatch
blob: 07ffad0e3e17b30dc2813d3b18060a2d6dfcf54e (plain)
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
48
49
#! /bin/sh /usr/share/dpatch/dpatch-run
## 06_fix_pdf_xref.dpatch by  <jblache@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Mark non-existent objects as free in the xref table.

@DPATCH@
diff -urNad xsane-0.995~/src/xsane-multipage-project.c xsane-0.995/src/xsane-multipage-project.c
--- xsane-0.995~/src/xsane-multipage-project.c	2007-05-17 14:57:31.000000000 +0200
+++ xsane-0.995/src/xsane-multipage-project.c	2008-09-17 21:54:28.871207862 +0200
@@ -973,6 +973,10 @@
     else if (output_format == XSANE_PDF)
     {
       xsane_save_pdf_create_document_header(outfile, &xref, pages, preferences.save_pdf_flatedecoded);
+
+      /* Objects 4 and 5 are unused and do not exist */
+      xref.obj[4] = 0;
+      xref.obj[5] = 0;
     }
   }
 #ifdef HAVE_LIBTIFF
diff -urNad xsane-0.995~/src/xsane-save.c xsane-0.995/src/xsane-save.c
--- xsane-0.995~/src/xsane-save.c	2008-09-17 21:53:33.000000000 +0200
+++ xsane-0.995/src/xsane-save.c	2008-09-17 21:54:07.654207681 +0200
@@ -4087,7 +4087,7 @@
 
   for (i=1; i <= pages * 2 + 7; i++)
   {
-    fprintf(outfile, "%010lu 00000 n \n", xref->obj[i]);
+    fprintf(outfile, "%010lu 00000 %c \n", xref->obj[i], (xref->obj[i]) ? 'n' : 'f');
   }
 
   fprintf(outfile, "\n");
@@ -4186,11 +4186,13 @@
 
   xsane_save_pdf_create_document_header(outfile, &xref, 1, flatedecode);
 
-  xref.obj[4] = ftell(outfile);
-  xref.obj[5] = ftell(outfile);
+  /* Objects 4 and 5 are unused and do not exist */
+  xref.obj[4] = 0;
+  xref.obj[5] = 0;
 
   if (apply_ICM_profile && (cms_function == XSANE_CMS_FUNCTION_EMBED_SCANNER_ICM_PROFILE))
   {
+    /* Use object 4 for ICM profile */
     icc_object = 4;
     xsane_embed_pdf_icm_profile(outfile, &xref, image_info->icm_profile, flatedecode, icc_object);
   }