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

pdf4tcl

149 views
Skip to first unread message

DrS

unread,
Dec 29, 2011, 3:21:59 PM12/29/11
to
Is anyone using this package? I wonder how the package handles page
boundaries when printing several pages of plain text.

I would like to generate a pdf that will contain lots of plain text.
But I don't really want to calculate font sizes and page heights, etc.
in order to start and end pages. I just would like to set a title, and
start printing line by line. I wonder if this is possible.

Thanks!

DrS

Jeff Godfrey

unread,
Dec 29, 2011, 4:29:40 PM12/29/11
to
I have used pdf4tcl in some past projects, and with good luck. I don't
have access to any code right now, so I'm going from memory here, but...

I don't think it'll automatically generate page breaks for you, but it's
easy to request a current page position. So, for instance, after you
generate your each line of text, you could ask it where you are on the
page. Once you've reached a given threshold, you can easily generate a
new page yourself.

So, while not fully automatic, it should be quite easy to do what you need.

Jeff

Robert Heller

unread,
Dec 29, 2011, 4:48:44 PM12/29/11
to
You will have to calculate font sizes and page heights to determine when
to end a page and start a new one. I don't think there is any way
around this.

What *I* would do is create a snit class that uses this package to
create an abstraction level for printing lines of text and internally
maintains the page position and takes care of starting new pages as
needed.

>
> Thanks!
>
> DrS
>

--
Robert Heller -- 978-544-6933 / hel...@deepsoft.com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments



arjenmarkus

unread,
Dec 30, 2011, 2:21:39 AM12/30/11
to
On 2011-12-29 22:48, Robert Heller wrote:
> At Thu, 29 Dec 2011 15:21:59 -0500 DrS <drsc...@gmail.com> wrote:
>
>> Is anyone using this package? I wonder how the package handles page
>> boundaries when printing several pages of plain text.
>>
>> I would like to generate a pdf that will contain lots of plain text.
>> But I don't really want to calculate font sizes and page heights, etc.
>> in order to start and end pages. I just would like to set a title, and
>> start printing line by line. I wonder if this is possible.
>
> You will have to calculate font sizes and page heights to determine when
> to end a page and start a new one. I don't think there is any way
> around this.
>
> What *I* would do is create a snit class that uses this package to
> create an abstraction level for printing lines of text and internally
> maintains the page position and takes care of starting new pages as
> needed.
>

Have a look at this Wiki page: http://wiki.tcl.tk/24593

It presents exactly such a wrapper, even though it is probably very much
tuned to my purposes. At least it will give you an idea on how to
proceed.

Regards,

Arjen

Peter Spjuth

unread,
Dec 30, 2011, 7:46:14 AM12/30/11
to
pdf4tcl mostly provides primitives and not much of higher level page
handling.
Such things are very application dependent and it's hard to make
generally useful
utilities for them. But I welcome suggestions, and even more I welcome
patches.

For simple text the drawTextBox provides some help. Below is an
example that dumps
raw text to a PDF. Note that drawTextBox currently left aligns rows
so for example
indentation is lost.

package require pdf4tcl

set data [read stdin]

pdf4tcl::new mypdf -paper a4 -margin 20m

foreach {w h} [mypdf getDrawableArea] break
mypdf setFont 12 Courier
while {$data ne ""} {
mypdf startPage
set data [mypdf drawTextBox 0 0 $w $h $data]
}
mypdf write -file testtext.pdf
mypdf cleanup

/Peter

DrS

unread,
Dec 30, 2011, 10:14:30 AM12/30/11
to
On 12/30/2011 7:46 AM, Peter Spjuth wrote:
> On Dec 29, 9:21 pm, DrS<drscr...@gmail.com> wrote:
>
>
> pdf4tcl mostly provides primitives and not much of higher level page
> handling.
> Such things are very application dependent and it's hard to make
> generally useful
> utilities for them. But I welcome suggestions, and even more I welcome
> patches.
>


Much thanks to all for their suggestions. It looks like all I need to
do is do a few simple calculations to control pagination. Arjen's
example may be a good starting point for this. This is a nice to have
for me at this point but if I end up implementing a wrapper around it, I
will post it to the wiki.


Sincerely,

DrS

Jeremy Cowgar

unread,
Dec 30, 2011, 1:14:50 PM12/30/11
to
I have table code that supports column spanning, header rows, automatic
page breaks/repeating headers.

I feel bad, but I just bunched it all together in one file, that is sort
of a mess, but it all works. It needs cleaned up and I have been waiting
on that to release the code but I am unsure when I will get to it. If
anyone wants the code, they can send me an email and I'll attach it in a
reply.

Jeremy


0 new messages