Skip to content

Instantly share code, notes, and snippets.

@amoeba
Created July 31, 2009 18:42
Show Gist options
  • Save amoeba/159366 to your computer and use it in GitHub Desktop.
Save amoeba/159366 to your computer and use it in GitHub Desktop.
require 'prawn'
Prawn::Document.generate('crop-marks.pdf') do
spacing = 12
margin = 100
canvas do
# topleft corner
stroke_line [bounds.left + spacing, bounds.top - margin],
[bounds.left + margin - spacing, bounds.top - margin]
stroke_line [bounds.left + margin, bounds.top - spacing],
[bounds.left + margin, bounds.top - margin + spacing]
# topright corner
stroke_line [bounds.right - spacing, bounds.top - margin],
[bounds.right - margin + spacing, bounds.top - margin]
stroke_line [bounds.right - margin, bounds.top - spacing],
[bounds.right - margin, bounds.top - margin + spacing]
# bottomleft corner
stroke_line [bounds.left + spacing, bounds.bottom + margin],
[bounds.left + margin - spacing, bounds.bottom + margin]
stroke_line [bounds.left + margin, bounds.bottom + spacing],
[bounds.left + margin, bounds.bottom + margin - spacing]
# bottomright corner
stroke_line [bounds.right + spacing, bounds.bottom + margin],
[bounds.right - margin + spacing, bounds.bottom + margin]
stroke_line [bounds.right - margin, bounds.bottom + spacing],
[bounds.right - margin, bounds.bottom + margin - spacing]
end
end
@qipcreative
Copy link

Bottom right corner should be:

bottomright corner

  pdf.stroke_line [pdf.bounds.right - spacing, pdf.bounds.bottom + margin], 
              [pdf.bounds.right - margin + spacing, pdf.bounds.bottom + margin]
  pdf.stroke_line [pdf.bounds.right - margin, pdf.bounds.bottom + spacing], 
              [pdf.bounds.right - margin, pdf.bounds.bottom + margin - spacing]

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