Bug 697654 - Can't convert PDF to image
Summary: Can't convert PDF to image
Status: RESOLVED INVALID
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Interpreter (show other bugs)
Version: 9.20
Hardware: PC Windows 10
: P4 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-08 05:11 UTC by v.ripoll
Modified: 2017-09-19 22:32 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
The PDF that can't be converted to an image. (1.16 MB, application/pdf)
2017-03-08 05:11 UTC, v.ripoll
Details

Note You need to log in before you can comment on or make changes to this bug.
Description v.ripoll 2017-03-08 05:11:37 UTC
Created attachment 13460 [details]
The PDF that can't be converted to an image.

I tried to convert a PDF using the following command line:

http://www.vekn.fr/graphical_design/doc.pdf 

"c:\Program Files (x86)\gs\gs9.20\bin\gswin32c.exe" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -sOutputFile=test.tif doc.pdf

and got the following error:

Error: /undefined in --get--
Operand stack:
   --dict:5/5(L)--   0   false   1   --dict:6/14(L)--   --dict:6/14(L)--   Subtype
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1983   1   3   %oparray_pop   1982   1   3   %oparray_pop   1966   1   3   %oparray_pop   --nostringval--   --nostringval--   2   1   1   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --dict:6/6(L)--   --nostringval--   4   %dict_continue   --nostringval--
Dictionary stack:
   --dict:1200/1684(ro)(G)--   --dict:1/20(G)--   --dict:83/200(L)--   --dict:83/200(L)--   --dict:135/256(ro)(G)--   --dict:291/300(ro)(G)--   --dict:30/32(L)--   --dict:0/6(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.20: Unrecoverable error, exit code 1

I have the same error if I try to create a .jpg file.

I tried the same command with another PDF, and it works (I can see the pages if I remove the QUIET NOPAUSE and NOPROMPT flags)

The PDF file has 1 page containing 3 CMYK tif images, one of which has a transparent area.

Thanks for your help.
Comment 1 Ken Sharp 2017-03-08 05:17:28 UTC
Adobe Acrobat is unable to open this PDF file it throws an error 'expecting a name object'. Looks to me like your file is simply broke.
Comment 2 v.ripoll 2017-03-08 05:20:27 UTC
Indeed, I work with Foxit PhandomPDF and it opens it just fine.
When I tried with Adobe Acrobat Reader DC, I got an error (18). I will investigate in that direction.
Comment 3 v.ripoll 2017-03-08 07:18:50 UTC
I confirm this issue can be closed. The PDF document was not properly created (even though it opens without error in Foxit PhantomPDF).
Comment 4 Ken Sharp 2017-03-08 07:33:18 UTC
FWIW, the problem here is that the page dictionary defines an XObject Resource 'XF1':

      /Xf1 1 0 R

But object 1 is defined as an ICC profile:

1 0 obj
<<
  /Alternate /DeviceCMYK
  /N 4
  /Length 557168
>>
stream

which is used by object 2 as a colorspace resource:

2 0 obj
<<
  /Type /XObject
  /Subtype /Image
  /Width 19
  /Height 24
  /Length 1824
  /ColorSpace [ /ICCBased 1 0 R ]
  /BitsPerComponent 8
>>

Clearly the definition of the XObject in the page Resources dictionary is incorrect, but the page stream uses that XObject:

q 0.033333 0 0 0.033333 0.236378 0.25348 cm /Xf1 Do Q

This means that the PDF consumer would have to treat an ICC profile as an image. Obviously it can't do that. Presumably Foxit simply (and silently!) ignores the error and fails to draw that image XObject.

Removing the spurious entry from the page resources dictionary and the use from the content stream, results in a file which all the PDF consumers I have will open without error.