Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Margin options work only with string keys #1011

Closed
rsov opened this issue Mar 13, 2017 · 3 comments
Closed

Margin options work only with string keys #1011

rsov opened this issue Mar 13, 2017 · 3 comments

Comments

@rsov
Copy link

rsov commented Mar 13, 2017

Prawn version: 2.2.0

class PdfWorksheet < Prawn::Document
  def initialize(doc)
      super('top_margin' => 85) # works
      super(top_margin: 85) # Does not
  end
end

The piece of code responsible is at: lib/prawn/document.rb:724

sides.zip(positions).each do |side, pos|
  new_margin = options["#{side}_margin"] || (margin[pos] if pos)
  state.page.margins[side] = new_margin if new_margin
end

Is it possible to make it accept symbols and strings as options?

Something like:
new_margin = options["#{side}_margin"] || options["#{side}_margin".to_sym] || (margin[pos] if pos)

According to the documentation it should take in a key
http://www.rubydoc.info/github/sandal/prawn/Prawn%2FDocument%3Ainitialize

@bvogel
Copy link

bvogel commented Mar 14, 2017

breaks my specs in prawn-templates as well

@bvogel
Copy link

bvogel commented Mar 14, 2017

this was introduced by #963 and would be (partly) fixed with #1003

@pointlessone
Copy link
Member

Fixed in 2.2.1

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

No branches or pull requests

3 participants