# word07.rb.txt: ruby script (encoding: Windows-31J) # 2段組の文書を生成 # markdownの原稿 data07.md.txt から z_word07.docx を作る。 # data07.inf.txtの情報に従って、A4横長、2段組の文書にする。 require "wrdap" # pandocにより、markdown→Word変換 src_file = "data07.md.txt" filename = "z_word07.docx" mkd_str = File.read(src_file) docx_str = Wrd::pandoc_docx(mkd_str) File.open(filename, "wb") {|ff| ff.write docx_str} # ワード文書の調整 info_file = "data07.inf.txt" adjust_msg = info_msg = get_msg = nil table_count = 0 wrd = Wrdap.new wrd.opens(filename) do |doc| info_msg, adjust_msg, get_msg = doc.set_info(info_file) table_count = doc.table_border() # 表の罫線を調整 if info_msg or adjust_msg or table_count > 0 doc.ActiveWindow.View.Type = WdPrintView # 印刷レイアウトモード doc.save end end if info_msg.to_s != '' puts "* 設定した項目" print info_msg printf("\n") end if get_msg.to_s != '' puts "* 文書情報" print get_msg printf("\n") end if table_count > 0 printf("* 表の罫線: %d個の表の罫線を細い実線にしました.\n\n", table_count) end if adjust_msg.to_s != '' print adjust_msg printf("\n") end