4

動的画像と動的テキストを含むドキュメントがあり、画像の周囲にテキストが必要です。画像は横向きのページに右揃えで配置されます。これが私がこれまでに持っているものです:

pdf.bounding_box([0,pdf.bounds.top - 50], :width => pdf.bounds.width, :height => pdf.bounds.height-50) do
  pdf.text @article.title, :size => 30, :style => :bold
  pdf.text @article.content, :align => :left
  # image
  pdf.bounding_box([pdf.bounds.right - 250, pdf.bounds.top], :width => 250, :height => 250) do
    pdf.image image_path, :width => 250
  end
end

テキストは画像の真下に表示されます。このルビーエビを右揃えの画像にテキストを折り返す方法を試してみましたか?しかし、それは機能しませんでした。

助けてくれてありがとう。

4

2 に答える 2

2

画像の幅と高さがわかっている場合は、text_boxを使用して画像の横にテキストボックスを配置し、返されたテキストの文字列が収まらなかった場合に収集できます。次に、画像とtext_boxの下に2番目のテキストボックスまたは通常のtext()呼び出しを作成します。これで、準備は完了です。

この例は役に立ちます:http: //github.com/sandal/prawn/blob/0.9.1/examples/text/text_box_returning_excess.rb

于 2010-05-02T13:29:43.630 に答える
0

私はエビの経験があまりないので、これは単なる推測です。画像の境界ボックスの後にpdf.textステートメントを配置してみましたか?

pdf.bounding_box([0,pdf.bounds.top - 50], 
   :width => pdf.bounds.width, 
   :height => pdf.bounds.height-50) do 

   # image 
   pdf.bounding_box([pdf.bounds.right - 250, pdf.bounds.top], 
      :width => 250, :height => 250) do 
      pdf.image image_path, :width => 250 
   end 

   pdf.text @article.title, :size => 30, :style => :bold 
   pdf.text @article.content, :align => :left 

end
于 2010-04-22T19:00:24.470 に答える