Skip to content

Instantly share code, notes, and snippets.

@nassredean
Created October 23, 2015 15:54
Show Gist options
  • Save nassredean/8c7a3a83e17d3524c50d to your computer and use it in GitHub Desktop.
Save nassredean/8c7a3a83e17d3524c50d to your computer and use it in GitHub Desktop.
Prawn Lookahead Height
require "prawn"
@pdf = Prawn::Document.new(margin: 0)
@text = "Oh hai text rect. " * 10
@options = { :document => @pdf }
text_box = Prawn::Text::Box.new(@text, @options)
p "cursor before dry run: #{@pdf.cursor}"
p "whats the height before dry run?"
p "....who knows????" if text_box.height == 0
text_box.render(:dry_run => true)
p "whats the height after the dry run?"
p "#{text_box.height}" if text_box.height
p "cursor after dry run: #{@pdf.cursor}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment