Created
January 18, 2015 13:19
-
-
Save takuya/39f5f313f46b635b44ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "prawn" | |
f_name = File.basename(__FILE__, ".rb")+".pdf" | |
Prawn::Document.generate(f_name) { | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "prawn" | |
f_name = File.basename(__FILE__, ".rb")+".pdf" | |
Prawn::Document.generate(f_name) { | |
stroke_axis | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "prawn" | |
f_name = File.basename(__FILE__, ".rb")+".pdf" | |
Prawn::Document.generate(f_name) { | |
stroke_axis | |
stroke_circle [0,0] , 10 #原点 | |
bounding_box([100,300],:width=>100,:height=>100 ){ | |
stroke_bounds | |
stroke_circle [0,0] , 10 # ボックス右下原点の相対座標になる | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "prawn" | |
f_name = File.basename(__FILE__, ".rb")+".pdf" | |
Prawn::Document.generate(f_name) { | |
stroke_axis | |
stroke_circle [0,0] , 10 #原点 | |
text "this is prawn." | |
bounding_box([100,300],:width=>100,:height=>100 ){ | |
stroke_bounds | |
stroke_circle [0,0] , 10 # ボックス右下原点の相対座標になる | |
text "aaaaaaaaa" | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "prawn" | |
f_name = File.basename(__FILE__, ".rb")+".pdf" | |
Prawn::Document.generate(f_name) { | |
## 行に水平線を引く | |
text "Hello world" | |
stroke_horizontal_rule | |
text "Hello world" | |
stroke_horizontal_rule | |
## 横に直線を引く | |
stroke_color "0000ff" | |
stroke_horizontal_line 0, 540, :at=> 50 | |
stroke{ | |
horizontal_line 100, 340, :at=> 400 | |
horizontal_line 100, 340, :at=> 420 | |
horizontal_line 100, 340, :at=> 440 | |
} | |
## 横に直線を引く | |
stroke_color "00ffff" | |
stroke_horizontal_line 0, 540, :at=> 50 | |
stroke{ | |
horizontal_line 0, 540, :at=> 100 | |
horizontal_line 0, 540, :at=> 150 | |
horizontal_line 0, 540, :at=> 200 | |
} | |
## 縦に直線を引く | |
stroke_color "ff0000" | |
stroke_vertical_line 0, 720, :at => 135 | |
stroke{ | |
vertical_line 0, 720, :at => 270 | |
vertical_line 0, 720, :at => 405 | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "prawn" | |
f_name = File.basename(__FILE__, ".rb")+".pdf" | |
Prawn::Document.generate(f_name) { | |
stroke_axis | |
## 線を引く、1つずつ | |
stroke{ | |
move_to 0, 0 | |
line_to 100,100 | |
line_to 200,300 | |
} | |
## まとめて | |
stroke { | |
curve [100,500], [400, 200], :bounds => [[500,400], [200,290]] | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "prawn" | |
f_name = File.basename(__FILE__, ".rb")+".pdf" | |
Prawn::Document.generate(f_name) { | |
## 日本語を書く | |
stroke_axis | |
text "aaa" | |
font "/Library/Fonts/Microsoft/meiryo.ttf" | |
text <<-EOS | |
<!doctype html> | |
<html lang=ja> | |
<head> | |
<meta charset='utf-8' > | |
<title>マイページタイトル</title> | |
</head> | |
<body> | |
<section> | |
<h1>姉川合戦の以前と以後での信長の行動の違いについて</h1> | |
</section> | |
</body> | |
</html> | |
EOS | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "prawn/table" | |
require "prawn" | |
f_name = File.basename(__FILE__, ".rb")+".pdf" | |
Prawn::Document.generate(f_name) { | |
## 日本語を書く | |
stroke_axis | |
font "/Library/Fonts/Microsoft/meiryo.ttf" | |
text "スターバックス・ラテの価格" | |
move_down 20 | |
table [ | |
["年","価格(税込)","幅"], | |
["1996年","260円","出店開始"], | |
["2007年","310円","+50円"], | |
["2009年","320円","+10円"], | |
["2011年","340円","+30円"], | |
["2014年","350円","+10円"], | |
["2014年","400円","+50円"], | |
] | |
## 場所を決めるには、矩形に閉じ込めるのが早そう | |
bounding_box([270,360], :width=>270,:height=>360){ | |
table [ | |
["年","価格(税込)","幅"], | |
["1996年","260円","出店開始"], | |
["2007年","310円","+50円"], | |
["2009年","320円","+10円"], | |
["2011年","340円","+30円"], | |
["2014年","350円","+10円"], | |
["2014年","400円","+50円"], | |
] | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "prawn/table" | |
require "prawn" | |
f_name = File.basename(__FILE__, ".rb")+".pdf" | |
Prawn::Document.generate(f_name) { | |
## 日本語を書く | |
stroke_axis | |
font "/Library/Fonts/Microsoft/meiryo.ttf" | |
text "フラペチーノ" | |
table([ | |
[make_cell(:content=>"名前"),make_cell(:content=>"価格(税込)"),], | |
["チョコレート オランジュ モカ フラペチーノ", "561円"], | |
["オランジュ ホワイト モカ フラペチーノ キャラメルソース", "561円"], | |
["コーヒー フラペチーノ", "432円"], | |
["キャラメル フラペチーノ", "486円"], | |
["ダーク モカ チップ フラペチーノ", "507円"], | |
["ダーク モカ チップ クリーム フラペチーノ", "507円"], | |
["抹茶 クリーム フラペチーノ", "486円"], | |
["バニラ クリーム フラペチーノ", "486円"] | |
]){ | |
row(0).font = "/Library/Fonts/Microsoft/Meiryo Bold.ttf" | |
column(1).width = 100 | |
} | |
## 適当に折り返してくれる | |
bounding_box([270,360], :width=>270,:height=>360){ | |
text "フラペチーノ" | |
table [ | |
["名前","価格(税込)"], | |
["チョコレート オランジュ モカ フラペチーノ", "561円"], | |
["オランジュ ホワイト モカ フラペチーノ キャラメルソース", "561円"], | |
["コーヒー フラペチーノ", "432円"], | |
["キャラメル フラペチーノ", "486円"], | |
["ダーク モカ チップ フラペチーノ", "507円"], | |
["ダーク モカ チップ クリーム フラペチーノ", "507円"], | |
["抹茶 クリーム フラペチーノ", "486円"], | |
["バニラ クリーム フラペチーノ", "486円"] | |
] , :row_colors => ["99eeeeee","ddffff"] | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "prawn/table" | |
require "prawn" | |
f_name = File.basename(__FILE__, ".rb")+".pdf" | |
Prawn::Document.generate(f_name,{ :page_layout => :landscape,:margin=>10 }) { | |
## 日本語を書く | |
stroke_axis | |
font "/Library/Fonts/Microsoft/meiryo.ttf" | |
text "フラペチーノ" | |
table([ | |
[make_cell(:content=>"名前"),make_cell(:content=>"価格(税込)"),], | |
["チョコレート オランジュ モカ フラペチーノ", "561円"], | |
["オランジュ ホワイト モカ フラペチーノ キャラメルソース", "561円"], | |
["コーヒー フラペチーノ", "432円"], | |
["キャラメル フラペチーノ", "486円"], | |
["ダーク モカ チップ フラペチーノ", "507円"], | |
["ダーク モカ チップ クリーム フラペチーノ", "507円"], | |
["抹茶 クリーム フラペチーノ", "486円"], | |
["バニラ クリーム フラペチーノ", "486円"] | |
]){ | |
row(0).font = "/Library/Fonts/Microsoft/Meiryo Bold.ttf" | |
column(1).width = 100 | |
} | |
## 適当に折り返してくれる | |
bounding_box([500,360], :width=>270,:height=>360){ | |
text "フラペチーノ" | |
table [ | |
["名前","価格(税込)"], | |
["チョコレート オランジュ モカ フラペチーノ", "561円"], | |
["オランジュ ホワイト モカ フラペチーノ キャラメルソース", "561円"], | |
["コーヒー フラペチーノ", "432円"], | |
["キャラメル フラペチーノ", "486円"], | |
["ダーク モカ チップ フラペチーノ", "507円"], | |
["ダーク モカ チップ クリーム フラペチーノ", "507円"], | |
["抹茶 クリーム フラペチーノ", "486円"], | |
["バニラ クリーム フラペチーノ", "486円"] | |
] , :row_colors => ["99eeeeee","ddffff"] | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment