[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#753239: [tex-live] bug in thumbpdf? - PATCH



Hi everyone,

Thanks to Ulrike's test files I could track it down ...

> So it seems that the $objstream is *only* initialized when the objdict[$count]
> is true, i.e., if the obj line looks like
> 	3 0 obj <<
> But the << is on the next line, and even then, moving it up, did not change
> anything.

That was absolutely true, but my check was wrong, because thumbpdf was
parsing a *different* file, the thumbpdf.pdf.

There are two changes in PDF-X or whatever that adds these new lines
after << and >>.

With the attached patch it works again on my installations.

But I don't know whether
	tell
	seek
works on Windows, too (Ulrike ... please ...)

The idea is that we read the next line (peek at it), and if it
is a << or endobj then we just do as normal, otherwise we put
the line back.

Patch attached, comments welcome.

Thanks


Norbert

------------------------------------------------------------------------
PREINING, Norbert                               http://www.preining.info
JAIST, Japan                                 TeX Live & Debian Developer
GPG: 0x860CDC13   fp: F7D8 A928 26E3 16A1 9FA0  ACF0 6CAC A448 860C DC13
------------------------------------------------------------------------
--- thumbpdf.pl.orig	2014-07-13 16:24:53.823731368 +0900
+++ thumbpdf.pl	2014-07-15 00:29:21.030833482 +0900
@@ -937,6 +937,18 @@
     $objno[$count] = $1;
     $getobjindex[$1] = $count;
     $objdict[$count] = ($2); # boolean (if $2 exists)
+    if (!$objdict[$count]) {
+      # check for << on thext line
+      my $pos = tell();
+      $_ = <PDF>;
+      if (/^<<$/) {
+      	$objdict[$count] = 1;
+	$lineno++;
+      } else {
+        # undo the reading
+	seek PDF, $pos, 0;
+      }
+    }
     my $stream = 0;
     print "* obj $objno[$count]" .
       (($objdict[$count]) ? " (dict)" : "") .
@@ -952,7 +964,20 @@
       {
         if (/^>>/)
         {
-          last if /^>>\s+endobj$/; # obj without stream
+	  # new line after >>
+          if (/^>>\s+endobj$/) {
+            last; # obj without stream
+          } else {
+            my $pos = tell();
+            $_ = <PDF> ;
+            if (/^endobj$/) {
+              last; # obj without stream
+              $lineno++;
+            } else {
+              seek PDF, $pos, 0;
+            }
+          }
+          # last if /^>>\s+endobj$/; # obj without stream
 
           # get stream
           $_ = <PDF>; $lineno++;

Reply to: