Skip to content

Instantly share code, notes, and snippets.

@shortsightedsid
Created July 6, 2010 08:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shortsightedsid/465162 to your computer and use it in GitHub Desktop.
Save shortsightedsid/465162 to your computer and use it in GitHub Desktop.
;; CL-PDF Hello World
;;
;; Use ASDF to load the CL-PDF library
;;
(asdf:operate 'asdf:load-op 'cl-pdf)
;;
;; Function to generate a Hello World pdf file.
;; On calling this function, you should see a pdf file
;; with a big Hello World in the center!
;;
(defun hello-world (file author title greeting)
"Create a Hello World PDF file"
(pdf:with-document (:title title :author author)
(pdf:with-page ()
(pdf:register-page-reference "page 1")
(pdf:with-outline-level ("Page 1" "page 1")
(let ((helvetica (make-instance 'pdf:font)))
(pdf:in-text-mode
(pdf:set-font helvetica 36.0)
(pdf:move-text 200 400)
(pdf:draw-text greeting)))))
(pdf:write-document file)))
(hello-world #P"d:/tmp/hello_world.pdf" "Sid H" "Hello World" "Hello World")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment