Invalidfont while converting PDF to JPG

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
nagapuspa57
Posts: 1
Joined: 2012-01-24T06:06:38-07:00
Authentication code: 8675308

Invalidfont while converting PDF to JPG

Post by nagapuspa57 »

Hi All. I new user in ImageMagick. I got problem while converting pdf file into jpg image using convert command via PHP Function (system, exec, shell_exec) on my web hosting. First, I try this command :

Code: Select all

convert foo.pdf foo.jpg
But error message appear like this :

Code: Select all

Error: /invalidfont in /findfont
Operand stack:
   --dict:9/18(L)--   F1   1   --dict:4/4(L)--   --dict:4/4(L)--   Helvetica   Helvetica
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1846   1   3   %oparray_pop   1845   1   3   %oparray_pop   1829   1   3   %oparray_pop   --nostringval--   --nostringval--   3   1   2   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   1804   7   9   %oparray_pop
Dictionary stack:
   --dict:1159/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:26/40(L)--
Current allocation mode is local
Last OS error: 2
I try to see font that installed on system using this command:

Code: Select all

convert -list font
And it turns out this font (Helvetica) has been installed in the system. And this is half of output:

Code: Select all

Path: /usr/lib64/ImageMagick-6.4.8/config/type-ghostscript.xml
  Font: Helvetica
    family: Helvetica
    style: Normal
    stretch: Normal
    weight: 400
    glyphs: /usr/share/fonts/default/Type1/n019003l.pfb
I was browse to many source and most of them suggest me to use -font argument to specify / self define like this:

Code: Select all

convert -font Helvetica foo.pdf foo.jpg
and also try another variant way, hoping to do the conversion using another font type like this:

Code: Select all

convert -font Bitstream-Vera-Sans-Roman foo.pdf foo.jpg
or

Code: Select all

convert -font /mypath/Arial.ttf foo.pdf foo.jpg
But that way also didn't change the condition. It's any way to fixed the problem without configure operating system. Because I use web hosting to do that and didn't have permission to configure operating system.

Thank's for replay. Best Regards.
indiego
Posts: 75
Joined: 2010-10-16T06:35:10-07:00
Authentication code: 8675308

Re: Invalidfont while converting PDF to JPG

Post by indiego »

I guess the font in not embedded and ghostscript is not able to access the local Helvetica font somehow.
You can test it with the 'pdffonts' tool, which is part of Xpdf (http://www.foolabs.com/xpdf/download.html)

pdffonts foo.pdf

and then look in the 'emb' (embedded) column for the Helvetica font. If possible create your pdf with embedded fonts (subset is sufficient).
Post Reply