Skip to content

Instantly share code, notes, and snippets.

@mohiji
Created July 10, 2012 23:45
Show Gist options
  • Save mohiji/3086990 to your computer and use it in GitHub Desktop.
Save mohiji/3086990 to your computer and use it in GitHub Desktop.
Handy Common Lisp + cl-pdf Snippet
(pdf:with-document ()
(pdf:with-page (:bounds pdf:*letter-portrait-page-bounds*)
(let ((width (elt pdf:*letter-portrait-page-bounds* 2))
(height (elt pdf:*letter-portrait-page-bounds* 3))
(helvetica (make-instance 'pdf:font)))
(loop for y from 20 to height by 20 do
(pdf:move-to 0 y)
(pdf:line-to width y))
(loop for x from 20 to width by 20 do
(pdf:move-to x 0)
(pdf:line-to x height))
(pdf:stroke)
(pdf:in-text-mode
(pdf:move-text 40 0)
(pdf:set-font helvetica 8.0)
(loop for y from 0 to height by 20 do
(pdf:draw-text (format nil "~a" y))
(pdf:move-text 0 20)))
(pdf:in-text-mode
(pdf:move-text 0 40)
(pdf:set-font helvetica 8.0)
(loop for x from 0 to width by 20 do
(pdf:draw-text (format nil "~a" x))
(pdf:move-text 20 0)))))
(pdf:write-document #P"guide.pdf"))
@mohiji
Copy link
Author

mohiji commented Jul 10, 2012

This generates a labeled grid on a US Letter sized page so that you can figure out how to lay things out later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment