Skip to content

Instantly share code, notes, and snippets.

@Metaxal
Created December 2, 2025 21:57
Show Gist options
  • Select an option

  • Save Metaxal/bd02d44439beb955b7a87bef0c31faea to your computer and use it in GitHub Desktop.

Select an option

Save Metaxal/bd02d44439beb955b7a87bef0c31faea to your computer and use it in GitHub Desktop.
Pict to pdf
#lang racket/base
(require pict
racket/draw
racket/class
define2)
(provide (all-defined-out))
(define (pict->pdf scene out-file)
(define pdf-dc
(new pdf-dc%
[interactive #f]
[width (* .82 (pict-width scene))]
[height (* .82 (pict-height scene))]
[output out-file]))
(send pdf-dc start-doc "start pdf")
(send pdf-dc start-page)
(draw-pict scene pdf-dc 0 0)
(send pdf-dc end-page)
(send pdf-dc end-doc))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment