Skip to content

Cannot output postscript (or svg) #13

@mark-summerfield

Description

@mark-summerfield

The docs don't show how to output to postscript or to svg.
Example:

#!/usr/bin/env wish9

package require tkpath

proc main {} {
    const BASENAME /tmp/tkpath_out
    const WIDTH 640
    const HEIGHT 480
    font create Courier -family Courier -size 18
    font create Helvetica -family Helvetica -size 18
    font create Times -family Times -size 18
    array set fontmap {
        Courier {Courier-Roman 18}
        Helvetica {Helvetica-Roman 18}
        Times {Times-Roman 18}
    }
    tkp::canvas .canv -width $WIDTH -height $HEIGHT
    pack .canv
    .canv create ellipse 150 150 -rx 130 -ry 130 -fill #00FF00 -stroke #FF0000 -strokewidth 15
    .canv create ellipse 270 270 -rx 110 -ry 110 -fill #FFFF00 -stroke #FF0000 -strokewidth 15
    .canv create ellipse 370 370 -rx 70 -ry 70 -fill #0000FF -stroke #FF0000 -strokewidth 15
    .canv create ptext 400 150 -fontsize 24 -fontfamily Courier -text "0O1lQ Courier " -textanchor w
    .canv create ptext 400 170 -fontsize 24 -fontfamily Helvetica -text "0O1lQ Helvetica " -textanchor w
    .canv create ptext 400 190 -fontsize 24 -fontfamily Times -text "0O1lQ Times " -textanchor w
    update
    .canv postscript -file $BASENAME.ps -colormode color -fontmap fontmap
    exec ps2pdf $BASENAME.ps $BASENAME.pdf
    file delete $BASENAME.ps
    exec {*}[auto_execok okular] $BASENAME.pdf &
    bind . <Escape> exit
}

main

If you comment out from the postscript line to the second exec line it shows the canvas correctly. But with the lines uncommented (as above) it just produces an error:

Error in startup script: gsave

    (generating Postscript for item 1)
    invoked from within
".canv postscript -file $BASENAME.ps -colormode color -fontmap fontmap"
    (procedure "main" line 22)
    invoked from within
"main"
    (file "/tmp/test.tcl" line 33)

I'm using Debian Linux.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions