Vertical align not working in combination with rowspan
Opened this issue · 6 comments
I am hopefully not making a silly mistake, but I can't work out how to vertically align a cell with a rowspan correctly.
Here my minimal example:
require "prawn"
require "prawn/table"
Prawn::Document.generate('rowspan-valign-bug.pdf') do
table [
[{ content: "Foo", rowspan: 2, valign: :center }, { content: "1" }, { content: "2" }],
[{ content: "3" }, { content: "4" }]
]
end
The output then looks like this:
Am I missing something, is this expected behaviour or actually a bug?
To make sure I understand correctly, you expect 'Foo' to appear a little higher, correct? So that the spacing above and below the letters are more similar?
Yes, I expect the capital letter to be centered with the horizontal line on
the right side. But it seems like the 'Foo' starts right below of the line
- as if the top padding gets added twice.
Am 06.08.2015 23:31 schrieb "Evan Sharp" notifications@github.com:
To make sure I understand correctly, you expect 'Foo' to appear a little
higher, correct? So that the spacing above and below the letters are more
similar?—
Reply to this email directly or view it on GitHub
#52 (comment)
.
Yep I agree that looks like a bug. If you (or anyone else) has the time feel free to dive in and try to sort it out. I'm not sure when I'll get the chance but if I do I'll update the issue.
I have the similar problem.
I wanted to dynamically, it gives a table mix
https://drive.google.com/file/d/0B8r7Uu63KbCBcEttOWxPOFFfU3c/view?usp=sharing
this is my code source
class DisciplinesPdf < PdfA4p
def initialize(school, categories, current_user, view)
super()
=begin
if school.pdfp
encrypt_document(
:owner_password => "#{current_user.pdf_password}",
:user_password => "#{school.pdf_password}",
:permissions => {:print_document => false,
:modify_contents => false,
:copy_contents => false,
:modify_annotations => false})
end
=end
font_size 8
@school = school
#@disciplines = disciplines
@categories = categories
@view = view
# header
table_desciplines
# footer(current_user)
end
def table_desciplines
# font("#{Rails.root}/config/recipes/fonts/kacst_one_5.0/KacstOne.ttf") do
font("#{Rails.root}/config/recipes/fonts/amiri/amiri-boldslanted.ttf") do
text("بسم اللهّ الرّحمن الرّحيم".connect_arabic_letters, :direction => :rtl, :align => :center, :size => 18)
end
move_down 10
table header_rows do
style(
row(0),
:background_color => 'AFB8BE',
)
style(
columns(0),
:align => :center
)
style(
columns(-1),
:align => :center
)
style(
columns(2),
:align => :right
)
self.row_colors = ['F2F2F2', 'FFFFFF']
self.header = true
self.position = :center
self.cell_style = {:border_lines => [:dotted], :padding => [2, 4, 2, 4]}
end
end
def header_desciplines
[
{content: "N°", :font => "#{Rails.root}/config/recipes/fonts/amiri/amiri-boldslanted.ttf"},
{content: "Matieres", :font => "#{Rails.root}/config/recipes/fonts/amiri/amiri-boldslanted.ttf", colspan: 2}
# {content: "المواد".connect_arabic_letters.reverse, :font => "#{Rails.root}/config/recipes/fonts/amiri/amiri-boldslanted.ttf"},
# {content: "ر".connect_arabic_letters, :font => "#{Rails.root}/config/recipes/fonts/amiri/amiri-boldslanted.ttf"}
]
end
def rows_desciplines
@id = 0
@id1 = 0
@categories.map do |categorie|
[
{content: "#{@id+=1}", rowspan: categorie.nb},
{content: "#{categorie.name}", rowspan: categorie.nb},
{content: "x"}
# {content: "#{item.matiere_latin}".connect_arabic_letters.reverse, :font => "#{Rails.root}/config/recipes/fonts/amiri/amiri-boldslanted.ttf"},
# {content: @view.arabic_number("#{@id1+=1}".connect_arabic_letters), :font => "#{Rails.root}/config/recipes/fonts/amiri/amiri-boldslanted.ttf"}
]
end
end
def header_rows
[header_desciplines, *rows_desciplines]
end
end
I want a table exactly like that : https://drive.google.com/file/d/0B8r7Uu63KbCBSDVuUG83NWhrakU/view?usp=sharing