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

Creating PDFs with tcl

420 views
Skip to first unread message

Giorgio Valoti

unread,
Jul 10, 2008, 3:30:03 PM7/10/08
to
Hi all, I’m looking for a tcl solution to create pdf documents.
As far as I know, these documents do not have very sophisticated
layout/typography requirements, however, I have to deploy the solution
on Mac OS X (which excludes pdflib, I think) and I have to generate the
document outline. Are there any tools that I can use via tcl?

Thank you in advance
--
Giorgio Valoti

Torsten Berg

unread,
Jul 10, 2008, 3:51:28 PM7/10/08
to

This may contain what you want:

Trampoline! (http://wiki.tcl.tk/13033): To convert a canvas into pdf
pdf4tcl (http://wiki.tcl.tk/13449): drawing commands on a pdf page
text2pdf (http://wiki.tcl.tk/20179): for simple text into pdf
htmldoc ( http://www.easysw.com/htmldoc/ )

Other pointer are here: http://wiki.tcl.tk/pdf

Torsten

Cameron Laird

unread,
Jul 10, 2008, 4:23:17 PM7/10/08
to
In article <21f2f3fa-36de-4c79...@25g2000hsx.googlegroups.com>,
.
.
.
I seem to be putting a lot of my time these days to management of
PDF images; while there is a WIDE range in approaches, perhaps I,
also, can help.

Why do you think that PDFlib is not available for Mac OS? <URL:
http://www.pdflib.com/download/pdflib-family/pdflib-7/ > says
otherwise.

My default approach for many situations has become to generate
HTML, and transform HTML to PDF using any of several nice
renderers <URL:
http://phaseit.net/claird/comp.text.pdf/PDF_converters.html#html2ps >.
I can't tell from your description how well that fits your situation.

Giorgio Valoti

unread,
Jul 11, 2008, 2:05:35 AM7/11/08
to
On 2008-07-10 22:23:17 +0200, cla...@lairds.us (Cameron Laird) said:

> In article <21f2f3fa-36de-4c79...@25g2000hsx.googlegroups.com>,
> Torsten Berg <be...@typoscriptics.de> wrote:
>>
>>> Hi all, I’m looking for a tcl solution to create pdf documents.
>>> As far as I know, these documents do not have very sophisticated
>>> layout/typography requirements, however, I have to deploy the solution

>>> on Mac OS X (which excludes pdflib, I think) […]


>
> Why do you think that PDFlib is not available for Mac OS? <URL:
> http://www.pdflib.com/download/pdflib-family/pdflib-7/ > says
> otherwise.

But I don’t see the tcl package for that platform :-/

>
> My default approach for many situations has become to generate
> HTML, and transform HTML to PDF using any of several nice
> renderers <URL:
> http://phaseit.net/claird/comp.text.pdf/PDF_converters.html#html2ps >.
> I can't tell from your description how well that fits your situation.

Probably so. Basically it’s a ~1000 pages catalog which will be updated
with a monthly schedule and if an additional step is needed it
shouldn’t be a problem and indeed I could be finally able to convince
the client to bring that pile of pages online ;-)

Thank you

--
Giorgio Valoti

dave.j...@googlemail.com

unread,
Jul 11, 2008, 4:32:09 AM7/11/08
to
On Jul 11, 7:05 am, Giorgio Valoti <giorgi...@mac.com> wrote:
> On 2008-07-10 22:23:17 +0200, cla...@lairds.us (Cameron Laird) said:
>
> > In article <21f2f3fa-36de-4c79-802e-c076277b8...@25g2000hsx.googlegroups.com>,

> > Torsten Berg <b...@typoscriptics.de> wrote:
>
> >>> Hi all, I’m looking for a tcl solution to create pdf documents.
> >>> As far as I know, these documents do not have very sophisticated
> >>> layout/typography requirements, however, I have to deploy the solution
> >>> on Mac OS X (which excludes pdflib, I think) […]
>
> > Why do you think that PDFlib is not available for Mac OS? <URL:
> >http://www.pdflib.com/download/pdflib-family/pdflib-7/> says
> > otherwise.
>
> But I don’t see the tcl package for that platform :-/
>
>
>
> > My default approach for many situations has become to generate
> > HTML, and transform HTML to PDF using any of several nice
> > renderers <URL:
> >http://phaseit.net/claird/comp.text.pdf/PDF_converters.html#html2ps>.
> > I can't tell from your description how well that fits your situation.
>
> Probably so. Basically it’s a ~1000 pages catalog which will be updated
> with a monthly schedule and if an additional step is needed it
> shouldn’t be a problem and indeed I could be finally able to convince
> the client to bring that pile of pages online ;-)
>
> Thank you
>
> --
> Giorgio Valoti

My vote is also for htmldoc, which we have used for the last 5 years
after a flirtation with pdflib. The primary benefits have been:

It simplified the document generation code
Headers and footers for free
The intermediate html lets you see easily where you have made mistakes

Dave

Giorgio Valoti

unread,
Jul 11, 2008, 8:52:00 AM7/11/08
to
On 2008-07-11 10:32:09 +0200, "dave.j...@googlemail.com"
<dave.j...@googlemail.com> said:

> On Jul 11, 7:05 am, Giorgio Valoti <giorgi...@mac.com> wrote:
>> On 2008-07-10 22:23:17 +0200, cla...@lairds.us (Cameron Laird) said:
>>> Torsten Berg <b...@typoscriptics.de> wrote:
>>
>>>>> Hi all, I’m looking for a tcl solution to create pdf documents.

>>>>> […]


>
> My vote is also for htmldoc, which we have used for the last 5 years
> after a flirtation with pdflib. The primary benefits have been:
>
> It simplified the document generation code
> Headers and footers for free
> The intermediate html lets you see easily where you have made mistakes

I’m reading from the documentation that stylesheets are not supported.
How did you find this limitation? Is using inline style attributes
enough for your needs?

--
Giorgio Valoti

Cameron Laird

unread,
Jul 11, 2008, 5:51:52 PM7/11/08
to
In article <g56t99$mgf$1...@nnrp.ngi.it>,

Giorgio Valoti <gior...@mac.com> wrote:
>On 2008-07-10 22:23:17 +0200, cla...@lairds.us (Cameron Laird) said:
.
.
.

>> Why do you think that PDFlib is not available for Mac OS? <URL:
>> http://www.pdflib.com/download/pdflib-family/pdflib-7/ > says
>> otherwise.
>
>But I don’t see the tcl package for that platform :-/
.
.
.
My secret's out! You're absolutely right; the company does
NOT supply the Tcl binding there. I've been using C and Python
PDFlib libraries, and ... well, obviously, my comment was at
best incomplete.

Cameron Laird

unread,
Jul 11, 2008, 5:55:14 PM7/11/08
to
In article <g56t99$mgf$1...@nnrp.ngi.it>,
Giorgio Valoti <gior...@mac.com> wrote:
.
.

.
>> I can't tell from your description how well that fits your situation.
>
>Probably so. Basically it’s a ~1000 pages catalog which will be updated
>with a monthly schedule and if an additional step is needed it
>shouldn’t be a problem and indeed I could be finally able to convince
>the client to bring that pile of pages online ;-)
.
.
.
Right: while PDF is capable of remarkable effects, my
experience is that they're entirely secondary to the
major gain which comes from a reasonable automation--
the convincing-the-client part just to do *something*.
So, for me, the main thing is to get some sort of
application going, and a passage through XHTML->PDF helps
me achieve quick but adequate results.

dave.j...@googlemail.com

unread,
Jul 11, 2008, 6:18:07 PM7/11/08
to
On Jul 11, 1:52 pm, Giorgio Valoti <giorgi...@mac.com> wrote:
> On 2008-07-11 10:32:09 +0200, "dave.joub...@googlemail.com"

Yes, we found in-line fine, because the documents we produce are
things like contracts of employment, guides to employment law etc, and
we were doing this long before there was a movement away from tables
to CSS for layout. We also found that their special comment tags, like
please do not start this paragraph unless there are at least X number
of lines left on this page, extremely useful. When we were trying to
do this in pdflib we were running around trying to do all sorts of
calculations. In addition, trying to work out how many pages the
document would take so that we could number the pages as 1/X 2/X etc
was in the end not worth it.

Dave

yahalom

unread,
Jul 11, 2008, 7:11:27 PM7/11/08
to
On Jul 12, 7:18 am, "dave.joub...@googlemail.com"
> Dave- Hide quoted text -
>
> - Show quoted text -

we use pd4ml http://pd4ml.com/ it is java based converter from html to
pdf. works fine for us. We needed unicode support which it has. it is
also quite simple to work with. But you would need to install java.

Giorgio Valoti

unread,
Jul 12, 2008, 1:43:43 AM7/12/08
to
On 2008-07-12 00:18:07 +0200, "dave.j...@googlemail.com"
<dave.j...@googlemail.com> said:

> […]


>>
>> I’m reading from the documentation that stylesheets are not supported.
>> How did you find this limitation? Is using inline style attributes
>> enough for your needs?
>>
>> --
>> Giorgio Valoti
>
> Yes, we found in-line fine, because the documents we produce are
> things like contracts of employment, guides to employment law etc, and
> we were doing this long before there was a movement away from tables
> to CSS for layout. We also found that their special comment tags, like
> please do not start this paragraph unless there are at least X number
> of lines left on this page, extremely useful.

oh yes, it can be a lifesaver.

--
Giorgio Valoti

Giorgio Valoti

unread,
Jul 12, 2008, 1:48:00 AM7/12/08
to
On 2008-07-12 01:11:27 +0200, yahalom <yaha...@gmail.com> said:

> […]


>>>>>>>> Hi all, I’m looking for a tcl solution to create pdf documents.
>>
>

> we use pd4ml http://pd4ml.com/ it is java based converter from html to
> pdf. works fine for us. We needed unicode support which it has. it is
> also quite simple to work with. But you would need to install java.

Mmh, that would not be a problem as Java comes preinstalled on Mac OS X.
--
Giorgio Valoti

joheid

unread,
Jul 12, 2008, 6:18:49 AM7/12/08
to

Another option would be pdflatex. preparing the text with templates
and a tcl script and pipe it through pdflatex. The typography would
be definitely the best -- the template preparation might be not that
easy.

--
Joachim Heidemeier

Donal K. Fellows

unread,
Jul 12, 2008, 9:54:28 AM7/12/08
to
joheid wrote:
> Another option would be pdflatex. preparing the text with templates
> and a tcl script  and pipe it through pdflatex. The typography would
> be definitely the best -- the template preparation might be not that
> easy.

As long as you're dealing with simple ASCII text, you can get
thoroughly excellent results that way. Outside the ASCII domain,
things get more complicated (alas).

Donal.

joheid

unread,
Jul 12, 2008, 1:55:43 PM7/12/08
to
On 12 Jul., 15:54, "Donal K. Fellows" <donal.k.fell...@man.ac.uk>
wrote:

ASCII might be a little too narrow, inputenc{utf8} and the babel
package have been around for a while ...
--
Joachim Heidemeier

Giorgio Valoti

unread,
Jul 14, 2008, 12:54:44 PM7/14/08
to
On 2008-07-12 12:18:49 +0200, joheid <joh...@ttiger.in-berlin.de> said:

> On 10 Jul., 21:30, Giorgio Valoti <giorgi...@mac.com> wrote:
>> Hi all, I’m looking for a tcl solution to create pdf documents.

>> […]


>> --
>> Giorgio Valoti
>
> Another option would be pdflatex. preparing the text with templates
> and a tcl script and pipe it through pdflatex. The typography would
> be definitely the best -- the template preparation might be not that
> easy.

Well, I’ve tried some time ago to create something with latex, but I
don’t know latex and this catalogue is full of tables that span across
multiple pages. Maybe for someone with (much?) more experience with
latex than me it could be an easy task to do but my results was, well,
pretty awful. :-(

--
Giorgio Valoti

Gerald W. Lester

unread,
Jul 14, 2008, 1:06:20 PM7/14/08
to

Giorgio,

I've done this a couple of years ago with tables that spanned 20 or so pages
in a catalog. As I recall, the trick was for me to run it through latex two
or three times to build indexes and some other housekeeping files before
running it through to produce the output.

This was also a Tcl script generating the latex file then causing the
processing to be done.


--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+

WL

unread,
Jul 14, 2008, 1:47:39 PM7/14/08
to
In article <9HLek.20492$%q.1...@newsfe24.lga>,
Gerald W. Lester <Gerald...@cox.net> wrote:
>Giorgio Valoti wrote:
> [woes with latex and tables]

>
>I've done this a couple of years ago with tables that spanned 20 or so pages
>in a catalog. As I recall, the trick was for me to run it through latex two
>or three times to build indexes and some other housekeeping files before
>running it through to produce the output.
>
>This was also a Tcl script generating the latex file then causing the
>processing to be done.

heh.. I did the exact same thing :) I used tcl to process a
csv file (output from excel) to generate a latex file. Ran
latex over and over again to generate the pdf itself.

Latex is pretty good about saying when it needs to be rerun.
The real trick, I think, is finding the right table package.
IIRC, think the default table environment doesn't handle
long tables that span multiple pages very well. I had to
use one of the long table packages. But, I was familiar
with latex at the time, so it was fairly simple to create a
script to do what I would do by hand.

In the long run, this worked out very well for me; I was
also able to generate a set of html files as well as the
pdf. For something that may change once a month, using
ps2pdf seems the simplest way.

--
WL
real mail: wliao at sdf loSnPesAtarM org
(remove the uppercase letters...)

Giorgio Valoti

unread,
Jul 14, 2008, 3:08:52 PM7/14/08
to
On 2008-07-14 19:47:39 +0200, m...@privacy.net (WL) said:

> In article <9HLek.20492$%q.1...@newsfe24.lga>,
> Gerald W. Lester <Gerald...@cox.net> wrote:
>> Giorgio Valoti wrote:
>> [woes with latex and tables]
>>
>> I've done this a couple of years ago with tables that spanned 20 or so pages
>> in a catalog. As I recall, the trick was for me to run it through latex two
>> or three times to build indexes and some other housekeeping files before
>> running it through to produce the output.
>>
>> This was also a Tcl script generating the latex file then causing the
>> processing to be done.
>
> heh.. I did the exact same thing :) I used tcl to process a
> csv file (output from excel) to generate a latex file. Ran
> latex over and over again to generate the pdf itself.
>
> Latex is pretty good about saying when it needs to be rerun.
> The real trick, I think, is finding the right table package.
> IIRC, think the default table environment doesn't handle
> long tables that span multiple pages very well. I had to
> use one of the long table packages. But, I was familiar
> with latex at the time, so it was fairly simple to create a
> script to do what I would do by hand.
>

