Prawn PDF table mixed formats

I am trying to generate a simple table in ruby with prawn pdf.

I need some text in a cell to be bold, and some to be not bold. For example:

Now following some examples, I have the basic table rendering with this code:

pdf.table([
  ["1. Row example text", "433"],
  ["2. Row example text", "2343"],
  ["3. Row example text", "342"],
  ["4. Row example text", "36"]], :width => 500, :cell_style => {
    :font_style => :bold})

But I can see absolutely no way of inserting more text into the first cell with a different format. (In this case I want it to be unbolded)

Does anyone know how to accomplish this?

Thanks for any help

Answers


Prawn::Document.generate("test.pdf") do |pdf|
     table_data = [[Prawn::Table::Cell::Text.new( pdf, [0,0], :content => "<b>1. Row example text</b> \n\nExample Text Not Bolded", :inline_format => true), "433"],
                   [Prawn::Table::Cell::Text.new( pdf, [0,0], :content => "<b>2. Row example text</b>", :inline_format => true), "2343"],
                   [Prawn::Table::Cell::Text.new( pdf, [0,0], :content => "<b>3. Row example text</b>", :inline_format => true), "342"],                    
                   [Prawn::Table::Cell::Text.new( pdf, [0,0], :content => "<b>4. Row example text</b>", :inline_format => true), "36"]]

    pdf.table(table_data,:width => 500)
end

You can also do

Prawn::Document.generate("test.pdf") do |pdf|
    table_data = [["<b>1. Row example text</b>\n\nExample Text Not Bolded", "<b>433<b>"], 
                  ["<b>2. Row example text</b>", "<b>2343</b>"], 
                  ["<i>3. Row example text</i>", "<i>342</i>"],
                  ["<b>4. Row example text</b>", "<sub>36</sub>"]]

    pdf.table(table_data, :width => 500, :cell_style => { :inline_format => true })
end

Prawn's inline_format supports <b>, <i>, <u>, <strikethrough>, <sub>, <sup>, <font>, <color> and <link>


Need Your Help

how to do twitter login on a website javascript

javascript twitter

I've been looking for how to login with twitter. i found something about twitter @anywhere but it seems that this options has been taken down. does anyone know if there is an other way on how to lo...

Foreign Key problem using ADO .NET Entity Data

entity-framework

I am developing an ASP.NET MVC2 app with a MSSQL db using VS2008 and SQL Express 2008 R2. I have a table called Business and another table called Employee. Employee has a BusinessID foreign key as...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.