Coder Social home page Coder Social logo

practicingruby / prawn-layout Goto Github PK

View Code? Open in Web Editor NEW
69.0 6.0 21.0 200 KB

NOTE: prawn-layout has been merged into the main prawn repository as of 2010.02.25 (http://github.com/sandal/prawn), however the stable branch of prawn-layout 0.8.x is still hosted here.

Home Page: http://github.com/sandal/prawn

License: Other

Ruby 100.00%

prawn-layout's Introduction

prawn-layout has been merged into http://github.com/sandal/prawn as of
2010.02.25.  The stable branch of 0.8.x is still hosted here, but after Prawn
0.9 is released, the issue tracker will be closed and development will cease on
this repository.

If you want to track the bleeding edge, head over to
http://github.com/sandal/prawn

prawn-layout's People

Contributors

andrewo avatar blaxter avatar bradediger avatar bragi avatar cassiomarques avatar huerlisi avatar jamis avatar practicingruby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

prawn-layout's Issues

table() runs indefinitely with long text

This snippet of code doesn't work properly on Prawn master and 0.7.1, it runs without stopping, like an infinite loop or something.

Prawn::Document.generate("wide_table.pdf") do
  data = []
  data << ["English 12 S1", "Shalabi", "some long text " * 20]
  table data
end

tested under Ruby 1.9.1p378 and ruby 1.8.6p287.

Basically, Prawn is not able to handle very long text in table() when the :column_widths option is not specified. It is able to handle text at certain lengths, for example, in the above snippet, if the multiplier was 16 instead of 20 it works.

I think Prawn should either be able to handle it, or at least raise an exception when it can't, but not loop forever.

Thanks

The row_colors option causes black boxes on pages > 1

When building a table everything looks good on the first page but the content on any additional page is completely black. Below is some sample code that shows the error. Comment out the :row_colors option and everything works fine.

  table(
    (1..45).map { [ "foo"] },
    :row_colors => ["DBDBDB", "FFFFFF"],
    :position => :center
  )

Text Box inside Bounding Box Inside Grid shrink_to_fit bug

:overflow => :shrink_to_fit does not work if the following conditions occur:

A text box has the same width and height as the bounding_box, which has the same width and height as the grid box we are using for positioning.

The latter with grid box size may be irrelevant, but this was my setup when the bug appeared.
Text which overflowed just disappeared.

:shrink_to_fit started working when i decreased the height and width of the text_box to be smaller than the bounding box.

'footer' is not margin smart

if you start a footer with a top-left x-coordinate of 38 or greater, stuff gets cut off. To illustrate:

footer [38, margin_box.bottom] do
    stroke_horizontal_rule
    text "Align right footer", :align => :right
end

Cell width calculation ignores font_style and font_size

[Description edited by bradediger]

When a the data for a table includes cells or hashes that specify :font_style and :font_size (possibly other attributes as well), the natural width calculation for the table is wrong.

Specced in bneumeier/prawn-layout@2024b97.

Patch in bneumeier/prawn-layout@cfaffbf looks correct but carries a big refactor of prawn-layout that conflicts with the nested table changes for 0.7. It also adds colspan to Cell, which, as discussed on prawn-ruby, is suboptimal. If we can rebase these changes on top of the new prawn-layout, that would be perfect.

Document.page_number

Would be useful for go_to_page and other things, returns the current page number.

Overflow in a table cell causes page break

I am struggling with an unwanted page break in a table. The contents of the cells varies in length. It seems some specific combinations of text length trigger the page break. Some much longer texts are displayed without a page break.

Here is the shortest snippet I found that has the page break. (I'm not using the font_size change in my app, it just happens to trigger the problem here.)

require 'rubygems'
require 'prawn/core'
require 'prawn/layout'
Prawn::Document.generate("problem.pdf") do
  @table = [[
    Prawn::Table::Cell.new(:text => "Some text with overflow.\nAnother line"),
    Prawn::Table::Cell.new(:text => 'foo'),
  ]]

  (8..9).each do |i|
    table @table, {:column_widths => { 0 => 100, 1 => 100}, :font_size => i}
  end
end

This happened in 0.5; I've built the gem from github and it's the same.

prawn-layout 0.8.4 fails tests

When running the specs I get two failures:

  1. Failure:
    test_spec {A document's grid when a grid is defined} 005 [should draw outlines without changing global default colors to grid color](A document's grid when a grid is defined)
    [./spec/grid_spec.rb:70:in test_spec {A document's grid when a grid is defined} 005 [should draw outlines without changing global default colors to grid color]' /usr/lib64/ruby/gems/1.8/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:insend'
    /usr/lib64/ruby/gems/1.8/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:in `run']:
    <[0.0, 0.0, 0.0]> expected but was
    .

  2. Failure:
    test_spec {A document's grid when a grid is defined} 006 [should draw outlines without curent color settings](A document's grid when a grid is defined)
    [./spec/grid_spec.rb:81:in test_spec {A document's grid when a grid is defined} 006 [should draw outlines without curent color settings]' /usr/lib64/ruby/gems/1.8/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:insend'
    /usr/lib64/ruby/gems/1.8/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:in `run']:
    <[0.8, 1.0, 0.0]> expected but was
    .

30 tests, 45 assertions, 2 failures, 0 errors

I've made sure to run these against prawn-core 0.8.4, but I saw the same failures with prawn-core 0.7.1. Please let me know if more information is needed.

fill_color() no more works with table()

Originally reported by eeabed (Abdul-Jabbar Shalabi):

After upgrading to Prawn 0.7.1, I noticed that table() doesn't respect the current color setting by fill_color(), only the first cell will have text color according to it, but subsequent cells will have just black text.

example:

fill_color "ff0000"
table [%w[1 2 3],%w[4 5 6],%w[7 8 9]], 
  :position => :center,
  :border_width   => 0,
  :font_size => 40

Only the first cell in the above table has red text color, the rest is just black.
Expected: all text should be red.

Maybe it is worth it to add a :text_color option for table() for setting text color, as we have for headers (:header_text_color)

column_box doesn't flow between columns when displaying tables instead of text

While trying to work with column_box I found out that plain text works well but tables don't flow properly.

This works fine:

column_box [0,cursor], :width => bounds.width, :columns => 2 do
  text " This is a test " * 100
end

This just causes the tables to continue in the first column over multiple pages, never flowing into the second column:

column_box [0,cursor], :width => bounds.width, :columns => 2 do
  table data, :headers => headers,
    :header_color => 'C0C0C0',
    :font_size    => 7,
    :border_style => :grid,
    :border_width => 0.5,
    :width        => bounds.width-10
end 

New Table Options

Added some new table options. See shammond42/prawn-layout (http://github.com/shammond42/prawn-layout) for implementation. The following options have been implemented.

  • :column_color => shade a column of table cells
  • rows border style
  • outline border style

Also fixed a couple of border rendering bugs that became apparent with the above border styles.

Grid.show doesn't reset stroke color

When using show_all for on a grid, the stroke color isn't reset afterwards. This is an undesired side effect.

Working on a patch, will post when ready.

Page break created for each table for some fonts when vertical_padding is small

Reported by Simon Hürlimann:

There's some regression in drawing tables.
When using a small vertical_padding (like 0 or 1), a page break is inserted after each cell. Cell borders are on the previous page than the content, though.

It looks like the commit to prawn-core 63dd5c8 (Don't let descender protrude below bounds bottom. This is a change from pre-text-overhaul functionality.) seems to have introduced this behaviour.

You may reproduce ith git versions
prawn-layout c13d2ce - Really fixing this now prawn-core 63dd5c8 - Don't let descender protrude below bounds bottom. This is a change from pre-text-overhaul functionality.

this wraps page for every cell for default font:
pdf.table([['Test', 'Val'], ['Test', 'Val']], :vertical_padding => 1)

It got somehow better during the development towards 0.7.1. The problem doesn't show anymore with the default font, but can still be triggered by some other fonts and smaller vertical_padding. I've experienced it with some proprietary TTF font called "Cholla Sans" with vertical_padding = 1. It also shows with the free TTF font "DejaVu Sans" and the built in font "Times-Roman" and vertical_padding = 0.

With
prawn-layout 0.7.1 prawn-core 0.7.1

it works for the default font, but still wraps for every cell for "Cholla" font with padding => 1 and "DejaVuSans", "Times-Roman" with padding => 0:
pdf.font('Times-Roman') pdf.table([['Test', 'Val'], ['Test', 'Val']], :vertical_padding => 0)

Minimal reproducing example:

  require 'prawn/core'
  require 'prawn/layout'

  pdf = Prawn::Document.new
  pdf.font('Times-Roman')
  pdf.table([['Test', 'Val'], ['Test', 'Val']], :vertical_padding => 0)
  pdf.render_file('test.pdf')

Adobe Reader 9.x Display Error if using table

Hi,

if I create a document with table I get an error with the Acrobat Reader 9.x

"An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem."

The error occurs only if I use more then six columns in my table.

For example following code works fine without errors:

Prawn::Document.generate("test.pdf", :page_size => "A4", :page_layout => :landscape) do |pdf|
data = [['Gregory Brown', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow'],
['Gregory Brown', 'Gregory Brow', 'Gregory Brow','Gregory Brow','Gregory Brow'],
['Gregory Brown', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow','Gregory Brow'],
['Gregory Brown', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow','Gregory Brow']] 

pdf.table data 
end 

If I add some columns I get the display error. Following code reproduce it.

Prawn::Document.generate("test.pdf", :page_size => "A4", :page_layout => :landscape) do |pdf|
data = [['Gregory Brown', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow','Gregory Brow','Gregory Brow','Gregory Brow'],
['Gregory Brown', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow','Gregory Brow','Gregory Brow'],
['Gregory Brown', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow','Gregory Brow', 'Gregory Brow','Gregory Brow'],
['Gregory Brown', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow','Gregory Brow','Gregory Brow','Gregory Brow']]

pdf.table data 
end 
The error only appear on the Acrobat Reader 9.x.

Mac Preview and Foxit Reader are working without errors.

Table does not respect :spacing for text()

Defect documented in:
bugs/table_spacing_calculations.rb

Note also:

"If you specify the text :size outside of the table element the cell spacing is not adjusted properly and stays at the default size. However, if you specify the :font_size in the table it works properly.

This fails: text_options.update(:size => 7) table(data)

This works properly: table data, :font_size => 7"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.