Padding for single label
larzknoke opened this issue · 3 comments
Hello,
I don't know if anyone else is looking in here, but I'll try:
I there a way to add a padding/margin for the single label?
Thanks
Lars
It's not possible to add margin to a single label of a multi-label type. Say the type has 24 labels per page, you can change all 24 labels to have another margin/padding, but not 1 of the 24.. at least not without changing the internals of the gem a lot.
If you want to update the margin of the type itself, you'd do something like:
Prawn::Labels.types = {
"CustomLabel" => {
"paper_size" => "A4",
"columns" => 2,
"rows" => 2,
"left_margin" => 28,
"top_margin" => 28
}}
That merges the above type into the existing types already defined in the types.yaml file.
Prawn::Labels.generate("names.pdf", names, :type => "CustomLabel") do |pdf, name|
pdf.text name
end
sorry I used the wrong words. I mean I want to set a padding for all labels on the page (red line in the screenshot). To get some margin in the label itself. The options on the LabelTypes is for the hole page not for the single label (green line).
Now I do a workaround with a table inside the label and give the cell a padding.
Ah, you do that using the margin combined with the column and row gutter label options. You'll need to do some calculation, but this would be it:
left_margin = original outer margin (green line) + desired label left margin
right_margin = original outer margin (green line) + desired label right margin
column_gutter = desired label left margin + desired label right margin
top_margin = original outer margin (green line) + desired label top margin
bottom_margin = original outer margin (green line) + desired label bottom margin
row_gutter = desired label top margin + desired label bottom margin
To get exact values, use millimeters x 2.835 to get it to the needed point values when calculating above.