File: cell_text.rb

package info (click to toggle)
ruby-prawn 1.0.0~rc1%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,248 kB
  • sloc: ruby: 17,499; sh: 44; makefile: 17
file content (38 lines) | stat: -rw-r--r-- 1,495 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# encoding: utf-8
#
# Text cells accept the following options: <code>align</code>,
# <code>font</code>, <code>font_style</code>, <code>inline_format</code>,
# <code>kerning</code>, <code>leading</code>, <code>min_font_size</code>,
# <code>overflow</code>, <code>rotate</code>, <code>rotate_around</code>,
# <code>single_line</code>, <code>size</code>, <code>text_color</code>,
# and <code>valign</code>.
#
# Most of these style options are direct translations from the text methods
# styling options.
#
require File.expand_path(File.join(File.dirname(__FILE__),
                                   %w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
  data = [ ["Look at how the cells will look when styled", "", ""],
           ["They probably won't look the same", "", ""]
         ]
  
  table data, :cell_style => { :font => "Times-Roman", :font_style => :italic }
  move_down 20
  
  table data, :cell_style => { :size => 18, :text_color => "346842" }
  move_down 20
  
  table [["Just <font size='18'>some</font> <b><i>inline</i></b>", "", ""],
         ["<color rgb='FF00FF'>styles</color> being applied here", "", ""]],
         :cell_style => { :inline_format => true }
  move_down 20
  
  table [["1", "2", "3", "rotate"]], :cell_style => { :rotate => 30 }
  move_down 20
  
  table data, :cell_style => { :overflow => :shrink_to_fit, :min_font_size => 8,
                               :width => 60, :height => 30 }
end