Sha256: e997bb89ee321a49ec1ce5a8d178a9b70b163e4ca81431f1673f1d7aba3e8a56

Contents?: true

Size: 1.31 KB

Versions: 10

Compression:

Stored size: 1.31 KB

Contents

#!/usr/bin/env ruby
# coding: utf-8

$:.unshift(File.dirname(__FILE__) + "/../lib")

require 'pdf/wrapper'

pdf = PDF::Wrapper.new("image_table.pdf", :paper => :A4)
pdf.text File.read(File.dirname(__FILE__) + "/../specs/data/utf8.txt").strip, :alignment => :centre
pdf.pad 5
headers = %w{one two three four}

image_cell = PDF::Wrapper::TextImageCell.new("9781857233001", File.dirname(__FILE__) + "/../specs/data/orc.svg", 150, 100)

data = []
data << ["This is some longer text to ensure that the cell wraps","oh noes! the cols can't get the width they desire",3,4]
data << ["This is some longer text to ensure that the cell wraps","oh noes! the cols can't get the width they desire",3,4]
data << [image_cell,2,3,4]

data << [[], "j", "a", "m"]

(1..100).each do
  data << %w{1 2 3 4}
end

table = PDF::Wrapper::Table.new(:font_size => 10) do |t|
  t.data = data
  t.headers headers, {:color => :white, :fill_color => :black}
  t.row_options 6, {:border => "t"}
  t.row_options :even, {:fill_color => :gray}
  t.col_options 0, {:border => "tb"}
  t.col_options 1, {:alignment => :centre}
  t.col_options 2, {:alignment => :centre}
  t.col_options 3, {:alignment => :centre, :border => "tb"}
  t.col_options :even, {:fill_color => :blue}
  t.cell_options 3, 3, {:fill_color => :green}
  #t.manual_col_width 0, 200
end

pdf.table(table)
pdf.finish

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pdf-wrapper-0.4.5 examples/table_images.rb
pdf-wrapper-0.4.4 examples/table_images.rb
pdf-wrapper-0.4.1 examples/table_images.rb
pdf-wrapper-0.4.0 examples/table_images.rb
pdf-wrapper-0.3.5 examples/table_images.rb
pdf-wrapper-0.3.4 examples/table_images.rb
pdf-wrapper-0.3.3 examples/table_images.rb
pdf-wrapper-0.3.2 examples/table_images.rb
pdf-wrapper-0.3.1 examples/table_images.rb
pdf-wrapper-0.3.0 examples/table_images.rb