• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

prawnto(プラウント?)使ってみました。まだ課題があるのですが、現時点でのメモです。

http://cracklabs.com/prawnto
http://cracklabs.com/prawnto/demos:デモ一覧
http://github.com/thorny-sun/prawnto/tree/master
git://github.com/thorny-sun/prawnto.git

###生成したPDF
以前の記事をPDFにしてみました。
生成されたPDF:test.pdf

###pluginのインストール
prawnライブラリを使っているので、ますprawnをインストール。その後prawnto pluginインストール。
shell>>
sudo gem install prawn
./script/plugin install git://github.com/thorny-sun/prawnto.git
<<--

###(日本語表示用に)IPAフォントをダウンロード
下記からダウンロードして解凍、ttfファイルをアクセス可能なところにコピーします。
http://ossipedia.ipa.go.jp/ipafont/

配置するとしたら下記でしょうか。

  • #{RAILS_ROOT}/vendor/fonts
  • #{RAILS_ROOT}/vendor/font_ttf
  • /usr/share/fonts/
  • /usr/local/share/fonts/)

###Rails controller, view
まずはController。
page_layoutは:portrailt(縦)か:landscape(横)のどちらかです。
rails>>
#controller
respond_to do |format|
format.html { render :action => 'show' }
format.pdf {
prawnto :prawn => {
:page_layout => :portrait, # 縦
:page_size => "A4",
:left_margin => 36,
:right_margin => 24,
:top_margin => 24,
:bottom_margin => 24},
:inline => true
}
end
<<--

そしてview(show.pdf.prawnという形式のファイル)

rails>>
#show.pdf.prawn
pdf.font "#{RAILS_ROOT}/public/ipag.ttf"
pdf.text @article.title, :size => 36
pdf.text @article.body
pdf.text "This page has very wide left and right margins, causing a squeeze. " * 10
pdf.text "これはテストです。" * 20
pdf.font "Times-Roman"
pdf.text "abcdefghijklmnopqrstu"* 20, :wrap => :character
pdf.text "http://thebogles.com/blog/2007/10/how-to-add-google-adsense-for-mobile-to-your-ruby-on-rails-site/"
<<--

###現時点での課題

  • URLや日本語の文章など空白がない文字列?だと折り返されない
    => demoで紹介されている:wrap => :characterオプションが0.1.2だとなさそう?
  • レイアウト枠のpdfを重ねたりする機能はない?(発見できず)
posted by satoko satoko on Thu 4 Sep 2008 at 17:04 with 2 comments
maiha maiha 01/06 23:38
pdf-writerから移住してきました
凄くわかりやすいです、ありがとう!
satoko satoko 01/07 15:56
お役に立ててうれしいです!情報古くなっているかもですが、よろしくお願いします。
Contents rssrss
NSAssertやNSLogを無効にする:-DNS_BLOCK_ASSERTIONS=1とNS_BLOCK_ASSERTIONS
GDBでview.frameを表示させる
Core Animationについてのリンク集
[iPhone] new BSDライセンスについてライセンス引用のメモ
Implementing a Container View Controller in UIViewController Class Reference
UITableView用のNSIndexPathの作り方
Xcodeのテンプレート、View-based ApplicationとWindow-based Applicationの違い
CopyOnSelectのLion対応
Xcode4のCode Snippetsを別のPCに移動する+gitで管理する
[iPhone] Singleton: iOS4以降はGCDのdispatch_onceを使う
Tags
iphone開発gitIBInterfaceBuilderiOSSIMBLSnippetsterminaltwitterxcodeXcode4
Comments rssrss
https://rootskitchen.bar/ https://rootskitchen.bar/: Just had a solid session playing the crash format ... 05/18 17:27
guest guest: Optimizar el tiempo durante un viaje de negocios e... 05/18 00:46
https://foolsandkings.bar/ https://foolsandkings.bar/: Wrapped up a cracking night session grinding crash... 05/17 19:23
guest guest: Para muchos turistas, el transporte publico y la l... 05/15 18:22
https://safeedsautotransport.com/ https://safeedsautotransport.com/: Многие пользователи в Узбекистане интересуются, на... 05/13 14:36
evlnwyiyh evlnwyiyh: something new and exciting [url=http://www.gyxb4s... 05/08 11:27
guest guest: The creative community and travel enthusiasts note... 05/07 02:59
https://www.thegameroom.org/online-casinos/100-free-spins/ https://www.thegameroom.org/online-casinos/100-free-spins/: Frisse xxx platforms brengen innovatieve inhoud vo... 05/03 11:12
Services from s21g
YOMU Web小説リーダー
小説投稿サイトの公式ページを開き、WebView表示と読み上げ向け表示を切り替えて、移動中や作業中にもWeb小説の続きを聴きやすくするiPhoneアプリです。
補助探
公開されている補助金・助成金情報を集約し、条件に合う制度を探しやすくするサービスです。
jotter.me
個人開発者のためのホスティング一体型ノートサービス
ハンドミラー
iPhone向けの手鏡アプリ
ツイプロ(twpro)
Twitterプロフィールの高速検索エンジン