rpms/poppler/F-10 pdftops-large-image.patch, NONE, 1.1 poppler.spec, 1.76, 1.77

Matthias Clasen mclasen at fedoraproject.org
Sun Jan 4 05:15:59 UTC 2009


Author: mclasen

Update of /cvs/pkgs/rpms/poppler/F-10
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv21327

Modified Files:
	poppler.spec 
Added Files:
	pdftops-large-image.patch 
Log Message:
upstream bugfix for large images


pdftops-large-image.patch:

--- NEW FILE pdftops-large-image.patch ---
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 014036b..52495d7 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -2610,6 +2610,7 @@ void PSOutputDev::setupImage(Ref id, Stream *str) {
   GooString *s;
   int c;
   int size, line, col, i;
+  int outerSize, outer;
 
   // check if image is already setup
   for (i = 0; i < imgIDLen; ++i) {
@@ -2696,56 +2697,72 @@ void PSOutputDev::setupImage(Ref id, Stream *str) {
   if (useRLE) {
     ++size;
   }
+  outerSize = size/65535 + 1;
+
   writePSFmt("{0:d} array dup /ImData_{1:d}_{2:d} exch def\n",
-	     size, id.num, id.gen);
+	     outerSize, id.num, id.gen);
   str->close();
 
   // write the data into the array
   str->reset();
-  line = col = 0;
-  writePS((char *)(useASCIIHex ? "dup 0 <" : "dup 0 <~"));
-  do {
-    do {
-      c = str->getChar();
-    } while (c == '\n' || c == '\r');
-    if (c == (useASCIIHex ? '>' : '~') || c == EOF) {
-      break;
-    }
-    if (c == 'z') {
-      writePSChar(c);
-      ++col;
-    } else {
-      writePSChar(c);
-      ++col;
-      for (i = 1; i <= (useASCIIHex ? 1 : 4); ++i) {
-	do {
-	  c = str->getChar();
-	} while (c == '\n' || c == '\r');
-	if (c == (useASCIIHex ? '>' : '~') || c == EOF) {
-	  break;
-	}
+  for (outer = 0;outer < outerSize;outer++) {
+    int innerSize = size > 65535 ? 65535 : size;
+
+    // put the inner array into the outer array
+    writePSFmt("{0:d} array 1 index {1:d} 2 index put\n",
+	       innerSize, outer);
+    line = col = 0;
+    writePS((char *)(useASCIIHex ? "dup 0 <" : "dup 0 <~"));
+    for (;;) {
+      do {
+	c = str->getChar();
+      } while (c == '\n' || c == '\r');
+      if (c == (useASCIIHex ? '>' : '~') || c == EOF) {
+	break;
+      }
+      if (c == 'z') {
 	writePSChar(c);
 	++col;
+      } else {
+	writePSChar(c);
+	++col;
+	for (i = 1; i <= (useASCIIHex ? 1 : 4); ++i) {
+	  do {
+	    c = str->getChar();
+	  } while (c == '\n' || c == '\r');
+	  if (c == (useASCIIHex ? '>' : '~') || c == EOF) {
+	    break;
+	  }
+	  writePSChar(c);
+	  ++col;
+	}
+      }
+      // each line is: "dup nnnnn <~...data...~> put<eol>"
+      // so max data length = 255 - 20 = 235
+      // chunks are 1 or 4 bytes each, so we have to stop at 232
+      // but make it 225 just to be safe
+      if (col > 225) {
+	writePS((char *)(useASCIIHex ? "> put\n" : "~> put\n"));
+	++line;
+	if (line >= innerSize) break;
+	writePSFmt((char *)(useASCIIHex ? "dup {0:d} <" : "dup {0:d} <~"), line);
+	col = 0;
       }
     }
-    // each line is: "dup nnnnn <~...data...~> put<eol>"
-    // so max data length = 255 - 20 = 235
-    // chunks are 1 or 4 bytes each, so we have to stop at 232
-    // but make it 225 just to be safe
-    if (col > 225) {
+    if (c == (useASCIIHex ? '>' : '~') || c == EOF) {
       writePS((char *)(useASCIIHex ? "> put\n" : "~> put\n"));
-      ++line;
-      writePSFmt((char *)(useASCIIHex ? "dup {0:d} <" : "dup {0:d} <~"), line);
-      col = 0;
+      if (useRLE) {
+	++line;
+	writePSFmt("{0:d} <> put\n", line);
+      } else {
+	writePS("pop\n");
+      }
+      break;
     }
-  } while (c != (useASCIIHex ? '>' : '~') && c != EOF);
-  writePS((char *)(useASCIIHex ? "> put\n" : "~> put\n"));
-  if (useRLE) {
-    ++line;
-    writePSFmt("{0:d} <> put\n", line);
-  } else {
     writePS("pop\n");
+    size -= innerSize;
   }
+  writePS("pop\n");
   str->close();
 
   delete str;
@@ -4382,7 +4399,7 @@ void PSOutputDev::doImageL1(Object *ref, GfxImageColorMap *colorMap,
       // make sure the image is setup, it sometimes is not like on bug #17645
       setupImage(ref->getRef(), str);
       // set up to use the array already created by setupImages()
-      writePSFmt("ImData_{0:d}_{1:d} 0\n", ref->getRefNum(), ref->getRefGen());
+      writePSFmt("ImData_{0:d}_{1:d} 0 0\n", ref->getRefNum(), ref->getRefGen());
     }
   }
 
@@ -4845,7 +4862,7 @@ void PSOutputDev::doImageL2(Object *ref, GfxImageColorMap *colorMap,
       // make sure the image is setup, it sometimes is not like on bug #17645
       setupImage(ref->getRef(), str);
       // set up to use the array already created by setupImages()
-      writePSFmt("ImData_{0:d}_{1:d} 0\n", ref->getRefNum(), ref->getRefGen());
+      writePSFmt("ImData_{0:d}_{1:d} 0 0\n",ref->getRefNum(), ref->getRefGen());
     }
   }
 
@@ -4899,7 +4916,12 @@ void PSOutputDev::doImageL2(Object *ref, GfxImageColorMap *colorMap,
 
   // data source
   if (mode == psModeForm || inType3Char || preload) {
-    writePS("  /DataSource { 2 copy get exch 1 add exch }\n");
+    if (inlineImg) {
+      writePS("  /DataSource { 2 copy get exch 1 add exch }\n");
+    } else {
+      writePS("  /DataSource { dup 65535 ge { pop 1 add 0 } if 2 index 2"
+	" index get 1 index get exch 1 add exch }\n");
+    }
   } else {
     writePS("  /DataSource currentfile\n");
   }
@@ -4938,6 +4960,7 @@ void PSOutputDev::doImageL2(Object *ref, GfxImageColorMap *colorMap,
     writePSFmt(">>\n{0:s}\n", colorMap ? "image" : "imagemask");
 
     // get rid of the array and index
+    if (!inlineImg) writePS("pop ");
     writePS("pop pop\n");
 
   } else {
@@ -5115,7 +5138,7 @@ void PSOutputDev::doImageL3(Object *ref, GfxImageColorMap *colorMap,
       // make sure the image is setup, it sometimes is not like on bug #17645
       setupImage(ref->getRef(), str);
       // set up to use the array already created by setupImages()
-      writePSFmt("ImData_{0:d}_{1:d} 0\n", ref->getRefNum(), ref->getRefGen());
+      writePSFmt("ImData_{0:d}_{1:d} 0 0\n", ref->getRefNum(), ref->getRefGen());
     }
   }
 
@@ -5186,7 +5209,12 @@ void PSOutputDev::doImageL3(Object *ref, GfxImageColorMap *colorMap,
 
   // data source
   if (mode == psModeForm || inType3Char || preload) {
-    writePS("  /DataSource { 2 copy get exch 1 add exch }\n");
+    if (inlineImg) {
+	writePS("  /DataSource { 2 copy get exch 1 add exch }\n");
+    } else {
+	writePS("  /DataSource { dup 65535 ge { pop 1 add 0 } if 2 index 2"
+	  " index get 1 index get exch 1 add exch }\n");
+    }
   } else {
     writePS("  /DataSource currentfile\n");
   }
@@ -5322,6 +5350,7 @@ void PSOutputDev::doImageL3(Object *ref, GfxImageColorMap *colorMap,
 
   // get rid of the array and index
   if (mode == psModeForm || inType3Char || preload) {
+    if (!inlineImg) writePS("pop ");
     writePS("pop pop\n");
 
   // image data


Index: poppler.spec
===================================================================
RCS file: /cvs/pkgs/rpms/poppler/F-10/poppler.spec,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- poppler.spec	16 Sep 2008 19:02:41 -0000	1.76
+++ poppler.spec	4 Jan 2009 05:15:29 -0000	1.77
@@ -3,7 +3,7 @@
 Summary: PDF rendering library
 Name: poppler
 Version: 0.8.7
-Release: 2%{?dist}
+Release: 3%{?dist}
 License: GPLv2 and Redistributable, no modification permitted
 # the code is GPLv2
 # the charmap data in /usr/share/poppler is redistributable
@@ -12,6 +12,8 @@
 Source0: http://poppler.freedesktop.org/poppler-%{version}.tar.gz
 Source1: http://poppler.freedesktop.org/poppler-data-%{dataversion}.tar.gz
 Patch0: poppler-ObjStream.patch
+# fix from upstream
+Patch1: pdftops-large-image.patch
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
 
 BuildRequires: gtk2-devel
@@ -108,6 +110,7 @@
 %setup -c -q -a1
 pushd %{name}-%{version}
 %patch0 -p0 -b .objstream
+%patch1 -p1 -b .large-image
 popd
 
 %build
@@ -195,6 +198,9 @@
 %{_mandir}/man1/*
 
 %changelog
+* Sun Jan  4 2009 Matthias Clasen  <mclasen at redhat.com> - 0.8.7-3
+- Fix a problem with large images
+
 * Tue Sep 16 2008 Rex Dieter <rdieter at fedoraproject.org> - 0.8.7-2
 - cleanup qt3 hack
 - %%description cosmetics




More information about the fedora-extras-commits mailing list