Created
January 19, 2015 18:56
-
-
Save takuya/df1215c2e01b4b27d833 to your computer and use it in GitHub Desktop.
Revisions
-
takuya created this gist
Jan 19, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,105 @@ #!/usr/bin/env ruby require "prawn/table" require "prawn" require 'pp' require 'barby' require 'barby/outputter/png_outputter' require "barby/barcode/qr_code" require 'stringio' class TodoDoc < Prawn::Document def todo_list=(data) data = check_and_fix_todo_list_format(data) @todo_list=data end def check_and_fix_todo_list_format(data=nil) list = data||@todo_list list = list.map{|e| e = e.map{|e| [e] } if e.is_a? Array e = [[e]] unless e.is_a? Array e[1]||= [""] e[2]||= ["about:blank"] e[2]= [make_table( [[Date.today.strftime, {image: qr_blob(e[2][0])} ]],cell_style:{:borders=>[]},position: :right )] e } list end def qr_blob(data) #data = "http://takuya-1st.hatenablog.jp/entry/" + Date.today.strftime("%Y/%m/%d") barcode = Barby::QrCode.new(data.encode("UTF-8")) blob = Barby::PngOutputter.new(barcode).to_png( margin:1,height:50 ) #Raw PNG data StringIO.new blob end def make_todo_table() data = @todo_list.pop data ||= [[""],[""],[""]] table(data){ column(0).width = 270 row(0).font = "/Library/Fonts/Microsoft/Meiryo Bold.ttf" row(0).size = 30 row(0).align = :center row(0).height= 40 row(1).size = 10 row(1).height= 100 row(2).size = 10 row(2).height= 40 } end def make_page() [ [0,720],[0,540],[0,360],[0,180], [270,720],[270,540],[270,360],[270,180], ].each{|e| bounding_box( e , height:200, width:300){ make_todo_table() } } end def layout while @todo_list.size > 0 do make_page() start_new_page() if @todo_list.size > 0 end end end f_name = File.basename(__FILE__, ".rb")+".pdf" TodoDoc.generate(f_name,{ :page_layout => :portrait,:margin=>40 }) {|pdf| #pdf.stroke_axis pdf.font "/Library/Fonts/Microsoft/meiryo.ttf" todo_list = [] todo_list << "404ページ修正" todo_list << "エラーページ修正" todo_list << "処理エラー通知" todo_list << "課金動作の確認" todo_list << ["メール送信確認", "メアド、送信元の確認、SMTPサーバーのチェック", "http://takuya-1st.hatenablog.jp/archive/"+Date.today.strftime("%Y/%m/%d") ] todo_list << "設定ファイル場所変更" todo_list << "課金テスト" pdf.todo_list = todo_list pdf.layout }