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

Vertical alignment in PDF tables is broken #127

Open
rsynnest opened this issue Sep 5, 2021 · 0 comments
Open

Vertical alignment in PDF tables is broken #127

rsynnest opened this issue Sep 5, 2021 · 0 comments

Comments

@rsynnest
Copy link

rsynnest commented Sep 5, 2021

Valign does not work. :top ends up centered, :center ends up at the bottom, and :bottom ends up at the bottom correctly.

The original valign code was added in prawn:5cddc78a

I've written a small script that can be used to quickly test/iterate, for anyone out there who wants to try a fix. I am not a Ruby dev and there are no build instructions for this repo so I just slapped this together:

Build Environment

Project files:

main.rb
./prawn-table/    <----- clone of this repo

To rebuild the Gem with your changes, and rebuild the PDF:

cd ./prawn-table
rm prawn-table-*.gem && gem build prawn-table.gemspec
cd -
ruby main.rb

Contents of main.rb:

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'prawn'
  gem 'prawn-table', :path => './prawn-table'
end


Prawn::Document.generate('result.pdf') do

data = [ ["TOP", "", ""], ]
table data, :cell_style => { :valign => :top}
move_down 20

data = [ ["CENTER", "", ""], ]
table data, :cell_style => { :valign => :center}
move_down 20

data = [ ["BOTTOM", "", ""], ]
table data, :cell_style => { :valign => :bottom}
move_down 20


end

Results

The current codebase results in the following:
image

Simply commenting out prawn/table/cell/text.rb line 69 gives a better result in my opinion:
image

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

1 participant