[geeklog-devel] PDF from article

Tom websitemaster at cogeco.net
Sat Jan 3 13:13:47 EST 2015

I think at least updating the printable story format to use some css would
be nice. I know a lot of my articles in printed format do not look very
nice. I wouldn't use the pdf option but I can see where that would be handy
for others as well.

Does all the css get included (plugins etc...) or just the themes? The
reason I am asking is that the odd time I have an autotag in my story that
it's output has classes that requires it's plugins css. Not a huge deal just
thought I would ask.


-----Original Message-----
From: geeklog-devel [mailto:geeklog-devel-bounces at lists.geeklog.net] On
Behalf Of Dirk Haun
Sent: January-03-15 9:04 AM
To: Geeklog Development
Subject: [geeklog-devel] PDF from article

So I need to create PDFs from some of my articles. Only new ones, actually,
so I don't mind a little extra manual work. I thought I'd simply use the
"print to PDF" option from my operating system (Mac OS X, but Windows or
Linux have similar options, AFAIK). The results weren't what I was hoping
for, though.

Just printing the "normal" article view will include the site's header and
footer, as well as all the stuff displayed in the side blocks (e.g. Who's
online) that you don't really need here.

The dedicated "print" view that we have, however, doesn't load the
stylesheet. So the article's formatting is lost, images don't show up as
expected and so on.

I wonder if our print view really makes sense like that. Shouldn't we at
least load the stylesheet to preserve the formatting?

After hacking that in, I encountered another problem: Links in the article
are shown underlined but the actual URL they link to is lost. While you can
make URLs in PDFs work like in HTML that would require creating the entire
PDF from within Geeklog with the help of a PDF library (PDFlib or the like)
and I didn't really want to invest that much time.

So I extracted the URLs from the article text and added them as footnotes at
the end of the article. I also removed the underlines and instead inserted
the footnote number in the text.

The result isn't perfect - it doesn't handle page breaks, for example. But
I'm quite please with the way it looks. It's a clean look (without the
site's header/footer or side blocks) but properly formatted. And you still
get the URLs of the linked sites (the Mac OS X Preview app actually lets you
click on those, at least the ones that don't wrap).

The code I came up with for this is not very elegant, though, to put it
mildly. It also includes some code to handle special cases on my site.
Still, I was wondering if I should try and integrate some of this back into
Geeklog and in which way. Right now, I gave it a separate link, /pdf instead
of /print. But, as stated above, maybe it would make more sense to modify
the existing print view and make it more usable.



P.S. Some of you may remember that Geeklog did have an option to generate
PDFs at one point. But it didn't really work all that well and was
eventually removed again.


geeklog-devel mailing list
geeklog-devel at lists.geeklog.net

More information about the geeklog-devel mailing list