Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Newbie, PDF

2 views
Skip to first unread message

Mike Lesser

unread,
Jan 31, 2005, 6:37:44 PM1/31/05
to mac...@perl.org
Hi all. Okay, where's that FAQ?

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!

Paul G. Hackett

unread,
Feb 1, 2005, 6:42:13 AM2/1/05
to mac...@perl.org
At 6:37 PM -0500 1/31/05, Mike Lesser wrote:
> I've been looking at generating PDF files from a script

You can find a basic introduction to this in:

Shawn Wallace, Perl Graphics Programming. Cambridge: O'Reilly (2003), ch. 12.

Paul

Adam Witney

unread,
Feb 1, 2005, 6:46:16 AM2/1/05
to MacOS X

Also take a look at PDF::API2, which is what I think is talked about in the
book mentioned below


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Jay

unread,
Feb 1, 2005, 10:09:07 AM2/1/05
to Mike Lesser, mac...@perl.org
All of the perl PDF options are pretty thin interfaces: they require a
good working knowledge of not only perl, but XML, the pdf layout, and
postscript, at least if you want your data to come out in some sort of
organized table. They're workhorses, but they're not for casual use.


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

David Cantrell

unread,
Feb 1, 2005, 10:12:19 AM2/1/05
to Jay, Mike Lesser, mac...@perl.org
On Tue, Feb 01, 2005 at 10:09:07AM -0500, Jay wrote:

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

William Ross

unread,
Feb 1, 2005, 11:55:11 AM2/1/05
to OS X Perl, Mike Lesser

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

Bill Stephenson

unread,
Feb 1, 2005, 12:17:37 PM2/1/05
to OSX Perl Group, Mike Lesser
On Jan 31, 2005, at 5:37 PM, Mike Lesser wrote:

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

Doug McNutt

unread,
Feb 1, 2005, 3:32:22 PM2/1/05
to OS X Perl
On 31 Jan 2005, at 23:37, Mike Lesser wrote:
>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.

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

Mike Lesser

unread,
Feb 2, 2005, 11:09:41 AM2/2/05
to mac...@perl.org
> Thanks Bill and thanks to everyone who responded. An excellent gang! I
> think the consensus is ...
>
> (1) I probably don't want to go directly to PDF; I need to create
> something else (something easier) and then, if I still want, convert
> or print to PDF.
> (2) Interim formats include HTML, XML, and LaTex, and maybe
> PostScript, in order of increasing complexity/learning curve
> (3) All of the above can be done with free stuff (super)
> (4) Perl _is_ probably a good solution for this, as opposed to PHP or
> another scripting language
>
> My output is charts like a collection of lists or tables, not graphs
> (yet), and it sort of resembles an invoice in some respects. It's
> essentially data extracted from MySQL, printed out nicely. A bitmap
> may be thrown in here or there, like a logo. I'm thinking that HTML &
> tables may be the easiest way; LaTex I have to research more.
>
I just had an epiphany: Pages from iWork. Pages apparently will import
XML, and AFAIK, XML is the native format. I can do the aesthetic stuff
right in pages and either edit or create the documents in XML with
Perl. How's that?

Thx
Mike

Leo Lapworth

unread,
Feb 2, 2005, 11:43:14 AM2/2/05
to Doug McNutt, OS X Perl
As someone has mentioned SVG I dont' feel so embarised plugging my own module:

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.

0 new messages