When convert PDF with invalid font, can I replace the font?

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
fcaserio
Posts: 26
Joined: 2007-03-19T15:22:12-07:00

When convert PDF with invalid font, can I replace the font?

Post by fcaserio »

Convert is acusing a missing font. In this case, is it possible to convert PDF replacing the missing font by another font?

Tks for helping

Bellow is what the prompt is returning:
-bash-3.2$ /usr/bin/convert -background white -colorspace RGB /home/acasa1/public_html/imagemagick/release.pdf -size 300x300 -resize 300x300 /home/acasa1/public_html/imagemagick/release.pdf.jpg
Error: /invalidfont in /findfont
Operand stack:
--dict:7/16(L)-- R10 11.04 --dict:4/4(L)-- --dict:4/4(L)-- Helvetica-Bold Helvetica-Bold
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1878 1 3 %oparray_pop 1877 1 3 %oparray_pop 1861 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-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- 1836 7 11 %oparray_pop
Dictionary stack:
--dict:1159/1684(ro)(G)-- --dict:1/20(G)-- --dict:75/200(L)-- --dict:75/200(L)-- --dict:108/127(ro)(G)-- --dict:288/300(ro)(G)-- --dict:22/25(L)-- --dict:6/8(L)-- --dict:21/40(L)-- --dict:3/5(L)-- --dict:8/15(L)--
Current allocation mode is local
Last OS error: 2
GPL Ghostscript 8.71: Unrecoverable error, exit code 1
convert: Postscript delegate failed `/home/acasa1/public_html/imagemagick/release.pdf': x681.cache @ error/pdf.c/ReadPDFImage/638.
convert: missing an image filename `/home/acasa1/public_html/imagemagick/release.pdf.jpg' @ error/convert.c/ConvertImageCommand/2919.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: When convert PDF with invalid font, can I replace the fo

Post by fmw42 »

IM relies upon Ghostscript delegate library to process PDF files. Your GS is rather old. Perhaps try upgrading and make sure you install the ghostscript fonts.
fcaserio
Posts: 26
Joined: 2007-03-19T15:22:12-07:00

Re: When convert PDF with invalid font, can I replace the fo

Post by fcaserio »

It's a shared server. Thay allready told me they cant update the ghostscript library.
Is there a convert param to indicate which font to use when the original font is not available?
tks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: When convert PDF with invalid font, can I replace the fo

Post by fmw42 »

fcaserio wrote:It's a shared server. Thay allready told me they cant update the ghostscript library.
Is there a convert param to indicate which font to use when the original font is not available?
tks
I do not know. That is something that has to do with Ghostscript. You would likely need to review the GS documentation or ask on GS forum. If you are lucky, perhaps some one else on this forum might know.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: When convert PDF with invalid font, can I replace the fo

Post by fmw42 »

/usr/bin/convert -background white -colorspace RGB /home/acasa1/public_html/imagemagick/release.pdf -size 300x300 -resize 300x300 /home/acasa1/public_html/imagemagick/release.pdf.jpg
Note that -size 300x300 will do nothing in this command. You might try without it.

If that does not work, then can you post a link to one of your problematic pdf files and we can at least test with other versions of GS and IM. You can upload your image to dropbox.com (public folder) and put a link here.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: When convert PDF with invalid font, can I replace the fo

Post by fmw42 »

/usr/bin/convert -background white -colorspace RGB /home/acasa1/public_html/imagemagick/release.pdf -size 300x300 -resize 300x300 /home/acasa1/public_html/imagemagick/release.pdf.jpg
If you are trying to maintain quality of your pdf when going to jpg, then you should use -density to supersample the pdf and remove the -size 300x300

Code: Select all

/usr/bin/convert -background white -density 300 -colorspace RGB /home/acasa1/public_html/imagemagick/release.pdf  -resize 300x300 /home/acasa1/public_html/imagemagick/release.pdf.jpg
Also you may want to use -colorspace sRGB on more current versions of IM, since there was a switch at one point in time to correct the misuse of -colorspace RGB to its proper -colorspace sRGB.

What version of IM are you using?
fcaserio
Posts: 26
Joined: 2007-03-19T15:22:12-07:00

Re: When convert PDF with invalid font, can I replace the fo

Post by fcaserio »

I'm not concerned about quality exactly. I want to prevent errors when thumbing PDFs.
This is a page with some tests
http://www.acasa.org.br/cgi-local/teste.php
I work from a long time with IM and PDFs, and on this particular server I'm having this problem.
I think that when the PDF is generated by word it includes a basefont tag, which is the issue that is causing IM to crash
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: When convert PDF with invalid font, can I replace the fo

Post by fmw42 »

fcaserio wrote:I'm not concerned about quality exactly. I want to prevent errors when thumbing PDFs.
This is a page with some tests
http://www.acasa.org.br/cgi-local/teste.php
I work from a long time with IM and PDFs, and on this particular server I'm having this problem.
I think that when the PDF is generated by word it includes a basefont tag, which is the issue that is causing IM to crash
We need a link to one problematic input PDF that can be downloaded as PDF in order to do any meaningful tests.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: When convert PDF with invalid font, can I replace the fo

Post by fmw42 »

These two images have alpha channels. JPG does not support transparency. The following commands work fine for me with IM 6.8.8.8 and GS 9.06

Code: Select all

convert document1.pdf -background white -flatten -resize 300x300 document1.jpg

convert release.pdf -background white -flatten -resize 300x300 release.jpg
I do not get any error messages about fonts.

It would appear that your GS may be too old or has been corrupt or your ISP has not installed the GS fonts.
fcaserio
Posts: 26
Joined: 2007-03-19T15:22:12-07:00

Re: When convert PDF with invalid font, can I replace the fo

Post by fcaserio »

On gs 9.* I dont have problems.
But the server is running gs 8.71
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: When convert PDF with invalid font, can I replace the fo

Post by fmw42 »

fcaserio wrote:On gs 9.* I dont have problems.
But the server is running gs 8.71
That is a GS problem and not an IM problem. You need to take that up with the providers of GS or your ISP. Or ask your questions on some GS forum.

Have you verified with your ISP that they have installed the GS fonts library and your account has the exported the path to GS fonts in your PATH or .profile file?
Post Reply