Bug 97803 - Recent versions of pdftoppm have trouble with reading input from stdin
Summary: Recent versions of pdftoppm have trouble with reading input from stdin
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: utils (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-14 09:22 UTC by Brecht Machiels
Modified: 2016-11-29 23:15 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
PDF file that can be used to trigger the bug (50.84 KB, application/pdf)
2016-09-14 09:32 UTC, Brecht Machiels
Details
read softmask into memstrean in case of matte (1.63 KB, patch)
2016-09-18 10:11 UTC, Thomas Freitag
Details | Splinter Review
read softmask into memstrean in case of matte (1.57 KB, patch)
2016-09-29 07:38 UTC, Thomas Freitag
Details | Splinter Review

Description Brecht Machiels 2016-09-14 09:22:17 UTC
Using this PDF file: http://www.mos6581.org/rinohtype/_downloads/demo.pdf

This works: 

    pdftoppm -f 5 -singlefile -gray demo.pdf >demo.pgm

This fails to parse the PDF properly:

    cat demo.pdf | pdftoppm -f 5 -singlefile -gray - >demo.pgm

This has the same effect:

    pdftoppm -f 5 -singlefile -gray - <demo.pdf >demo.pgm


These warnings are output:

Syntax Error (15429): Illegal character ')'
Syntax Error (15429): Illegal character ')'
Syntax Error (15429): Illegal character ')'
Syntax Error (15429): Illegal character ')'
Syntax Error (15429): Illegal character ')'
Syntax Error (15429): Illegal character ')'
Syntax Error (15429): Illegal character ')'
Syntax Error (15429): Illegal character ')'
Syntax Error (15445): Illegal character ')'
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Element of show/space array must be number or string
Syntax Error (15445): Unknown operator 'Enote'
Syntax Error (15445): Unknown operator ']'
Syntax Error (15445): Too few (0) args to 'TJ' operator

This used to work with poppler 0.41.0. I have tried a couple of versions since then, all of which suffer from the same problem. 0.47.0 is still broken.

I believe the other utils have similar problems with reading from stdin.
Comment 1 Brecht Machiels 2016-09-14 09:32:01 UTC
Created attachment 126512 [details]
PDF file that can be used to trigger the bug
Comment 2 Jason Crain 2016-09-14 18:19:50 UTC
(In reply to Brecht Machiels from comment #0)
> These warnings are output:
> 
> Syntax Error (15429): Illegal character ')'
> Syntax Error (15429): Illegal character ')'
> Syntax Error (15429): Illegal character ')'
...

I'm surprised this works as well as it does, with PDFs requiring random access...  Not assigning blame, but git bisect found this commit, so it probably has something to do with matte images.

36c276f1af7e0f1d8a207f6cdcaa80a24e95e044 is the first bad commit
commit 36c276f1af7e0f1d8a207f6cdcaa80a24e95e044
Author: Thomas Freitag <Thomas.Freitag@alfa.de>
Date:   Wed Mar 2 09:50:01 2016 +0100

    Splash: Implementation of matte entries in softmasks of softmasked images

    Bug #22473

:040000 040000 c279d786dc25cb4e54d54ff791c4642962ec9677 bca10de9202aa0d6bb5f49327583428f11d73a5f M      poppler
Comment 3 Thomas Freitag 2016-09-18 10:11:18 UTC
Created attachment 126600 [details] [review]
read softmask into memstrean in case of matte

In case of matte the softmask has to be read twice. This is not possible when read from stdin. So this patch allocate a memstream first and read the softmask into this memstream.
Comment 4 Albert Astals Cid 2016-09-28 22:01:26 UTC
worth using doGetChars instead of a one by one read?
Comment 5 Thomas Freitag 2016-09-29 07:38:00 UTC
Created attachment 126845 [details] [review]
read softmask into memstrean in case of matte

Sure, ALbert. I searched for that function but missed it, found just getChars() which is private.
Here the new patch.
Comment 6 Albert Astals Cid 2016-11-29 23:15:14 UTC
Pushed.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.