Skip to content

Instantly share code, notes, and snippets.

@afa
Forked from bradediger/checkbox_test.pdf
Last active September 15, 2015 15:48
Show Gist options
  • Select an option

  • Save afa/7a6958610202c8f95929 to your computer and use it in GitHub Desktop.

Select an option

Save afa/7a6958610202c8f95929 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
require 'prawn'
CHECKBOX = "\xE2\x98\x90" # "☐"
FILLED_CHECKBOX = "\xE2\x98\x91" # "☑"
Prawn::Document.generate("checkbox_test.pdf") do
# Use a font with the checkbox characters:
# http://www.fileformat.info/info/unicode/char/2610/fontsupport.htm
font "fonts/dejavu/ttf/DejaVuSans.ttf"
text "#{CHECKBOX} Not done yet"
text "#{FILLED_CHECKBOX} Complete!"
end
@afa

afa commented Sep 15, 2015

Copy link
Copy Markdown
Author
def checkbox(flag, x_position = 7, y_position = @pdf.cursor - 2)
  @pdf.bounding_box([x_position, y_position], width: 10, height: 12) do
    @pdf.stroke_bounds
    @pdf.text("X", align: :center, valign: :center) if flag
  end
end

просто сгенерить картинку в курсоре

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