Page 1 of 1

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

Posted: 2014-03-14T09:23:09-07:00
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.

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

Posted: 2014-03-14T09:27:26-07:00
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.

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

Posted: 2014-03-14T10:40:35-07:00
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

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

Posted: 2014-03-14T11:22:23-07:00
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.

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

Posted: 2014-03-14T11:25:32-07:00
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.

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

Posted: 2014-03-14T11:31:10-07:00
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?

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

Posted: 2014-03-14T12:10:48-07:00
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

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

Posted: 2014-03-14T12:44:33-07:00
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.

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

Posted: 2014-03-14T12:59:54-07:00
by fcaserio

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

Posted: 2014-03-14T13:24:51-07:00
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.

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

Posted: 2014-03-14T13:37:45-07:00
by fcaserio
On gs 9.* I dont have problems.
But the server is running gs 8.71

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

Posted: 2014-03-14T13:42:02-07:00
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?