Tk Library Source Code

View Ticket
Login
Ticket UUID: 88507dbd48fb9cb40ffae049ed25c2d0050d7186
Title: Add PDF as possible output format for diagrams
Type: RFE Version:
Submitter: arjenmarkus Created on: 2014-12-03 08:35:27
Subsystem: tklib :: diagrams Assigned To: aku
Priority: 7 High Severity: Minor
Status: Open Last Modified: 2015-01-05 17:37:45
Resolution: Accepted Closed By: nobody
    Closed on:
Description:
Using Peter Spjuth's pdf4tcl package it is very easy to produce PDF files containing the displayed diagram. A possible use is for inclusion in Latex or Word documents.

Typical code to create the PDF file:

after 1000 {
    set pdf1 [::pdf4tcl::new %AUTO% -paper {9.5c 6.0c}]
    $pdf1 canvas .c -width 9.2c
    $pdf1 write -file $filename.pdf
}

(The [after] is to make sure the canvas has been drawn completely)
User Comments: aku added on 2015-01-05 17:37:45:

Fixed canvas_pdf.tcl - Version bumped to 1.0.1.

Fixed application.tcl - Version bumped to 1.3.

NOTE: Fixed your application patch, was not working as indented. 'package present' throws an error when the package is not present. You have to catch it, not [llength] on the error message you see in an interactive tclsh.

Revision [04b7108ed8]. Committed. Pushed. Note: This is on branch "dia-pdf".


arjenmarkus added on 2014-12-15 08:12:02:
I have attached a patch for application.tcl - to show an error on screen if Tk has been loaded.

arjenmarkus added on 2014-12-14 15:41:28:
I found a small bug in canvas_pdf.tcl -- .canvas should have been $canvas.

(Something unexpected happening with fossil - to be reported separately - prevents me from applying it directly).

Also, a small problem on Windows with the application submodule: errors are not shown when using wish (there is no proper terminal to show the error message in). Also to be reported separately.

aku added on 2014-12-11 19:51:23:

Commit [100fa48b6b]

Fixed oops. Updated pkgIndex.tcl to know about "canvas::pdf".


aku added on 2014-12-11 19:49:22:

Commit [2446bda270]. Pushed.

This is on branch "dia-pdf".

Implemented a package "canvas::pdf" which encapsulates the above code in a form usable to "diagram::application", i.e. the apps/diagram-viewer.

After installing the extended tklib the dia-viewer should automatically accept "pdf" as a new output format.

Please test.


Attachments: