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 an intended feature as one can see in the comment line above this command:
# The page size mirrors the actual displayed geometry of the canvas.
If you want to "capture" all items you can change the proc generate as follows:
# get the current bbox-coords and store them into variables foreach {topLeftX topLeftY bottomRightX bottomRightY} [$w bbox all] {break} # move all items so that the top left corner has the coords 0,0 $w move all [expr {-$topLeftX}] [expr {-$topLeftY}] # use the bbox-coords for width and heigth, instead of the winfo-stuff #AppendPageObject [winfo width $w] [winfo height $w] AppendPageObject [expr {$bottomRightX - $topLeftX}] [expr {$bottomRightY - $topLeftY}] AppendContentObject $w # move the items back to their original positions $w move all [expr {$topLeftX}] [expr {$topLeftY}]
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)
KPV (2008-01-28): Tried capturing the display of TkGoldberg and the resulting pdf fails to display with the error 'Too few operands'.
Also, I uncovered an 8.5 bug: InlineImage incorrectly treats the list rawRow as a string. Tcl 8.5 is now adding some braces to lists and so the call to binary will fail.
rattleCAD (2016-01-11):
old: regsub -all -- {((\#)|( ))} $rawRow {} row new: regsub -all -- {((\#)|( )|(\{)|(\}))} $rawRow {} row
works for me