jordanbyron / prawn-labels

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Top to bottom alignment is off on the Avery 5160 labels

Quikchek opened this issue · comments

We're attempting to use the madriska/prawn-labels gem and it's losing alignment row after row. At row 6 the print starts to overlap the edge of the label.

Just looking at the preview you can tell it won't print on the Avery 5160 labels, 3 x 10, 30 labels to a sheet.

Is there a special setting we need to use in the US? I see 8.5 x 11 is not the same as A4...don't know if this gem is designed for A4 sheet sizes.

We'd be grateful for any assistance or guidance you can provide.

Attached the pdf file. The bottom and top should be same distance from the edge as the labels are centered top to bottom. The top labels are clearly closer to the edge than the bottom labels. Attached pdf to this issue


This is our Code

members = members.map{|member| [ "#{member.first_name.titleize} #{member.last_name.titleize}", member.address, "#{member.city}, #{member.state} #{member.zip}"] }
Prawn::Labels.render( members, type: 'Avery5160', shrink_to_fit: true) do |pdf, member|
pdf.font 'Courier', style: :bold
pdf.font_size = 10
pdf.font_size = member[0].length > 15 ? 10 : 12
pdf.text member[0], align: :center

  pdf.font 'Courier'
  pdf.font_size  = 8


  pdf.text "#{member[1]}", align: :center
  pdf.text "#{member[2]}", align: :center
end

labels (4).pdf

Looks like the text content isn't vertically aligned within the label.

Give this a try and see if you can get your example code working:

http://stackoverflow.com/questions/7827916/prawn-is-there-a-way-for-vertical-alignment-of-all-content-in-a-box

@jordanbyron I know this issue is closed, but we were having the same problem. To get labels to fit, we overwrote the specifications with the following:

  "Avery5160" => {
      "paper_size" => "LETTER",
      "top_margin" => 36,
      "bottom_margin" => 15,
      "left_margin" => 15.822,
      "right_margin" => 15.822,
      "columns" => 3,
      "rows" => 10,
      "column_gutter" => 22,
      "row_gutter" => 0}

With the above, the the printed labels aligned properly with label grid. I am happy to issue a pr if you think there is merit to it.

@hoenth do you have a code example I could run that shows the problem?