Discussion:
Server-side postscript-to-PDF on-the-fly conversion
Rob Gould
2010-03-27 04:41:19 UTC
Permalink
Is there a free solution out there that will enable me to take a PHP-generated postscript output file, and dynamically, on-the-fly convert it to a PDF document and send to the user as a download when the user clients on a link?

More description of what I'm trying to do:

1) I've got a web-page that accepts some user input
2) They hit SUBMIT
3) I've got a PHP file that takes that input and generates a custom Postscript file from it, which I presently serve back to the user. On a Mac, Safari and Firefox automatically take the .ps output and render it in Preview.
4) However, in the world of Windows, it seems like it'd be better to just convert it on-the-fly into a PDF, so that the user doesn't need to worry about having a post-script viewer app installed.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
David Robley
2010-03-27 05:23:40 UTC
Permalink
Post by Rob Gould
Is there a free solution out there that will enable me to take a
PHP-generated postscript output file, and dynamically, on-the-fly convert
it to a PDF document and send to the user as a download when the user
clients on a link?
1) I've got a web-page that accepts some user input
2) They hit SUBMIT
3) I've got a PHP file that takes that input and generates a custom
Postscript file from it, which I presently serve back to the user. On a
Mac, Safari and Firefox automatically take the .ps output and render it in
Preview.
4) However, in the world of Windows, it seems like it'd be better to just
convert it on-the-fly into a PDF, so that the user doesn't need to worry
about having a post-script viewer app installed.
Ghostscript is the first thing that comes to my mind; alternatively googling
for "convert postscript pdf" or similar might turn up other options.


Cheers
--
David Robley

To a cat, "NO!" means "Not while I'm looking."
Today is Sweetmorn, the 13rd day of Discord in the YOLD 3176.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Floyd Resler
2010-03-27 11:07:03 UTC
Permalink
Post by Rob Gould
Is there a free solution out there that will enable me to take a PHP-
generated postscript output file, and dynamically, on-the-fly
convert it to a PDF document and send to the user as a download when
the user clients on a link?
1) I've got a web-page that accepts some user input
2) They hit SUBMIT
3) I've got a PHP file that takes that input and generates a custom
Postscript file from it, which I presently serve back to the user.
On a Mac, Safari and Firefox automatically take the .ps output and
render it in Preview.
4) However, in the world of Windows, it seems like it'd be better
to just convert it on-the-fly into a PDF, so that the user doesn't
need to worry about having a post-script viewer app installed.
Is there a particular reason why you need to use Postscript? Can you
output it directly to PDF?

Take care,
Floyd

Sent from my iPhone
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Al
2010-03-27 15:07:43 UTC
Permalink
Post by Rob Gould
Is there a free solution out there that will enable me to take a PHP-generated postscript output file, and dynamically, on-the-fly convert it to a PDF document and send to the user as a download when the user clients on a link?
1) I've got a web-page that accepts some user input
2) They hit SUBMIT
3) I've got a PHP file that takes that input and generates a custom Postscript file from it, which I presently serve back to the user. On a Mac, Safari and Firefox automatically take the .ps output and render it in Preview.
4) However, in the world of Windows, it seems like it'd be better to just convert it on-the-fly into a PDF, so that the user doesn't need to worry about having a post-script viewer app installed.
http://pear.php.net/package/XML_fo2pdf
http://pear.php.net/package/File_PDF
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
tedd
2010-03-27 16:55:07 UTC
Permalink
Post by Rob Gould
Is there a free solution out there that will enable me to take a
PHP-generated postscript output file, and dynamically, on-the-fly
convert it to a PDF document and send to the user as a download when
the user clients on a link?
1) I've got a web-page that accepts some user input
2) They hit SUBMIT
3) I've got a PHP file that takes that input and generates a custom
Postscript file from it, which I presently serve back to the user.
On a Mac, Safari and Firefox automatically take the .ps output and
render it in Preview.
4) However, in the world of Windows, it seems like it'd be better
to just convert it on-the-fly into a PDF, so that the user doesn't
need to worry about having a post-script viewer app installed.
Rob :

Do you want something like this:

