Created
July 10, 2012 23:45
-
-
Save mohiji/3086990 to your computer and use it in GitHub Desktop.
Handy Common Lisp + cl-pdf Snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This generates a labeled grid on a US Letter sized page so that you can figure out how to lay things out later.