jordanbyron / prawn-labels

Prawn/Labels: A simple helper to generate labels for Prawn PDFs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to set font size

fkumro opened this issue · comments

How would I set the font size for the label text?

I tried setting it using document properties, but it did not change the font size.

document: {font_size: 10}

Then I looked at the prawn docs and tried to use the font_size method, but received a NoMethodError when using inside the render block

labels = Prawn::Labels.render(build_labels, :type => "Avery5160", :shrink_to_fit => true) do |pdf, label|
      font_size(10) do 
        pdf.text label
      end
    end

Thanks for any help!

You need to call font_size on pdf inside the block:

labels = Prawn::Labels.render(build_labels, :type => "Avery5160", :shrink_to_fit => true) do |pdf, label|
  pdf.font_size(10) do 
    pdf.text label
  end
end

Thanks - I actually just tried the following and it worked too

pdf.font_size 10
pdf.text 'text'

Thanks!