Darren,
To do what you want to do, you need GhostScript and ImageMagick
installed. Your script (in PHP, Perl, or whichever) can then call
ImageMagick's "convert" program, and make the conversion.
convert sample.pdf sample.jpeg
-or-
convert sample.pdf sample.png
So, to make the conversion in PHP, just do:
exec("convert sample.pdf sample.jpeg")
You might also find this helpful:
http://www.samurajdata.se/~cj/ps.html
More information:
http://www.php.net/manual/en/function.exec.php
http://www.imagemagick.org/www/formats.html
Search Stragegy:
"php pdf" on google.com
--
samrolken-ga |
Request for Answer Clarification by
g8z-ga
on
29 Dec 2002 08:55 PST
hi,
I did as you said and received an error, "Portable Document delegate
failed". I cut and pasted the commands from the Unix command line
below. The first command verifies that ghostscript is installed, the
second command verifies that ImageMagick is installed, the 'ls' shows
that I have a pdf present, and the last command is the conversion
attempt. What am I doing wrong?
[windsor@borg alphatest]$ ghostscript
GNU Ghostscript 6.52 (2001-10-20)
Copyright (C) 2001 artofcode LLC, Benicia, CA. All rights reserved.
This software comes with NO WARRANTY: see the file COPYING for
details.
GNU Ghostscript 6.52: Cannot open X display `(null)'.
**** Unable to open the initial device, quitting.
[windsor@borg alphatest]$
[windsor@borg alphatest]$ identify logo:
640x480+0+0 PseudoClass 256c 26kb GIF 0.0u 0:01
[windsor@borg alphatest]$
[windsor@borg alphatest]$ ls
test.pdf
[windsor@borg alphatest]$ convert test.pdf test.jpeg
convert: Portable Document delegate failed (test.pdf).
convert: Missing an image file name.
|
Clarification of Answer by
samrolken-ga
on
29 Dec 2002 15:58 PST
Please tell me which operating system you are using so that I may
provide instructions for installing or compiling a ghostscript-aware
version of ImageMagick.
--samrolken-ga
|
Request for Answer Clarification by
g8z-ga
on
29 Dec 2002 16:34 PST
hi,
The system is Linux. However, I'm not sure if recompiling is an option
available to me. The website that I'm trying to do this on is remotely
hosted, although I do have telnet access. In other words, I don't have
root privileges.
Is there some way to do the conversion by calling a ghostscript
function first, and then calling ImageMagick on the result, or by some
other method altogether? If not, then please provide the recompilation
instructions and I'll see if the hosting company will do it for me or
if it's possible via telnet.
Thanks,
Darren
|
Clarification of Answer by
samrolken-ga
on
29 Dec 2002 16:48 PST
Can you try executing this:
gs -sDEVICE=jpeg -sOutputFile=test.jpg test.pdf
-- samrolken-ga
|
Clarification of Answer by
samrolken-ga
on
03 Jan 2003 04:35 PST
As a little follow-up to your question, I wanted to let you know that
I came across the source code to a site that does the exact thing that
you want to do. The guy who runs http://www.samurajdata.se/~cj/ps.html
was kind enough to send me the GPL'ed source code to his website
(written in PHP) that does the exact same thing that you need to do. I
have put it up at http://samk.org/files/psview-2.0.tar.gz. I hope this
helps, and I wish you luck.
-- samrolken-ga
|
Request for Answer Clarification by
g8z-ga
on
04 Jan 2003 17:50 PST
hi,
Thanks for the additional clarification. It looks like your answer
does exactly what I need.
I tried the link that you provided and it seems to be invalid... could
you check that URL one more time?
Thanks for an excellent answer.
|
Clarification of Answer by
samrolken-ga
on
04 Jan 2003 18:53 PST
Oops! Sorry about that. The correct URL is
http://samk.org/files/psview-0.2.tar.gz .
--
samrolken-ga
|