Version 18 of Trampoline!

Updated 2006-11-27 18:23:05

Mac Cody's nearly pure-Tcl PDF-savvy extension, whose home is on SourceForge at http://trampoline.sourceforge.net


RS: Trampoline is also a coding concept to allow unbounded recursion.


Trampoline is an extension to enable Adobe PDF output from the canvas. From SourceForge:-

Trampoline! is a nearly pure-Tcl library extension that generates an Adobe Portable Document Format (PDF) document based upon the content of a Tk canvas. The intent of this extension is to provide a "modern" replacement for the Tk canvas widget command postscript, which generates a Postscript document based upon the content of a Tk canvas. Trampoline! is striving to be compliant with Adobe PDF Reference version 1.4.

DPE 10 May 2005 Thanks for a useful package. I found a bug with text that contains nothing but whitespace that causes generate to fail. This can be fixed by adding the following lines near the top of TextConvert:

      # Do not process blank text
      if {[string trim [$w itemcget $item -text]] == ""} {
          return ""
      }

MP 13 August 2005 Great package.

I also found a bug, only the visible part of the canvas is placed in the pdf. This can be overcome when replacing

      AppendPageObject [winfo width $w] [winfo height $w]

by

      set Size [$w cget -scrollregion]
      AppendPageObject [lindex $Size 2] [lindex $Size 3]

In the generate proc. I have not tested it when scrollregion is not set in the canvas definition

SH 27 November 2006 This isn't a bug, but a intended feature as one can see in the comment line above this command:

      # The page size mirrors the actual displayed geometry of the canvas.

You can also use

      set Size [$w bbox all]

for getting the area of the canvas where items are.


Alastair Davies uses this on the MacOS X platform, for which it needs one modification. The output file must be fconfigured with -translation binary instead of -translation lf (16 Aug 2006)


Category Package - Category Printing