2016-09-14 65 views
1

我需要把2圖像和文​​字在同一行。標題與蝦欄

例如:

(圖像1) 「TEXT」(圖像2)

模擬的報頭。 這裏是我的代碼:

class PruebasPdf < Prawn::Document 

def initialize(prueba) 
    super() 
    @prueba = Prueba.order("id DESC").all 
    cabecera 
    prueba_id 
    marcagua 
end 
def cabecera 
    image "#{Rails.root}/app/assets/images/logo-i.jpg", :width => 50, :height => 50,:position => :left 
    text "Universidad Centroccidental Lisandro Alvarado", size: 18, style: :bold, align: :center 
    image "#{Rails.root}/app/assets/images/logo-d.jpg", :width => 50, :height => 50,:position => :right 
end 
def prueba_id 
    table prueba_id_all do 
     row(0).font_style = :bold 
     columns(1..3).align = :center 
     self.row_colors = ["DDDDDD","FFFFFF"] 
     self.header = true 
     end 

end 

def prueba_id_all 
    [["Titulo","Descripcion","Fecha"]] + 
    @prueba.map do |prueba| 
     [prueba.titulo,prueba.desc,prueba.fecha] 
    end 

end 

def marcagua 
    create_stamp("watermark") do 
    rotate(30, :origin => [-5, -5]) do 
     stroke_color "FF3333" 
     stroke_color "000000" 
     fill_color "993333" 
     font("Times-Roman") do 
     draw_text "Coordinacion de Investigacion", :at => [-23, -3] 
     end 
     fill_color "000000" 
    end 
    end 

     stamp_at "watermark", [300, 300] 
      end end 

有誰知道它是如何做到的?提前致謝! 對不起我的英語---

回答

0

如果您的標題不會改變或以任何方式動態,那麼我只是使用絕對定位與x和y座標來讓您的圖像和文字排列你想要的方式。你可以做這樣的事情與:at選項:

image "#{Rails.root}/app/assets/images/logo-i.jpg", :width => 50, :height => 50, :at => [200, 80] 
draw_text "Universidad Centroccidental Lisandro Alvarado", size: 18, style: :bold, :at => [260, 100] 
image "#{Rails.root}/app/assets/images/logo-d.jpg", :width => 50, :height => 50, :at => [320, 80] 

這些只是例子座標,但你可以得到的想法

+0

謝謝你,幫我!上帝保佑你 –

+0

不客氣! – Ren