How can i call an image in my model

14 views
Skip to first unread message

Maddy

unread,
Aug 21, 2012, 2:57:13 AM8/21/12
to rubyonra...@googlegroups.com
Hi folks,

Am generating  table vales as pdf file.I need to call my images in that pdf generated file..

how could i call?? 

its is my actual image directory "/assets/images/logo.png"

it is my model.rd,

class PerformancePdf < Prawn::Document
  def initialize(performance)
    super(top_margin: 70)
    @performance=performance
    p @performance
    performance_view
    performance_item
    performance_regards
  end
  
    
  def performance_view
  text "Hi,"
  text @performance.employee.employee_id
  end
  
  def performance_item
    move_down 75
    table performance_item_rows do
      row(0).font_style = :bold
      columns(1..3).align = :right
      self.row_colors = ["DDDDDD", "FFFFFF"]
      self.header = true
    end
  end
  
  def performance_item_rows
  text "Performance Status"
  move_down 10
    [["Name", "Project", "Client", "Start Date","End Date", "Duration", "Remarks"]]+
    [[@performance.employee.name,@performance.project.name,@performance.project.client,@performance.start_date,@performance.end_date,@performance.duration,@performance.task
    ]]
  end
  
  def performance_regards
  move_down 400
  text "Thanks&Regards"
  text "xxxx"
  end
 end



Robert Walker

unread,
Aug 21, 2012, 2:43:43 PM8/21/12
to rubyonra...@googlegroups.com
Maddy wrote in post #1072965:
> Hi folks,
>
> Am generating table vales as pdf file.I need to call my images in that
> pdf
> generated file..
>
> how could i call??
>
> its is my actual image directory "/assets/images/logo.png"

I think, if I understand you correctly, you're looking for this:

----------------
text "The image will go right below this line of text."
image "#{Prawn::DATADIR}/images/pigs.jpg"
----------------

This example was extracted directly from the Prawn manual:
http://prawn.majesticseacreature.com/manual.pdf

--
Posted via http://www.ruby-forum.com/.
Reply all
Reply to author
Forward
0 new messages