2012-09-10 13 views
7

मैं प्रॉन पीडीएफ के साथ रूबी में एक साधारण टेबल उत्पन्न करने की कोशिश कर रहा हूं।प्रोन पीडीएफ टेबल मिश्रित प्रारूप

मुझे बोल्ड होने के लिए सेल में कुछ टेक्स्ट चाहिए, और कुछ बोल्ड नहीं होने चाहिए। उदाहरण के लिए:

Example table अब कुछ उदाहरण निम्नलिखित, मैं बुनियादी तालिका इस कोड के साथ प्रतिपादन किया है:

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}) 

लेकिन मैं पूरी तरह से एक अलग प्रारूप के साथ प्रथम कक्ष में और अधिक पाठ डालने का कोई रास्ता नहीं देख सकते हैं । (इस मामले में मैं इसे अनबल्ड करना चाहता हूं)

क्या कोई यह जानता है कि इसे कैसे पूरा किया जाए?

किसी भी मदद

उत्तर

19
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 

के लिए धन्यवाद तुम भी बस जैसे देख रहा था,

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 

झींगा के inline_format का समर्थन करता है <b>, <i>, <u>, <strikethrough>, <sub>, <sup>, <font>, <color> and <link>

+0

धन्यवाद कर सकते हैं। चिंतित था कि यह अदृश्य घोंसले कोशिकाओं में गिरावट होगी! – Chris

संबंधित मुद्दे