http://webbytedd.com/bb/pdf/

Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Ashley Sheridan
2010-03-27 17:21:48 UTC
Permalink
Post by tedd
Post by Rob Gould
Is there a free solution out there that will enable me to take a
PHP-generated postscript output file, and dynamically, on-the-fly
convert it to a PDF document and send to the user as a download when
the user clients on a link?
1) I've got a web-page that accepts some user input
2) They hit SUBMIT
3) I've got a PHP file that takes that input and generates a custom
Postscript file from it, which I presently serve back to the user.
On a Mac, Safari and Firefox automatically take the .ps output and
render it in Preview.
4) However, in the world of Windows, it seems like it'd be better
to just convert it on-the-fly into a PDF, so that the user doesn't
need to worry about having a post-script viewer app installed.
http://webbytedd.com/bb/pdf/
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
It doesn't seem to like characters outside the normal range. I tried a
name of '©œ£¿±®' (cruel parents I know!) and it added a lot of other
characters before each one as if it were made up of multibyte characters
that it didn't recognise.

Thanks,
Ash
http://www.ashleysheridan.co.uk
Yousif Masoud
2010-03-27 18:21:57 UTC
Permalink
Post by Rob Gould
Is there a free solution out there that will enable me to take a
PHP-generated postscript output file, and dynamically, on-the-fly convert it
to a PDF document and send to the user as a download when the user clients
on a link?
[...]
3) I've got a PHP file that takes that input and generates a custom
Postscript file from it, which I presently serve back to the user. On a
Mac, Safari and Firefox automatically take the .ps output and render it in
Preview.
[...]
I think you're looking for a PHP library that can take the output from the
function that produces the PS file and generates a PDF file which you then
send back to the user. I haven't come across such a utility.

I recommend generating a PDF file directly using PDFLib or FPDF (
http://www.fpdf.org/) if possible.

An alternative strategy (if you cannot create a PDF directly) could be:

1. Validate input and Generate PS file then go to 2 otherwise raise input
exception and exit
2. Write (1) to a temporary location then go to 3 otherwise raise file
generation exception and exit
3, Use a utility like ps2pdf (or ghostscript) to convert file to pdf then go
to 4 otherwise raise file conversion exception and exit
4. Serve (3) then go to 5 otherwise raise file transfer exception and exit
5. Delete files and exit normally

Tutorial on ps2pdf: http://www.linux.com/archive/feed/35022
Frank Arensmeier
2010-03-27 19:57:02 UTC
Permalink
Post by Rob Gould
Is there a free solution out there that will enable me to take a PHP-
generated postscript output file, and dynamically, on-the-fly
convert it to a PDF document and send to the user as a download when
the user clients on a link?
1) I've got a web-page that accepts some user input
2) They hit SUBMIT
3) I've got a PHP file that takes that input and generates a custom
Postscript file from it, which I presently serve back to the user.
On a Mac, Safari and Firefox automatically take the .ps output and
render it in Preview.
4) However, in the world of Windows, it seems like it'd be better
to just convert it on-the-fly into a PDF, so that the user doesn't
need to worry about having a post-script viewer app installed.
If your webserver runs on MacOSX, look out for a binary called
'pstopdf'. From the man page:

[...]
pstopdf is a tool to convert PostScript input data into a PDF
document. The input data may come from a file
or may be read from stdin. The PDF document is always written to
a file. The name of the output PDF file is
derived from the name of the input file or may be explicitly
named using the -o option.
[...]

Another option might be xpdf (http://www.foolabs.com/xpdf/). There are
several different tools bundled with that app and there might be some
ps -> pdf converter too.

Otherwise, there is always Ghostscript.

/frank
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Paul M Foster
2010-03-28 14:04:19 UTC
Permalink
On Sat, Mar 27, 2010 at 08:57:02PM +0100, Frank Arensmeier wrote:


<snip>
Post by Frank Arensmeier
If your webserver runs on MacOSX, look out for a binary called
[...]
pstopdf is a tool to convert PostScript input data into a PDF
document. The input data may come from a file
or may be read from stdin. The PDF document is always written to
a file. The name of the output PDF file is
derived from the name of the input file or may be explicitly
named using the -o option.
[...]
This is a fairly standard application on all *nix boxes. That's why
MacOS includes it. And if your hosting platform is Linux, it's probably
there as well.

Paul
--
Paul M. Foster
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Loading...