Server-side postscript-to-PDF on-the-fly conversion

Server-side postscript-to-PDF on-the-fly conversion

am 27.03.2010 05:41:19 von 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?

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

Re: Server-side postscript-to-PDF on-the-fly conversion

am 27.03.2010 06:23:40 von David Robley

Rob Gould wrote:

> 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.

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

Re: Server-side postscript-to-PDF on-the-fly conversion

am 27.03.2010 12:07:03 von Floyd Resler

On Mar 27, 2010, at 12:41 AM, Rob Gould wrote:

> 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.
>

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

Re: Server-side postscript-to-PDF on-the-fly conversion

am 27.03.2010 16:07:43 von Al

On 3/27/2010 12:41 AM, Rob Gould wrote:
> 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.
>
>


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

Re: Server-side postscript-to-PDF on-the-fly conversion

am 27.03.2010 17:55:07 von TedD

At 12:41 AM -0400 3/27/10, Rob Gould wrote:
>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.

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

Re: Server-side postscript-to-PDF on-the-fly conversion

am 27.03.2010 18:21:48 von Ashley Sheridan

--=-8PsfkjcCq6f0Ia8AFkGi
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Sat, 2010-03-27 at 12:55 -0400, tedd wrote:

> At 12:41 AM -0400 3/27/10, Rob Gould wrote:
> >Is there a free solution out there that will enable me to take a=20
> >PHP-generated postscript output file, and dynamically, on-the-fly=20
> >convert it to a PDF document and send to the user as a download when=20
> >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=20
> >Postscript file from it, which I presently serve back to the user.=20
> >On a Mac, Safari and Firefox automatically take the .ps output and=20
> >render it in Preview.
> >4) However, in the world of Windows, it seems like it'd be better=20
> >to just convert it on-the-fly into a PDF, so that the user doesn't=20
> >need to worry about having a post-script viewer app installed.
>=20
> Rob :
>=20
> Do you want something like this:
>=20
> http://webbytedd.com/bb/pdf/
>=20
> Cheers,
>=20
> tedd
> --=20
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>=20


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



--=-8PsfkjcCq6f0Ia8AFkGi--

Re: Server-side postscript-to-PDF on-the-fly conversion

am 27.03.2010 19:21:57 von Joseph Masoud

--001485eba0b2edaea20482cc5a5a
Content-Type: text/plain; charset=ISO-8859-1

On Sat, Mar 27, 2010 at 4:41 AM, Rob Gould wrote:

> 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

--001485eba0b2edaea20482cc5a5a--

Re: Server-side postscript-to-PDF on-the-fly conversion

am 27.03.2010 20:57:02 von Frank Arensmeier

27 mar 2010 kl. 05.41 skrev 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?
>
> 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.
>
>

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

Re: Server-side postscript-to-PDF on-the-fly conversion

am 28.03.2010 16:04:19 von Paul M Foster

On Sat, Mar 27, 2010 at 08:57:02PM +0100, Frank Arensmeier wrote:




>
> 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.
> [...]

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