Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

PDF via Perl?

by perlmonkey (Hermit)
on May 22, 2000 at 22:39 UTC ( [id://14253]=perlquestion: print w/replies, xml ) Need Help??

perlmonkey has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to create a platform independent document dynamically via a perl based website (running on Irix). The page formatting is critical, so ps or pdf is preferred. It is mandatory for my needs to be able to display the document on Irix, Linux, and windows 9X/NT machines.

Postscript seems to be a perfect solutions since there are nice modules like PostScript::Document, however getting a ps document to show/print in Linux or Windows is a pain since the only viewer I could find is ghostview or gsview. Also to get gsview installed on the users machines might be impossible since I am in a corporate environment and it is very difficult to get 'unsanctioned' programs installed by IS.

It would be ideal to be able to use Acrobat since that program is installed on every system around, and seems to be supported on every platform. But Acrobat only reads PDF files. So is there a way to get ps to pdf via perl (I dont see any PDF modules). Maybe there are legal issues with this from Adobe that I am unaware of? I am not sure if the pdf format is licensed or if just the adobe products that create pdf are licensed.

Any ideas on how to approach this problem, or does anyone know of a better solution? Thanks for any input!

Replies are listed 'Best First'.
Re: PDF via Perl?
by perlmonkey (Hermit) on May 23, 2000 at 05:40 UTC
    Once again, thanks for all the input.

    Unfortunatley I found the PDF package and the Text::PDF package fairly useless. They seem to be strong in reading a pdf file, but very weak or useless for actually creating a pdf file. I also did look into the ps2pdf which is not a bad solution if you want to install ghostscript. The "PDF file creator written in perl" seemed promising but it is licensed ... how lame. Also the txt2pdf is licensed so screw them. I was getting really depressed as it seems that everyone that touched pdf files was out to make a crapload of money (adobe of course being the worst offender).

    Anyway to wrap up my tale ... PDF::Create (duh!) It is not part of the PDF package apparently (different authors), but after another extensive search (eventually from freshmeat.net) I stumbled on a message that refered to it. BTW it is not in search.cpan.org. So I tried:perl -MCPAN -e "install 'PDF::Create'" and wah-lah! It worked, (and beautifully). Although it is simple, and not fully implemented yet it works beyond my needs. Here is a full program the creates a PDF file:
    use PDF::Create; use strict; my $pdf = new PDF::Create('filename' => 'test.pdf', 'Version' => 1.2, 'Author' => 'Perl Monger', 'Title' => 'Test Test'); my $page = $pdf->new_page; my $f1 = $pdf->font('Subtype' => 'Type1', 'Encoding' => 'WinAnsiEncoding', 'BaseFont' => 'Helvetica-Oblique'); $page->string($f1, 40, 30, 600, "Hello from pdf Hell!" ); $pdf->close;
    I hope others find this helpful.

    Update: PDF::Create Version 0.01 is now in search.cpan.org
      How can I output the Simplified Chinese Code with Correct 'Encoding'? When I use 'gb2312' or 'utf-8', there has the wrong output. Thanks!
RE: PDF via Perl?
by neshura (Chaplain) on May 22, 2000 at 22:44 UTC
RE: PDF via Perl?
by Russ (Deacon) on May 23, 2000 at 01:50 UTC
    I've done PDF via Perl where I work.

    We needed to spit out a number of forms on demand, so we made a blank form in PostScript and converted it to PDF. We would then print that as an object, followed by data objects (the actual text in the form), one per page. It made a very tight download (100's of printed pages would fit in just a few K), because we reused the PDF form object.

    There is nothing simple about PDF, but it can be done.

    Feel free to email me (Russ) if you need more information. I'll help you however I can.

    Russ

Re: PDF via Perl?
by lhoward (Vicar) on May 22, 2000 at 22:43 UTC
    I've never used either of these, but a quick search turned up these on CPAN.

Re: PDF via Perl?
by KM (Priest) on May 22, 2000 at 22:50 UTC
Re: PDF via Perl?
by perlmonkey (Hermit) on May 22, 2000 at 23:33 UTC
    Thanks everyone for your posts. Apparently my search was not that productive. I never think about search.cpan.org but or course I will next time. Somewhat in my defense I went to: http://www.cpan.org/modules/by-module/ as I always do, and the PDF module is not listed there. But the Text::PDF, which I didnt think to look for, is there.

    Hopefully at least one of the modules will be functional.

      If you ever get a chance, you should check out the CPAN.pm module. I personally hate it but I still use it to search for modules every now and then. It even lets you do regex searches for modules ;) but it never seems to install the modules correctly so I still do it by hand.

      72656B636148206C72655020726568746F6E41207473754A

        I live by CPAN.pm, it is awesome. I just didn't try
        perl -MCPAN -e "install 'PDF'"
        But now that I am looking at the modules they dont look to useful. They seem to be total alpha modules basically for reading pdf files. I dont see yet how to create one from scratch, although Text::PDF claims to be able to. And I dont see any examples yet. I am going to keep hacking.
Re: PDF via Perl?
by Anonymous Monk on May 23, 2000 at 09:39 UTC
    I realize this is a bit late, and I've not read through the article thoroughly, but I thought it might be worth mentioning just to provide another way to approach the problem. This method does not require a module, but does require Adobe Acrobat (not just Reader). It does seem a bit convoluted, but is well documented, and includes examples and resources (with even more options). http://www-4.ibm.com/software/developer/library/pdfs/
RE: PDF via Perl?
by Tibetan_Monk (Initiate) on May 22, 2000 at 23:58 UTC
    When all else fails 'search'. I have spent alot of time manually searching through cpan and never finding what I need. But when I do a search woola .. there it is. So you are not alone witht the cpan ignorance :}
Re: PDF via Perl?
by btrott (Parson) on May 22, 2000 at 22:44 UTC
    Did you see Text::PDF?

    I must admit, I've no experience with it, but it may suit your needs.

Re: PDF via Perl?
by Anonymous Monk on May 23, 2000 at 01:38 UTC
    I might suggest that you create the document in ps then just run it through ps2pdf which comes with every ghostscript install, i believe. So it should be on your IRIX box. Not exactly a great or fast solution but with some banging it could be made to work. If you know what your doing ghostscript itself can write pdf files ... pdfwrite is one of the standard 'output devices'.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://14253]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-03-29 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found