Bug 691334

Summary: convert from PDF to JPG does not work with OpenType (otf) fonts
Product: Ghostscript Reporter: Steven Arnold <stevena>
Component: PDF InterpreterAssignee: Alex Cherepanov <alex>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P4    
Version: 8.70   
Hardware: All   
OS: Linux   
Customer: Word Size: ---
Attachments: Working and non-working PDFs
patch

Description Steven Arnold 2010-05-21 18:35:38 UTC
Created attachment 6312 [details]
Working and non-working PDFs

PDF images that I generate using the PDF::API2 Perl library do not convert to JPG using the ImageMagick convert command when the PDF uses OpenType (otf) fonts.  However, the process works fine when using TrueType (ttf) fonts.  The only difference in the creation of the two files is whether TTF fonts or OTF fonts are being used; all calls and other code used to create the files are identical.

Two example PDFs, one that works and one that does not work, are attached.

To connect this report more specifically to Ghostscript, note that the non-working file cannot be opened with the 'gs' command in X11.  The file opens, but before the text is displayed, the command errors out.  As you might expect, the file that does work does open fine using the same gs command in X11.  The non-working PDF does open fine in all other programs, such as Acrobat, Preview, PDFPen Pro and others, both on the machine that created the PDF and other machines.

This failure of the convert command has been tested on both RHEL and Mac OS X (Snow Leopard) platforms.

Using TrueType fonts, the command works fine:

[ 02:23 PM (352) continuum:thoth ~ ] > convert working.pdf working.jpg 
[ 02:23 PM (353) continuum:thoth ~ ] > ls working.jpg 
working.jpg

But when using OpenType fonts, the command fails as follows:

[ 02:13 PM (339) continuum:thoth ~ ] > convert not_working.pdf not_working.jpg Error: /undefined in --.execform1--Operand stack:   --dict:6/15(L)--   1   10   StMeCBB~1274465411   34   --dict:6/6(L)--   --dict:6/6(L)--   StoneSerifStd-Medium   --dict:11/12(ro)(G)--   --nostringval--   --dict:8/8(L)--   --dict:15/16(L)--   --dict:15/16(L)--   CIDFontName
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1862   1   3   %oparray_pop   1861   1   3   %oparray_pop   1845   1   3   %oparray_pop   --nostringval--   --nostringval--   2   1   1   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   20162   --nostringval--   1810   4   11   %oparray_pop   --nostringval--   false   1   %stopped_push   1809   4   11   %oparray_pop   --nostringval--   (gstatetype)   --dict:0/0(L)--   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1163/1684(ro)(G)--   --dict:1/20(G)--   --dict:75/200(L)--   --dict:75/200(L)--   --dict:106/127(ro)(G)--   --dict:285/300(ro)(G)--   --dict:22/25(L)--   --dict:4/6(L)--   --dict:21/40(L)--   --dict:1/1(ro)(G)--   --dict:1/1(ro)(G)--   --dict:6/15(L)--
Current allocation mode is local
GPL Ghostscript 8.70: Unrecoverable error, exit code 1
convert: Postscript delegate failed `not_working.pdf': No such file or directory @ pdf.c/ReadPDFImage/634.
convert: missing an image filename `not_working.jpg' @ convert.c/ConvertImageCommand/2838.
Comment 1 Alex Cherepanov 2010-05-23 00:13:32 UTC
Created attachment 6315 [details]
patch

Decide whether load a CFF font as a simple font or a CIDFont based on the
/Subtype of the font object instead of the /Subtype of the font stream.
Acrobat appears to ignore the latter and PDF producers may put
a wrong type.
Comment 2 Alex Cherepanov 2010-05-23 00:16:52 UTC
The fix has been committed as a rev. 11303.