2012-09-10 3 views
7

나는 새우 pdf가있는 루비에서 간단한 표를 생성하려고합니다.새우 PDF 표 혼합 형식

셀에 굵은 글씨가 있어야하고 굵은 글자가 필요합니다. 예를 들면 :

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이

+0

<b>, <i>, <u>, <strikethrough>, <sub>, <sup>, <font>, <color> and <link> 감사합니다 지원 할 수 있습니다. 보이지 않는 중첩 세포로 변질 될까봐 걱정했습니다! – Chris