I just started Perl this week. Yikes, gotta get it together.
Anyway, I've been looking at generating PDF files from a script, and
although I've found (what seem to be) a couple of solutions, I can't
tell if any of them are: (1)viable, (2) being used by anybody else, (3)
currently working, and so on. Googling hasn't turned up much in the way
of perl+pdf+mac, if you know what I mean. I looked at PDFLib Lite and
some CPAN modules like PDF Template. I've also seen some stuff to
convert PS to PDF. Any opinions?
I want to crunch up some data from either text files or a MySQL
database, and make attractive output. It's mostly boxes and plain text,
like a chart. But what's the easiest/simplest way to go? This is for
single-user, Panther, non-critical.
Thanks!
You can find a basic introduction to this in:
Shawn Wallace, Perl Graphics Programming. Cambridge: O'Reilly (2003), ch. 12.
Paul
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
What I do, that works very well, is to use perl to format data as
LaTeX documents and then use pdflatex or TeXshop's visual editor to
render the pdfs. You can even just drop a "system('pfdlatex')" at the
end of the perl script. If you don't already know LaTeX, you can
learn enough for this project in the time it takes to download
TeXshop, or the LaTeX binaries from fink or ports.
HTH,
--jay
> What I do, that works very well, is to use perl to format data as
> LaTeX documents and then use pdflatex or TeXshop's visual editor to
> render the pdfs. You can even just drop a "system('pfdlatex')" at the
> end of the perl script. If you don't already know LaTeX, you can
> learn enough for this project in the time it takes to download
> TeXshop, or the LaTeX binaries from fink or ports.
I'll second that. Using LaTeX you'll get damned fine looking documents
too.
I used to use Lyx to generate outline documents, which I then edited to
put my content in, so I had a template for an invoice, a template for my
CV, a template for ...
I see the perl Template Toolkit being quite useful for this if you want
to automate it.
--
David Cantrell | London Perl Mongers Deputy Chief Heretic
Some people grow out of the petty theft of childhood.
Others go on to become CEOs and politicians.
If you really mean charts, it may be that Graphviz will do what you
want. It's not trivial to learn, but it's certainly easier than
generating pdfs from raw data. It can output postcript files as well as
images. see:
http://search.cpan.org/~lbrocard/GraphViz/
http://www.graphviz.org/
otherwise, if it's only for local use, I don't think perl is the answer
unless one of your goals is to learn perl. You're probably better off
with a combination of applescript and omnigraffle, using OSX's built-in
pdf-printing (which is also applescriptable) to create the final
document. If your data is in a perl-friendly form, perhaps also
Mac::Glue to hold everything together.
will
> I want to crunch up some data from either text files or a MySQL
> database, and make attractive output. It's mostly boxes and plain
> text, like a chart. But what's the easiest/simplest way to go? This is
> for single-user, Panther, non-critical.
Hi Mike,
I think you should take a look at outputting to an HTML document. Perl
has lots of tools for this and you can make graphs in a variety of
ways. Simple bar graphs can be made by resizing a 1x1 pixel gif image
and placing it and labels in a table.
Or, for more complex graphs, I've used GDGraph.pm (I think that's the
name) and it worked great too. If I recall, it does pie charts, bar and
line charts and maybe some others too.
Sherm Pendley's "Fat Camel" and "GraphicsKit" has most of what you need
to create images on the fly with perl, so you may want to take a look
at that too.
You can always print the html doc to a PDF file using the standard
"Print" command and it would seem to me that you should be able to
print a saved document to PDF with a perl only solution, but I've never
tried. If not, you should be able to find an AppleScript that can batch
print a folder or list of documents that can be called from a perl
script.
Have fun!!
--
Bill S.
If it's charts in the sense of plotting data have a look at SVG, yet another Adobe format. Its scaleable vector graphics are drawn by an engine freely downloadable for a lot of platforms. The format is TEXT much like uncompressed PDF and is easily created with perl.
--
--> The best programming tool is a soldering iron <--
Thx
Mike
http://search.cpan.org/dist/SVG-TT-Graph
Prints out bar / pie / line graphs, it's designed for presentations
to managers - e.g. looks sweet, and has a fair number of options for
customisation.
Use this to generate the graphs and save them to disk, then pull the
graphs into a generated webpage (I'd recomend using Template Toolkit
to build this) which has all the copy on it.