> […]

mmh, maybe I should take a look at this option again. Do you have some
info about the packages, by any chance?

--
Giorgio Valoti

Torsten Berg

unread,
Jul 14, 2008, 5:58:43 PM7/14/08
to
The 'tabular' environment in LaTeX does only handle one-page tables.
You can fake some multipage tables with the 'tabbing' environment, but
this is tedious.

>
> mmh, maybe I should take a look at this option again. Do you have some
> info about the packages, by any chance?

I have also done this with LaTeX. I used the 'longtable' package. Here
is an example:

http://users.sdsc.edu/~ssmallen/latex/longtable.html

For me, this always worked out well. I first created a LaTeX file by
hand until it fitted my needs, then automated the task with Tcl.

As an aside: is there something like an embedded LaTeX, that can be
distributed together with a Tcl application and doesn't need a
thousand files? Something like LaTeX in a starkit??

Torsten

joheid

unread,
Jul 18, 2008, 2:15:18 AM7/18/08
to

Yes, longtable and / or ltxtable are the key packages. longtable can
distribute long tables over several pages, ltxtable is actually a
longtable with the possibility to have selfadjusting columns, i.e.
equally spread the remaining space to the remaining columns. Due to
the calculations 2-4 latex runs are necessary.
Another important package would be the array package, which allows the
definition of different column types, dcoloumn for numerical cols
adjusted at the decimal separator. and probably booktabs which aims to
prepare "classical" looking tables. The "LaTeX Companion" has an
extensive chapter on tables.
To have a smoother start with LaTeX, the frontend LyX (www.lyx.org)
could be a good choice.

--
Joachim

0 new messages