Version 58 of pdf4tcl

Updated 2010-03-01 13:38:31 by arjen
 What: pdf4tcl
 Where: http://pdf4tcl.berlios.de/ 
 Description: pdf4tcl is a tcl package for generating pdf files.
              It started as a port of pdf4php to the tcl language.
              Currently at version 0.7.
 Updated: 01/2010
 Contact: See web site

Peter Spjuth 2009-01-11: Pdf4Tcl is now a reasonably complete package, except for handling fonts and encodings outside the built-ins, which I think is a big "except" for a PDF generator. I would welcome any help to fill this gap since I don't have the knowledge or the time currently.

YS 2009-08-24: I've added support for embedding TrueType and Type1 fonts. New version sent to Peter Spjuth.

YS As Peter still didn't look at new pdf4tcl, I'm putting it here.

Peter Spjuth: 0.7 has been released, including YS patch.

SRIV 2009-01-12: I almost finished modifying pdf4tcl to use TclOO instead of snit. I'll benchmark the speed when I'm done, then send you a patch against v0.5 if it looks good.

AM (26 october 2009) Here is a High-level wrapper for pdf4tcl that allows you to create documents with almost no concern for low-level details, such as putting in new pages.

RA (27 Feb 2010) Are there any examples where this is used as an intermediate step to print to paper?

AM (1 march 2010) I am using it to generate a PDF file from a Wiki-like text format and as I hate reading large quantities of text from the screen, I send to the printer for reviewing (at the moment other things take up my time, but the principle works very nicely).


chd: Very, very nice package I was waiting so long for - now printing under Windows is simple :-) I have three suggestions: I have seen that there is now a putRawImage command - good :-) A small goodie would be a direct way to insert PNG, GIF, BMP like JPEG. A command to get the high of the current text line would be nice to have the option to exactly set a "tabulator" after a newLine command. Last but not least: calculating points is annoying. A command "setUnit mm/inch/points" would help a lot. (btw: I'm using pdf4tcl for my bookkeeping software to create invoices/lists/address labels - now I don't need LaTeX anymore :-)

Peter Spjuth 2008-02-06: Could you please put these into the Feature Request Tracker? As always, patches are welcome too :-) .

chd 2008-02-06: Done - I hope I will have the time (and skill! ;-) to submit some patches soon :-)


Sarnold: I have used pdf4tcl in a small tool to display some kind of report. To me it was a better way than canvas exporting (as Encapsulated PostScript). MHo: I'm using it in my photoprinter-tool, see Matthias Hoffmann - PhotoPrinter. We had exchanged emails about that months ago. Unfortunately, the tweaks you mailed me have not found their way into a new version....

jnc: Has anyone done anything more with pdf4tcl? I just got done creating a table layout process where you can easily create tables, split them across pages, repeat headers, etc... It's still very rough code. I was wondering what's been done with pdf4tcl before I go much further.

anoved: I used pdf4tcl to create strpdf [L1 ], a tool I use to generate pages with short positioned annotations.

anoved: What's new in 0.3? Peter Spjuth: I have added a changes list to the home page. Also, the SVN history starts with my 0.2 import so all changes can be seen in the history there.


MHo 2008-02-01: Just started my first experiments with v0.3:

  • When generating large amounts of data, the finish method blocks the gui / program. It seems that data is not written out to the -file specified with new before entering finish. Are there any intermediate flushes or updates within finish???
  • Worst than that, the generated pdf is - in my case - unreadable by pdf readers such as FoxitReader... I didn't change fundamental logic in my code between v0.2 and v0.3.
  • After examining the old and new source code, I wonder if perhaps there is missing some fconfigure ... binary (within write, there is one)???
  • A binary compare of my output files show some differences, one use \x0D, the other (new one) \x0D0A

Peter Spjuth: There was a fconfigure missing that was fixed a few days ago. Try the latest from SVN and see if it helps. Things should continuously be written to the file, except for channel buffering, while creating pages. Fonts and images are dumped in finish so a lot of those could slow that step down.

MHo: The PDF unfortunately almost only contains lots and lots of images (JPGs), because it's a photo album... I already tested the latest version :-(

Peter Spjuth: Does the :-( imply that it still gave corrupt data or that it still was slow? If the former, file a bug report on the tracker. If the latter, I don't know. I guess it might be possible to dump images in endPage thus distributing the load on the different calls, but I do not understand the image handling code enough to change that. Patches are welcome.

MHo: Yes, the :-( means data corruption - will post a detailed bug report if I find the time later...


Peter Spjuth 2008-02-27: The development version now has support for dumping a canvas to PDF. Anyone interested is welcome to test and provide feedback.

Bryan Oakley 2008-02-27: my first attempt didn't work. I created a canvas, dumped some text on it, then did this:

  % pdf4tcl::new mypdf -paper a4
  ::mypdf
  % mypdf canvas .c
  526
  % mypdf write -file canvas.pdf
  can't read "pdf(xref,4)": no such element in array

This is from the version on the trunk of the svn repository.

Peter Spjuth: You need an explicit mypdf startPage call after creation. That is a bug, but should be enough as a workaround.

Jeff Godfrey 2008-02-27: Yep, using the above workaround, the canvas output seems to work for me - even for a relatively complex canvas. Nice work!

Bryan Oakley a few moments later: Nice! Thanks. Now all I need is a way to replicate a text widget on a canvas and I'm all set. Good work, Peter.

Peter Spjuth: It is probably just as easy to replicate the text widget with pdf4tcl's primitives directly. This is roughly how printing is done in Eskil. Taking the route around the canvas will probably be harder to get right. Unfortunately the text item of the canvas is currently the one pdf4tcl has hardest to get right due to font limitations.


See http://pdf4tcl.berlios.de/tkdemo.pdf for the result on dumping goldberg and items canvases from Tk's demo.

KPV I notice several errors in rendering TkGoldberg.

  1. match box stippling is off
  2. string holding weight too short
  3. string has some off-by-one alignment issues
  4. weight's upper left shoulder not rounded
  5. ball hopper upper left corner not rounded
  6. ball hopper down tube walls thickness doesn't match
  7. three arcs by the boat are upside down
  8. yellow down tube has one arc drawn on top when it should be hidden below
  9. curved part of the gray water pipe is all messed up
  10. cat's face mis-drawn

On the other hand, the anti-aliased lines look much better--compare slingshot, bucket, balloon, on/off switch, etc.

Peter Spjuth: Thanks for the feedback.

  • 1 Looks to be some rounding artifact in the viewer. Zooming in, the patterns look OK.
  • 2 was a bug in 2-point spline line. Fixed.
  • 3: If you mean the vertical line up to middle pulley it is off by one in the original. It's just clearer in the PDF.
  • 4 and 5 was a bug in polygon with spline. Fixed.
  • 6: I don't understand what is meant.
  • 7, 8, 9, 10 was that arcs were flipped in y. Fixed.

escargo 28 Feb 2008 - How does this compare to tclhpdf [L2 ]?



Rfox 5 Mar 2008 Why not submit this for inclusion in tcllib?


See also pdflib - Trampoline!