├── .gitignore ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── academic.txt ├── data.yaml ├── fonts ├── .gitkeep ├── IPA_Font_License_Agreement_v1.0.txt ├── Readme_IPAexfont00401.txt ├── ipaexg.ttf └── ipaexm.ttf ├── make_cv.rb ├── makefile ├── photo.jpg ├── sample ├── academic.pdf ├── academic1.png ├── academic2.png ├── licenses.png ├── output.pdf ├── output1.png ├── output2.png ├── photo.png └── teaching.png ├── style.txt ├── txt2yaml.rb └── yaml2txt.rb /.gitignore: -------------------------------------------------------------------------------- 1 | *.pdf 2 | 3 | # Bundler 4 | vendor/bundle/ 5 | .bundle/ 6 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } 6 | 7 | gem "prawn", github: "prawnpdf/prawn" 8 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GIT 2 | remote: https://github.com/prawnpdf/prawn 3 | revision: 8ceaa105f3e6038fac2eb4b84355d71b00d895f3 4 | specs: 5 | prawn (2.4.0) 6 | matrix (~> 0.4) 7 | pdf-core (~> 0.9.0) 8 | ttfunk (~> 1.7) 9 | 10 | GEM 11 | remote: https://rubygems.org/ 12 | specs: 13 | matrix (0.4.2) 14 | pdf-core (0.9.0) 15 | ttfunk (1.7.0) 16 | 17 | PLATFORMS 18 | ruby 19 | 20 | DEPENDENCIES 21 | prawn! 22 | 23 | BUNDLED WITH 24 | 2.1.4 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 - present H. Watanabe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # YAMLによる履歴書作成スクリプト 2 | 3 | [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE) 4 | 5 | YAML形式で書かれたデータファイルと、YAMLもしくはテキストファイル形式で書かれたスタイルから履歴書PDFファイルを作成するRubyスクリプトです。 6 | 7 | ## 履歴書フォーマットについて 8 | 9 | このスクリプトで作成される履歴書のフォーマットは、JIS Z 8303『帳票の設計基準』に掲載されていた「履歴書」の様式に則ったものでした。しかし経済産業省に履歴書の性別欄を無くすよう要望があり、経済産業省からその要望を受け取った一般財団法人日本規格協会は、もともと履歴書の様式は「例」であったとして、JIS Z 8303から履歴書の様式例を削除しました。もともとJIS Z 8303は帳票の寸法を定めるもので、個々の様式(フォーマット)を定めるものではなかったのですが、あくまで例として掲載されていた「履歴書」の様式が、「JIS規格のフォーマットである」と誤解されて広まったものだったようです。すなわち、JIS規格の履歴書というものはもともと存在せず、JISに記載されていた履歴書フォーマットも削除された今、このスクリプトの作るフォーマットに公的な意味はありません。ご利用の際は上記についてご承知おきください。 10 | 11 | ## 使い方 12 | 13 | ### 簡単な使用方法 14 | 15 | [ikasam](https://github.com/ikasam)さんが、[Dockerを使う実行環境](https://github.com/ikasam/docker-yaml_cv)を作ってくださっています。Docker環境がある方はいろいろインストールしなくても`git clone`して`docker-compose up`するだけでPDFが作成されるので便利です。 16 | 17 | ### 必要なライブラリ等 18 | 19 | このリポジトリを利用して、ローカルで運用するためには、Rubyの実行環境と以下のライブラリ、フォントが必要になります。 20 | 21 | * Prawn 22 | * IAPexフォント (本リポジトリに同封) 23 | 24 | PrawnはBundlerで管理しているため、以下のコマンドでインストールしてください。 25 | 26 | ```sh 27 | bundle config path vendor/bundle 28 | bundle config set --local without 'documentation' 29 | bundle install 30 | ``` 31 | 32 | Prawnから日本語を出力するためにIPAexフォントを使っており、本リポジトリに以下のように同封しています。利用にあたってはIPAフォントライセンスv1.0への同意が必要です。 33 | 34 | ```txt 35 | ├── fonts 36 | │   ├── IPA_Font_License_Agreement_v1.0.txt 37 | │   ├── Readme_IPAexfont00401.txt 38 | │   ├── ipaexg.ttf 39 | │   └── ipaexm.ttf 40 | └── make_cv.rb 41 | ``` 42 | 43 | ### 実行方法 44 | 45 | 以下のように、`-i`に続けてデータファイル、`-s`に続けてスタイルファイル、`-o`に続けて出力ファイルを指定します。省略した場合のデフォルトはそれぞれ`data.yaml`、`style.txt`、`output.pdf`です。 46 | 47 | ```sh 48 | $ ruby make_cv -h 49 | Usage: make_cv [options] 50 | -i, --input [datafile] 51 | -s, --style [stylefile] 52 | -o, --output [output] 53 | ``` 54 | 55 | YAML形式のデータファイル(例:`data.yaml`)とスタイルファイル(例:`style.txt`)を用意し、スクリプトを以下のように実行します。 56 | 57 | ```sh 58 | ruby make_cv.rb -i data.yaml -s style.txt -o output.pdf 59 | ``` 60 | 61 | 添付のサンプルでは以下のような出力が得られます。 62 | 63 | [PDFファイル](sample/output.pdf) 64 | 65 | ![output1.png](sample/output1.png) 66 | ![output2.png](sample/output2.png) 67 | 68 | また、スタイルファイルを変えることで、同じデータファイルから異なる出力を得られます。以下はアカデミックポスト向けのスタイルファイル`academic.txt`を使った場合です。 69 | 70 | ```sh 71 | ruby make_cv.rb -i data.yaml -s academic.txt -o academic.pdf 72 | ``` 73 | 74 | [PDFファイル](sample/academic.pdf) 75 | 76 | ![academic1.png](sample/academic1.png) 77 | ![academic2.jpg](sample/academic2.png) 78 | 79 | ### データの用意の仕方 80 | 81 | データはYAML形式で用意します。 82 | 83 | 以下はサンプルの`data.yaml`の一部です。 84 | 85 | ```YAML 86 | # 名前等 87 | date: 2018年 6月 5日現在 88 | name_kana: りれきしょ かくたろう 89 | name: 履歴書 書太郎 90 | birth_day: 1543年1月31日 (満 73 歳) 91 | gender: 男 92 | cell_phone: 090-1234-5678 93 | email: hoge@hogehoge.org 94 | photo: photo.jpg 95 | 96 | # 住所 97 | address_kana: とうきょうとちよだくちよだ 98 | address: 東京都千代田区千代田1-1-1 99 | address_zip: 100-0001 100 | tel: 0120-000-XXX 101 | fax: 0120-111-XXX 102 | # 連絡先 103 | address_kana2: ほっかいどう わっかないし そうやみさき 104 | address2: 北海道稚内市宗谷岬 105 | address_zip2: 098-6758 106 | tel2: 0120-222-XXX 107 | fax2: 0120-333-XXX 108 | ``` 109 | 110 | 例えば、写真が`photo.jpg`として用意してある場合、 111 | 112 | ```YAML 113 | photo: photo.jpg 114 | ``` 115 | 116 | とすれば写真が貼られます。もし写真ファイルを指定しなかった場合、例えば 117 | 118 | ```YAML 119 | # photo: photo.jpg 120 | ``` 121 | 122 | としてコメントアウトすると、写真部分は 123 | 124 | ![sample/photo.png](sample/photo.png) 125 | 126 | のような出力になります。 127 | 128 | ## スタイルファイル 129 | 130 | 履歴書のスタイルファイルは、一行に一要素ずつ記述していきます。例えば`academic.txt`は以下のような内容になっています。 131 | 132 | ```txt 133 | # ヘッダー 134 | string,5mm,247mm,履 歴 書,font_size=14,font_face=gothic 135 | string,110mm,245mm,$date,font_size=9 136 | 137 | # 住所・連絡先等 138 | box,145mm,204mm,30mm,40mm,line_style=dashed 139 | string,148mm,240mm,写真を貼る位置,font_size=9 140 | string,147mm,233mm,1. 縦36〜40 mm,font_size=8 141 | string,150mm,230mm,横24〜30 mm,font_size=8 142 | string,147mm,227mm,2. 本人単身胸から上,font_size=8 143 | string,147mm,224mm,3. 裏面にのりづけ,font_size=8 144 | string,147mm,221mm,4. 裏面に氏名記入,font_size=8 145 | ``` 146 | 147 | 一行目の 148 | 149 | ```txt 150 | string,5mm,247mm,履 歴 書,font_size=14,font_face=gothic 151 | ``` 152 | 153 | は、(5mm,247mm)の位置に「履 歴 書」という文字を、フォントサイズ14で、フォントはゴシックで記述する命令です。このうち必須なのは座標と文字列ですが、その後にオプションとしてフォントサイズやフォントの指定ができます。 154 | 155 | 次の行の 156 | 157 | ```txt 158 | string,110mm,245mm,$date,font_size=9 159 | ``` 160 | 161 | も同様に(110mm, 245mm)の位置に文字列を出力する命令ですが、出力する文字列が`$date`となっています。これは、データファイルの`data`要素に置換されます。今、データファイルは 162 | 163 | ```yaml 164 | date: 2018年 6月 5日現在 165 | ``` 166 | 167 | とあるので、 168 | 169 | ```txt 170 | string,110mm,245mm,$date,font_size=9 171 | ``` 172 | 173 | は 174 | 175 | ```txt 176 | string,110mm,245mm,2018年 6月 5日現在,font_size=9 177 | ``` 178 | 179 | に展開されます。 180 | 181 | テキスト形式の命令リストは以下の通りです。 182 | 183 | 命令| フォーマット| 説明 184 | -- | ---- | ---- 185 | string | string, x, y, value[,font options] | (x,y)に文字列valueを出力 186 | line | line, x, y, dx, dy[,line options] | (x,y)から(x+dx, y+dy)に線を描画 187 | box | box,x,y,width,height[,line options]| (x,y)に指定された幅と高さのボックスを描画 188 | photo |photo, x, y, width, height | 指定位置、サイズに写真ファイル`$photo`を描画 189 | new_page |new_page | 改ページ 190 | textbox |textbox,x,y,width,height,value[,font options] |指定位置、サイズにテキストボックスを描画 191 | multi_lines| multi_lines, x,y,dx,dy,num,sx,sy| (x,y)から、(dx,dy)方向に、毎回(sx,sy)だけ座標をずらしながらnum回線を引きます 192 | ymbox| ymbox,title,height,num,$value | $valueをhistoryデータとして、高さyに、年月表を作るマクロです。 193 | miscbox| miscbox,title,y,height,$value | タイトル付きテキストボックスです。$valueの内容をテキストボックス内に展開します。 194 | 195 | ### 特別な命令 196 | 197 | #### history 198 | 199 | 年、月、内容をともなったデータを描画する命令です。ymboxやmiscboxの内部で呼ばれます。 200 | 201 | ```txt 202 | history, y, year_x, month_x, value_x, dy, value[,font options] 203 | ``` 204 | 205 | * y: 描画を始めるy座標 206 | * year_x, month_x, value_x: それぞれ年、月、内容を書くx座標 207 | * dy: 改行時にどれだけ下に下げるか 208 | * value: 内容 209 | 210 | history環境に使われるデータは以下のように指定します。 211 | 212 | ```yaml 213 | licences: 214 | - 215 | year: 19XX 216 | month: 11 217 | value: 普通自動車免許 218 | - 219 | year: 20XX 220 | month: 11 221 | value: 履歴書検定1級 222 | ``` 223 | 224 | `year`や`month`は省略可能です(空白になります)。 225 | 226 | #### education_experience 227 | 228 | 学歴、職歴を書く命令です。命令フォーマットは以下の通りです。 229 | 230 | ```txt 231 | education_experience, y, year_x, month_x, value_x, dy, caption_x, ijo_x, [,font options] 232 | ``` 233 | 234 | * y: 描画を始めるy座標 235 | * year_x, month_x, value_x: それぞれ年、月、内容を書くx座標 236 | * dy: 改行時にどれだけ下に下げるか 237 | * caption_x: 「学歴」や「職歴」の文字のx座標 238 | * ijo_x: 「以上」の文字のx座標 239 | 240 | なお、学歴データは`$education`が、職歴データは`$experience$`が仮定されます。 241 | 242 | #### lines 243 | 244 | 複数の線を書く命令です。履歴書によくある右上が凹んだボックスを書くために用意してあります。命令フォーマットは以下の通りです。 245 | 246 | ```txt 247 | lines, num, x,y, dx, dy, ..., [,line options] 248 | ``` 249 | 250 | 最初に「何個の点データがあるか」を`num`で指定します。その後、始点、次の点の相対座標・・・と続け、最後に線のオプションを指定します。なお、この命令だけのオプションとして「close」というものがあります。これを指定すると最後に線を閉じます。 251 | 252 | #### ymbox 253 | 254 | 「年、月、事柄」を書くマクロです。例えば 255 | 256 | ```txt 257 | ymbox,免許・資格,204mm,4,$licences 258 | ``` 259 | 260 | は、「免許・資格」というタイトルの4行分の年月ボックスを、高さ204mmのところに配置する、という意味です。最後がデータのYAMLファイルの対応するレコードです。例えば、 261 | 262 | ```yaml 263 | # 免許・資格 264 | licences: 265 | - 266 | year: 19XX 267 | month: 11 268 | value: 普通自動車免許 269 | - 270 | year: 20XX 271 | month: 11 272 | value: 履歴書検定1級 273 | ``` 274 | 275 | というデータだったとすると、 276 | 277 | ![sample/licenses.png](sample/licenses.png) 278 | 279 | に展開されます。 280 | 281 | ```txt 282 | ymbox,免許・資格,204mm,4,$licences,font_size=9 283 | ``` 284 | 285 | などのように、最後にフォントサイズを指定できます。 286 | 287 | #### miscbox 288 | 289 | タイトル付きのテキストボックスに展開されるマクロです。例えば、 290 | 291 | ```txt 292 | miscbox,教育歴,120mm,50mm,$teaching,font_size=12 293 | ``` 294 | 295 | は、「教育歴」というタイトルの高さ(height)50mmのテキストボックスを、高さ(y座標)120mmのところに配置する、という意味です。最後のフォントサイズ指定は任意です。対応するYAMLレコードは\$teachingです。 296 | 297 | 例えば 298 | 299 | ```yaml 300 | # 教育歴 301 | teaching: | 302 | 「履歴書学特論」平成15年から17年まで 303 | 「PDF出力特論」平成18年から23年まで 304 | 「スタイルファイル特別演習」平成20年から29年まで 305 | ``` 306 | 307 | というデータだったとすると、 308 | 309 | ![sample/teaching.png](sample/teaching.png) 310 | 311 | に展開されます。 312 | 313 | ### スタイルファイル(YAML形式) 314 | 315 | 上記のテキスト形式で書かれたスタイルファイルは内部的にYAMLに変換されて処理されているため、スタイルファイルはYAML形式でも書くことができます。・・・が、実際やってみたら死ぬほど面倒だったので、通常はテキスト形式で書くことになろうかと思います。テキスト形式のスタイルファイルは`txt2yaml.rb`でYAML形式に変換できます。 316 | 317 | 例えば 318 | 319 | ```txt 320 | string,5mm,247mm,履 歴 書,font_size=14,font_face=gothic 321 | string,110mm,245mm,$date,font_size=9 322 | ``` 323 | 324 | を`txt2yaml.rb`に食わせると、 325 | 326 | ```yaml 327 | --- 328 | - type: string 329 | x: 5mm 330 | y: 247mm 331 | value: 履 歴 書 332 | font_size: '14' 333 | font_face: gothic 334 | - type: string 335 | x: 110mm 336 | y: 245mm 337 | value: "$date" 338 | font_size: '9' 339 | ``` 340 | 341 | が出力されます。同様にYAMLで書かれたスタイルファイルは`yaml2txt.rb`でテキスト形式に変換できます。 342 | 343 | ## 参考 344 | 345 | このスクリプトは、[PruneMazui](https://github.com/PruneMazui)さんの[resume-maker](https://github.com/PruneMazui/resume-maker)に影響されて開発したものです。 346 | 347 | ## 履歴 348 | 349 | * 2023年6月29日 Ruby 3.1 以上に対応(Thanks fabon-f)、IPAフォントを同封するように修正 350 | * 2018年7月30日 ymboxマクロ及びmiscboxマクロを追加 351 | * 2018年6月6日 リリース 352 | 353 | ## ライセンス 354 | 355 | * このスクリプトはMITライセンスに従います 356 | * 同封のIPAフォントはIPAフォントライセンスv1.0に従って再配布しています 357 | -------------------------------------------------------------------------------- /academic.txt: -------------------------------------------------------------------------------- 1 | # ヘッダー 2 | string,5mm,247mm,履 歴 書,font_size=14,font_face=gothic 3 | string,110mm,245mm,$date,font_size=9 4 | 5 | # 住所・連絡先等 6 | box,145mm,204mm,30mm,40mm,line_style=dashed 7 | string,148mm,240mm,写真を貼る位置,font_size=9 8 | string,147mm,233mm,1. 縦36〜40 mm,font_size=8 9 | string,150mm,230mm,横24〜30 mm,font_size=8 10 | string,147mm,227mm,2. 本人単身胸から上,font_size=8 11 | string,147mm,224mm,3. 裏面にのりづけ,font_size=8 12 | string,147mm,221mm,4. 裏面に氏名記入,font_size=8 13 | photo,145mm,244mm,30mm,40mm 14 | lines,6,0mm,240mm,139mm,0mm,0mm,-41mm,38mm,0mm,0mm,-36mm,-177mm,0mm,line_width=2.0,close=true 15 | line,0,233mm,139mm,0,line_style=dashed 16 | string,2mm,238mm,ふりがな,font_size=9 17 | string,30mm,238mm,$name_kana,font_size=9 18 | string,2mm,231mm,氏  名,font_size=9 19 | string,30mm,231mm,$name,font_size=14 20 | line,0,218mm,139mm,0mm 21 | line,15mm,218mm,0,-13mm 22 | string,1.5mm,217mm,生年月日,font_size=9 23 | string,30mm,213mm,$birth_day,font_size=12 24 | line,110mm,218mm,0mm,-13mm 25 | string,121mm,214mm,$gender,font_size=12 26 | line,21mm,205mm,0,-6mm,line_style=dashed 27 | string,1.5mm,203.5mm,携帯電話番号,font_size=9 28 | line,0,205mm,139mm,0mm 29 | string,25mm,203.5mm,$cell_phone,font_size=9 30 | line,56mm,205mm,0mm,-6mm 31 | line,69mm,205mm,0mm,-6mm,line_style=dashed 32 | string,57mm,204mm,E-MAIL,font_size=9 33 | string,75mm,204mm,$email,font_size=9 34 | line,0,205mm,139mm,0mm 35 | line,0,199mm,139mm,0mm 36 | line,0,194mm,139mm,0,line_style=dashed 37 | line,0,181mm,177mm,0 38 | line,0,176mm,139mm,0,line_style=dashed 39 | line,139mm,199mm,0mm,-36mm 40 | string,141mm,198mm,電話,font_size=9 41 | string,143mm,190mm,$tel,font_size=9 42 | string,141mm,180mm,電話,font_size=9 43 | string,143mm,172mm,$tel2,font_size=9 44 | string,2mm,198mm,ふりがな,font_size=8 45 | string,20mm,198mm,$address_kana,font_size=8 46 | string,2mm,193mm,現住所 〒,font_size=8 47 | string,15mm,193mm,$address_zip,font_size=8 48 | string,15mm,188mm,$address,font_size=12 49 | string,2mm,180mm,ふりがな,font_size=8 50 | string,20mm,180mm,$address_kana2,font_size=8 51 | string,2mm,175mm,連絡先 〒,font_size=9 52 | string,15mm,175mm,$address_zip2,font_size=9 53 | string,15mm,169mm,$address2,font_size=12 54 | 55 | # 所属学会・学位論文など 56 | box,0mm,137mm,177mm,24mm,line_width=2 57 | line,0mm,145mm,177mm,0mm 58 | line,0mm,153mm,177mm,0mm 59 | line,25mm,137mm,0mm,24mm 60 | line,88mm,153mm,0mm,8mm 61 | line,113mm,153mm,0mm,8mm 62 | 63 | string,4mm,159mm,博士学位 64 | string,92mm,159mm,取得年度 65 | string,4mm,151mm,授与機関 66 | string,4mm,143mm,学位論文 67 | string,26mm,159mm,$degree 68 | string,117mm,159mm,$degree_year 69 | string,26mm,151mm,$degree_affiliation 70 | string,26mm,143mm,$thesis_title,font_face=Times-Roman 71 | 72 | # 学歴・職歴 73 | box,0mm,9mm,177mm,126mm,line_width=2 74 | multi_lines,0mm,16mm,177mm,0,17,0,7mm 75 | line,19mm,135mm,0,-126mm,line_style=dashed 76 | line,31mm,135mm,0,-126mm 77 | string,8mm,133mm,年,font_size=9 78 | string,24mm,133mm,月,font_size=9 79 | string,77mm,133mm,学歴・職歴(各項目ごとにまとめて書く),font_size=9 80 | education_experience,127mm,3mm,24mm,35mm,7mm,95mm,155mm,font_size=12 81 | 82 | 83 | # 2ページ目 84 | new_page 85 | ymbox,免許・資格,204mm,4,$licences 86 | ymbox,主な受賞・表彰等,173mm,3,$awards 87 | miscbox,教育歴,120mm,50mm,$teaching,font_size=12 88 | miscbox,所属学会等,84mm,33mm,$affiliated_society 89 | miscbox,その他特記事項,55mm,26mm,$notices,font_size=12 90 | 91 | # 署名欄 92 | string,113mm,36mm,上記のとおり相違ありません。 93 | string,140mm,24mm,年  月  日 94 | string,165mm,12mm,印 95 | string,85mm,12mm,氏名 96 | line,80mm,5mm,90mm,0 97 | -------------------------------------------------------------------------------- /data.yaml: -------------------------------------------------------------------------------- 1 | # 名前等 2 | date: 2018年 6月 5日現在 3 | name_kana: りれきしょ かくたろう 4 | name: 履歴書 書太郎 5 | birth_day: 1543年1月31日 (満 73 歳) 6 | gender: 男 7 | cell_phone: 090-1234-5678 8 | email: hoge@hogehoge.org 9 | photo: photo.jpg 10 | 11 | # 住所 12 | address_kana: とうきょうとちよだくちよだ 13 | address: 東京都千代田区千代田1-1-1 14 | address_zip: 100-0001 15 | tel: 0120-000-XXX 16 | fax: 0120-111-XXX 17 | # 連絡先 18 | address_kana2: ほっかいどう わっかないし そうやみさき 19 | address2: 北海道稚内市宗谷岬 20 | address_zip2: 098-6758 21 | tel2: 0120-222-XXX 22 | fax2: 0120-333-XXX 23 | 24 | # 学位 25 | degree: 博士(工学) 26 | # 学位取得年度 27 | degree_year: 20XX年度 28 | # 学位授与機関 29 | degree_affiliation: 履歴書大学 30 | # 学位論文 31 | thesis_title: How to write a resume without a spreadsheet 32 | 33 | 34 | # 学歴 35 | education: 36 | - 37 | year: 20XX 38 | month: 4 39 | value: 履歴書大学履歴書学部 入学 40 | - 41 | year: 20XX 42 | month: 3 43 | value: 同 卒業 44 | - 45 | year: 20XX 46 | month: 4 47 | value: 履歴書大学履歴書研究科履歴書専攻博士前期課程 入学 48 | - 49 | year: 20XX 50 | month: 3 51 | value: 同 修了 52 | - 53 | year: 20XX 54 | month: 4 55 | value: 履歴書大学履歴書研究科履歴書専攻博士後期課程 入学 56 | - 57 | year: 20XX 58 | month: 3 59 | value: 同 修了 60 | 61 | 62 | 63 | #職歴 64 | experience: 65 | - 66 | year: 20XX 67 | month: 4 68 | value: 株式会社履歴書入社 69 | - 70 | year: 20XX 71 | month: 10 72 | value: 株式会社履歴書退職 73 | - 74 | year: 20XX 75 | month: 10 76 | value: 株式会社XXX 入社 77 | - 78 | value: 現在にいたる 79 | 80 | # 免許・資格 81 | licences: 82 | - 83 | year: 19XX 84 | month: 11 85 | value: 普通自動車免許 86 | - 87 | year: 20XX 88 | month: 11 89 | value: 履歴書検定1級 90 | 91 | 92 | # 主な受賞・表彰等 93 | awards: 94 | - 95 | year: 20XX 96 | month: 97 | value: 第二回履歴書学会ポスター賞 98 | - 99 | year: 20XX 100 | month: 101 | value: 第五回履歴書学会若手奨励賞 102 | 103 | # 教育歴 104 | teaching: | 105 | 「履歴書学特論」平成15年から17年まで 106 | 「PDF出力特論」平成18年から23年まで 107 | 「スタイルファイル特別演習」平成20年から29年まで 108 | 109 | # 所属学会 110 | affiliated_society: | 111 | 日本履歴書学会 112 | 神エクセル研究会 113 | 114 | # その他特記事項 115 | notices: | 116 | 着任可能時期: 20XX年4月1日 117 | 希望職位: 助教 118 | 119 | #通勤時間 120 | commuting_time: 1時間20分 121 | 122 | #扶養家族数(配偶者を除く) 123 | dependents: 2人 124 | 125 | #配偶者の有無 126 | spouse: 有 127 | 128 | #配偶者の扶養義務 129 | supporting_spouse: 有 130 | 131 | #趣味 132 | hobby: | 133 | 趣味はコンパイラいじめです。 134 | 特技は素手でMOをフォーマットできます。 135 | ちくわ大明神。 136 | 137 | #志望動機 138 | motivation: | 139 | 遊ぶ金欲しさ 140 | 141 | # 本人希望記入欄 142 | request: | 143 | 5000兆円欲しい。 144 | 5000兆FLOPSも欲しい。 145 | 5000兆プロセスも欲しい。 146 | でもスレッドはそんなにたくさんいらない。 147 | -------------------------------------------------------------------------------- /fonts/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaityo256/yaml_cv/7be73eea83251cee4fa12753ec2a3b16417ccea3/fonts/.gitkeep -------------------------------------------------------------------------------- /fonts/IPA_Font_License_Agreement_v1.0.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------- 2 | IPA Font License Agreement v1.0 3 | -------------------------------------------------- 4 | 5 | IPAフォントライセンスv1.0 6 | 7 | 許諾者は、この使用許諾(以下「本契約」といいます。)に定める条件の下で、許諾プログラム(1条に定義するところによります。)を提供します。受領者(1条に定義するところによります。)が、許諾プログラムを使用し、複製し、または頒布する行為、その他、本契約に定める権利の利用を行った場合、受領者は本契約に同意したものと見なします。 8 | 9 | 10 | 第1条 用語の定義 11 | 12 | 本契約において、次の各号に掲げる用語は、当該各号に定めるところによります。 13 | 14 | 1.「デジタル・フォント・プログラム」とは、フォントを含み、レンダリングしまたは表示するために用いられるコンピュータ・プログラムをいいます。 15 | 2.「許諾プログラム」とは、許諾者が本契約の下で許諾するデジタル・フォント・プログラムをいいます。 16 | 3.「派生プログラム」とは、許諾プログラムの一部または全部を、改変し、加除修正等し、入れ替え、その他翻案したデジタル・フォント・プログラムをいい、許諾プログラムの一部もしくは全部から文字情報を取り出し、またはデジタル・ドキュメント・ファイルからエンベッドされたフォントを取り出し、取り出された文字情報をそのまま、または改変をなして新たなデジタル・フォント・プログラムとして製作されたものを含みます。 17 | 4.「デジタル・コンテンツ」とは、デジタル・データ形式によってエンド・ユーザに提供される制作物のことをいい、動画・静止画等の映像コンテンツおよびテレビ番組等の放送コンテンツ、ならびに文字テキスト、画像、図形等を含んで構成された制作物を含みます。 18 | 5.「デジタル・ドキュメント・ファイル」とは、PDFファイルその他、各種ソフトウェア・プログラムによって製作されたデジタル・コンテンツであって、その中にフォントを表示するために許諾プログラムの全部または一部が埋め込まれた(エンベッドされた)ものをいいます。フォントが「エンベッドされた」とは、当該フォントが埋め込まれた特定の「デジタル・ドキュメント・ファイル」においてのみ表示されるために使用されている状態を指し、その特定の「デジタル・ドキュメント・ファイル」以外でフォントを表示するために使用できるデジタル・フォント・プログラムに含まれている場合と区別されます。 19 | 6.「コンピュータ」とは、本契約においては、サーバを含みます。 20 | 7.「複製その他の利用」とは、複製、譲渡、頒布、貸与、公衆送信、上映、展示、翻案その他の利用をいいます。 21 | 8.「受領者」とは、許諾プログラムを本契約の下で受領した人をいい、受領者から許諾プログラムを受領した人を含みます。 22 | 23 | 第2条 使用許諾の付与 24 | 25 | 許諾者は受領者に対し、本契約の条項に従い、すべての国で、許諾プログラムを使用することを許諾します。ただし、許諾プログラムに存在する一切の権利はすべて許諾者が保有しています。本契約は、本契約で明示的に定められている場合を除き、いかなる意味においても、許諾者が保有する許諾プログラムに関する一切の権利および、いかなる商標、商号、もしくはサービス・マークに関する権利をも受領者に移転するものではありません。 26 | 27 | 1.受領者は本契約に定める条件に従い、許諾プログラムを任意の数のコンピュータにインストールし、当該コンピュータで使用することができます。 28 | 2.受領者はコンピュータにインストールされた許諾プログラムをそのまま、または改変を行ったうえで、印刷物およびデジタル・コンテンツにおいて、文字テキスト表現等として使用することができます。 29 | 3.受領者は前項の定めに従い作成した印刷物およびデジタル・コンテンツにつき、その商用・非商用の別、および放送、通信、各種記録メディアなどの媒体の形式を問わず、複製その他の利用をすることができます。 30 | 4.受領者がデジタル・ドキュメント・ファイルからエンベッドされたフォントを取り出して派生プログラムを作成した場合には、かかる派生プログラムは本契約に定める条件に従う必要があります。 31 | 5.許諾プログラムのエンベッドされたフォントがデジタル・ドキュメント・ファイル内のデジタル・コンテンツをレンダリングするためにのみ使用される場合において、受領者が当該デジタル・ドキュメント・ファイルを複製その他の利用をする場合には、受領者はかかる行為に関しては本契約の下ではいかなる義務をも負いません。 32 | 6.受領者は、3条2項の定めに従い、商用・非商用を問わず、許諾プログラムをそのままの状態で改変することなく複製して第三者への譲渡し、公衆送信し、その他の方法で再配布することができます(以下、「再配布」といいます。)。 33 | 7.受領者は、上記の許諾プログラムについて定められた条件と同様の条件に従って、派生プログラムを作成し、使用し、複製し、再配布することができます。ただし、受領者が派生プログラムを再配布する場合には、3条1項の定めに従うものとします。 34 | 35 | 第3条 制限 36 | 37 | 前条により付与された使用許諾は、以下の制限に服します。 38 | 39 | 1.派生プログラムが前条4項及び7項に基づき再配布される場合には、以下の全ての条件を満たさなければなりません。 40 |  (1)派生プログラムを再配布する際には、下記もまた、当該派生プログラムと一緒に再配布され、オンラインで提供され、または、郵送費・媒体及び取扱手数料の合計を超えない実費と引き換えに媒体を郵送する方法により提供されなければなりません。 41 |   (a)派生プログラムの写し; および 42 |   (b)派生プログラムを作成する過程でフォント開発プログラムによって作成された追加のファイルであって派生プログラムをさらに加工するにあたって利用できるファイルが存在すれば、当該ファイル 43 |  (2)派生プログラムの受領者が、派生プログラムを、このライセンスの下で最初にリリースされた許諾プログラム(以下、「オリジナル・プログラム」といいます。)に置き換えることができる方法を再配布するものとします。かかる方法は、オリジナル・ファイルからの差分ファイルの提供、または、派生プログラムをオリジナル・プログラムに置き換える方法を示す指示の提供などが考えられます。 44 |  (3)派生プログラムを、本契約書に定められた条件の下でライセンスしなければなりません。 45 |  (4)派生プログラムのプログラム名、フォント名またはファイル名として、許諾プログラムが用いているのと同一の名称、またはこれを含む名称を使用してはなりません。 46 |  (5)本項の要件を満たすためにオンラインで提供し、または媒体を郵送する方法で提供されるものは、その提供を希望するいかなる者によっても提供が可能です。 47 | 2.受領者が前条6項に基づき許諾プログラムを再配布する場合には、以下の全ての条件を満たさなければなりません。 48 |  (1)許諾プログラムの名称を変更してはなりません。 49 |  (2)許諾プログラムに加工その他の改変を加えてはなりません。 50 |  (3)本契約の写しを許諾プログラムに添付しなければなりません。 51 | 3.許諾プログラムは、現状有姿で提供されており、許諾プログラムまたは派生プログラムについて、許諾者は一切の明示または黙示の保証(権利の所在、非侵害、商品性、特定目的への適合性を含むがこれに限られません)を行いません。いかなる場合にも、その原因を問わず、契約上の責任か厳格責任か過失その他の不法行為責任かにかかわらず、また事前に通知されたか否かにかかわらず、許諾者は、許諾プログラムまたは派生プログラムのインストール、使用、複製その他の利用または本契約上の権利の行使によって生じた一切の損害(直接・間接・付随的・特別・拡大・懲罰的または結果的損害)(商品またはサービスの代替品の調達、システム障害から生じた損害、現存するデータまたはプログラムの紛失または破損、逸失利益を含むがこれに限られません)について責任を負いません。 52 | 4.許諾プログラムまたは派生プログラムのインストール、使用、複製その他の利用に関して、許諾者は技術的な質問や問い合わせ等に対する対応その他、いかなるユーザ・サポートをも行う義務を負いません。 53 | 54 | 第4条 契約の終了 55 | 56 | 1.本契約の有効期間は、受領者が許諾プログラムを受領した時に開始し、受領者が許諾プログラムを何らかの方法で保持する限り続くものとします。 57 | 2.前項の定めにかかわらず、受領者が本契約に定める各条項に違反したときは、本契約は、何らの催告を要することなく、自動的に終了し、当該受領者はそれ以後、許諾プログラムおよび派生プログラムを一切使用しまたは複製その他の利用をすることができないものとします。ただし、かかる契約の終了は、当該違反した受領者から許諾プログラムまたは派生プログラムの配布を受けた受領者の権利に影響を及ぼすものではありません。 58 | 59 | 第5条 準拠法 60 | 61 | 1.IPAは、本契約の変更バージョンまたは新しいバージョンを公表することができます。その場合には、受領者は、許諾プログラムまたは派生プログラムの使用、複製その他の利用または再配布にあたり、本契約または変更後の契約のいずれかを選択することができます。その他、上記に記載されていない条項に関しては日本の著作権法および関連法規に従うものとします。 62 | 2.本契約は、日本法に基づき解釈されます。 63 | 64 | 65 | ---------- 66 | 67 | IPA Font License Agreement v1.0 68 | 69 | The Licensor provides the Licensed Program (as defined in Article 1 below) under the terms of this license agreement (“Agreement”). Any use, reproduction or distribution of the Licensed Program, or any exercise of rights under this Agreement by a Recipient (as defined in Article 1 below) constitutes the Recipient's acceptance of this Agreement. 70 | 71 | Article 1 (Definitions) 72 | 1.“Digital Font Program” shall mean a computer program containing, or used to render or display fonts. 73 | 2.“Licensed Program” shall mean a Digital Font Program licensed by the Licensor under this Agreement. 74 | 3.“Derived Program” shall mean a Digital Font Program created as a result of a modification, addition, deletion, replacement or any other adaptation to or of a part or all of the Licensed Program, and includes a case where a Digital Font Program newly created by retrieving font information from a part or all of the Licensed Program or Embedded Fonts from a Digital Document File with or without modification of the retrieved font information. 75 | 4.“Digital Content” shall mean products provided to end users in the form of digital data, including video content, motion and/or still pictures, TV programs or other broadcasting content and products consisting of character text, pictures, photographic images, graphic symbols and/or the like. 76 | 5.“Digital Document File” shall mean a PDF file or other Digital Content created by various software programs in which a part or all of the Licensed Program becomes embedded or contained in the file for the display of the font (“Embedded Fonts”). Embedded Fonts are used only in the display of characters in the particular Digital Document File within which they are embedded, and shall be distinguished from those in any Digital Font Program, which may be used for display of characters outside that particular Digital Document File. 77 | 6.“Computer” shall include a server in this Agreement. 78 | 7.“Reproduction and Other Exploitation” shall mean reproduction, transfer, distribution, lease, public transmission, presentation, exhibition, adaptation and any other exploitation. 79 | 8.“Recipient” shall mean anyone who receives the Licensed Program under this Agreement, including one that receives the Licensed Program from a Recipient. 80 | 81 | Article 2 (Grant of License) 82 | The Licensor grants to the Recipient a license to use the Licensed Program in any and all countries in accordance with each of the provisions set forth in this Agreement. However, any and all rights underlying in the Licensed Program shall be held by the Licensor. In no sense is this Agreement intended to transfer any right relating to the Licensed Program held by the Licensor except as specifically set forth herein or any right relating to any trademark, trade name, or service mark to the Recipient. 83 | 84 | 1.The Recipient may install the Licensed Program on any number of Computers and use the same in accordance with the provisions set forth in this Agreement. 85 | 2.The Recipient may use the Licensed Program, with or without modification in printed materials or in Digital Content as an expression of character texts or the like. 86 | 3.The Recipient may conduct Reproduction and Other Exploitation of the printed materials and Digital Content created in accordance with the preceding Paragraph, for commercial or non-commercial purposes and in any form of media including but not limited to broadcasting, communication and various recording media. 87 | 4.If any Recipient extracts Embedded Fonts from a Digital Document File to create a Derived Program, such Derived Program shall be subject to the terms of this agreement. 88 | 5.If any Recipient performs Reproduction or Other Exploitation of a Digital Document File in which Embedded Fonts of the Licensed Program are used only for rendering the Digital Content within such Digital Document File then such Recipient shall have no further obligations under this Agreement in relation to such actions. 89 | 6.The Recipient may reproduce the Licensed Program as is without modification and transfer such copies, publicly transmit or otherwise redistribute the Licensed Program to a third party for commercial or non-commercial purposes (“Redistribute”), in accordance with the provisions set forth in Article 3 Paragraph 2. 90 | 7.The Recipient may create, use, reproduce and/or Redistribute a Derived Program under the terms stated above for the Licensed Program: provided, that the Recipient shall follow the provisions set forth in Article 3 Paragraph 1 when Redistributing the Derived Program. 91 | 92 | Article 3 (Restriction) 93 | The license granted in the preceding Article shall be subject to the following restrictions: 94 | 95 | 1.If a Derived Program is Redistributed pursuant to Paragraph 4 and 7 of the preceding Article, the following conditions must be met : 96 |  (1)The following must be also Redistributed together with the Derived Program, or be made available online or by means of mailing mechanisms in exchange for a cost which does not exceed the total costs of postage, storage medium and handling fees: 97 |   (a)a copy of the Derived Program; and 98 |   (b)any additional file created by the font developing program in the course of creating the Derived Program that can be used for further modification of the Derived Program, if any. 99 |  (2)It is required to also Redistribute means to enable recipients of the Derived Program to replace the Derived Program with the Licensed Program first released under this License (the “Original Program”). Such means may be to provide a difference file from the Original Program, or instructions setting out a method to replace the Derived Program with the Original Program. 100 |  (3)The Recipient must license the Derived Program under the terms and conditions of this Agreement. 101 |  (4)No one may use or include the name of the Licensed Program as a program name, font name or file name of the Derived Program. 102 |  (5)Any material to be made available online or by means of mailing a medium to satisfy the requirements of this paragraph may be provided, verbatim, by any party wishing to do so. 103 | 2.If the Recipient Redistributes the Licensed Program pursuant to Paragraph 6 of the preceding Article, the Recipient shall meet all of the following conditions: 104 |  (1)The Recipient may not change the name of the Licensed Program. 105 |  (2)The Recipient may not alter or otherwise modify the Licensed Program. 106 |  (3)The Recipient must attach a copy of this Agreement to the Licensed Program. 107 | 3.THIS LICENSED PROGRAM IS PROVIDED BY THE LICENSOR “AS IS” AND ANY EXPRESSED OR IMPLIED WARRANTY AS TO THE LICENSED PROGRAM OR ANY DERIVED PROGRAM, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXTENDED, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO; PROCUREMENT OF SUBSTITUTED GOODS OR SERVICE; DAMAGES ARISING FROM SYSTEM FAILURE; LOSS OR CORRUPTION OF EXISTING DATA OR PROGRAM; LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE INSTALLATION, USE, THE REPRODUCTION OR OTHER EXPLOITATION OF THE LICENSED PROGRAM OR ANY DERIVED PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 108 | 4.The Licensor is under no obligation to respond to any technical questions or inquiries, or provide any other user support in connection with the installation, use or the Reproduction and Other Exploitation of the Licensed Program or Derived Programs thereof. 109 | 110 | Article 4 (Termination of Agreement) 111 | 1.The term of this Agreement shall begin from the time of receipt of the Licensed Program by the Recipient and shall continue as long as the Recipient retains any such Licensed Program in any way. 112 | 2.Notwithstanding the provision set forth in the preceding Paragraph, in the event of the breach of any of the provisions set forth in this Agreement by the Recipient, this Agreement shall automatically terminate without any notice. In the case of such termination, the Recipient may not use or conduct Reproduction and Other Exploitation of the Licensed Program or a Derived Program: provided that such termination shall not affect any rights of any other Recipient receiving the Licensed Program or the Derived Program from such Recipient who breached this Agreement. 113 | 114 | Article 5 (Governing Law) 115 | 1.IPA may publish revised and/or new versions of this License. In such an event, the Recipient may select either this Agreement or any subsequent version of the Agreement in using, conducting the Reproduction and Other Exploitation of, or Redistributing the Licensed Program or a Derived Program. Other matters not specified above shall be subject to the Copyright Law of Japan and other related laws and regulations of Japan. 116 | 2.This Agreement shall be construed under the laws of Japan. 117 | 118 | -------------------------------------------------------------------------------- /fonts/Readme_IPAexfont00401.txt: -------------------------------------------------------------------------------- 1 | IPAexフォント 2 | ― はじめにお読みください ― 3 | 4 | IPAexフォントは、JIS X 0213:2012に準拠したTrueTypeアウトラインベースのOpenTypeフォントです。 5 | 6 | IPAexフォントの使用または利用に当たっては、添付の「IPAフォントライセンスv1.0」に定める条件に従ってください。 7 | IPAexフォントを使用し、複製し、または頒布する行為、その他、「IPAフォントライセンスv1.0」に定める権利の利用を行った場合、受領者は「IPAフォントライセンスv1.0」に同意したものと見なします。 8 | 9 | 10 | IPAexフォント2書体パック(IPAexゴシック、IPAex明朝) IPAexfont00401.zip 11 | |--はじめにお読みください Readme_IPAexfont00401.txt 12 | |--IPAフォントライセンスv1.0 IPA_Font_License_Agreement_v1.0.txt 13 | |--IPAexゴシック(Ver.004.01) ipaexg.ttf 14 | |--IPAex明朝(Ver.004.01) ipaexm.ttf 15 | 16 | 17 | 「IPAフォント」は、IPAの登録商標です。 18 | 19 | ========================= 20 | IPAex Font 21 | -- Readme -- 22 | 23 | IPAex Fonts are JIS X 0213:2012 compliant OpenType fonts based on TrueType outlines. 24 | 25 | In using IPAex fonts, please comply with the terms and conditions set out in "IPA Font License Agreement v1.0" included in this package. 26 | Any use, reproduction or distribution of the IPA Font or any exercise of rights under "IPA Font License Agreement v1.0" by a Recipient constitutes the Recipient's acceptance of the License Agreement. 27 | 28 | 29 | IPAex Fonts 2 fonts package (IPAex Gothic、IPAex Mincho) IPAexfont00401.zip 30 | |--Readme Readme_IPAexfont00401.txt 31 | |--IPA Font License Agreement v1.0 IPA_Font_License_Agreement_v1.0.txt 32 | |--IPAexGothic(Ver.004.01) ipaexg.ttf 33 | |--IPAexMincho(Ver.004.01) ipaexm.ttf 34 | 35 | 36 | "IPA Font" is a registered trademark of IPA in Japan. 37 | -------------------------------------------------------------------------------- /fonts/ipaexg.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaityo256/yaml_cv/7be73eea83251cee4fa12753ec2a3b16417ccea3/fonts/ipaexg.ttf -------------------------------------------------------------------------------- /fonts/ipaexm.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaityo256/yaml_cv/7be73eea83251cee4fa12753ec2a3b16417ccea3/fonts/ipaexm.ttf -------------------------------------------------------------------------------- /make_cv.rb: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | require "optparse" 3 | require "bundler" 4 | Bundler.require 5 | require "yaml" 6 | require_relative "txt2yaml" 7 | 8 | $font_faces = Hash.new 9 | $font_faces["mincho"] = "fonts/ipaexm.ttf" 10 | $font_faces["gothic"] = "fonts/ipaexg.ttf" 11 | 12 | DEFAULT_FONT_FACE = "mincho" 13 | DEFAULT_FONT_SIZE = 12 14 | DEFAULT_LINE_WIDTH = 0.5 15 | DPI = 75 16 | 17 | class CVMaker 18 | def size(s) 19 | if s =~ /\s*(\-?[0-9\.]+)\s*mm/ 20 | $1.to_f / 25.4 * DPI 21 | elsif s =~ /\s*(-?[0-9\.]+)\s*cm/ 22 | $1.to_f / 25.4 * DPI * 10 23 | elsif s =~ /\s*(-?[0-9\.]+)\s*px/ 24 | $1.to_f 25 | else 26 | s.to_f 27 | end 28 | end 29 | 30 | def line_style(h) 31 | if h.has_key?("line_style") 32 | case h["line_style"] 33 | when "solid" 34 | undash 35 | when "dashed" 36 | d = DEFAULT_LINE_WIDTH 37 | @doc.dash([d, d]) 38 | end 39 | else 40 | @doc.undash 41 | end 42 | if h.has_key?("line_width") 43 | @doc.line_width(h["line_width"]) 44 | else 45 | @doc.line_width(DEFAULT_LINE_WIDTH) 46 | end 47 | end 48 | 49 | def get_value(h) 50 | value = h["value"] 51 | if value =~ /\$(.*)$/ 52 | value = @data.fetch($1, "") 53 | end 54 | value 55 | end 56 | 57 | def get_font(h) 58 | font_size = h.fetch("font_size", DEFAULT_FONT_SIZE).to_f 59 | face = h.fetch("font_face", DEFAULT_FONT_FACE) 60 | font_face = "" 61 | if $font_faces.has_key?(face) 62 | font_face = $font_faces[face] 63 | else 64 | font_face = face 65 | end 66 | return font_size, font_face 67 | end 68 | 69 | def put_string(x, y, str, font_size, font_face) 70 | return if str == "" 71 | w = font_size * str.size 72 | h = font_size 73 | @doc.bounding_box([x, y], :width => w, :height => h) do 74 | @doc.font_size font_size 75 | @doc.font font_face 76 | @doc.text str 77 | end 78 | end 79 | 80 | def photo(h) 81 | return if !@data.has_key?("photo") 82 | x = size(h["x"]) 83 | y = size(h["y"]) 84 | width = size(h["width"]) 85 | height = size(h["height"]) 86 | file = @data["photo"] 87 | @doc.image(file, :at => [x, y], :width => width, :height => height) 88 | end 89 | 90 | def string(h) 91 | x = size(h["x"]) 92 | y = size(h["y"]) 93 | str = get_value(h) 94 | font_size, font_face = get_font(h) 95 | w = font_size * str.to_s.size 96 | h = font_size 97 | @doc.bounding_box([x, y], :width => w, :height => h) do 98 | @doc.font_size font_size 99 | @doc.font font_face 100 | @doc.text str 101 | end 102 | end 103 | 104 | def box(h) 105 | line_style(h) 106 | x = size(h["x"]) 107 | y = size(h["y"]) 108 | w = size(h["width"]) 109 | h = size(h["height"]) 110 | @doc.move_to(x, y) 111 | @doc.line_to(x + w, y) 112 | @doc.line_to(x + w, y + h) 113 | @doc.line_to(x, y + h) 114 | @doc.close_and_stroke 115 | end 116 | 117 | def line(h) 118 | line_style(h) 119 | x = size(h["x"]) 120 | y = size(h["y"]) 121 | dx = size(h["dx"]) 122 | dy = size(h["dy"]) 123 | @doc.move_to(x, y) 124 | @doc.line_to(x + dx, y + dy) 125 | @doc.stroke 126 | end 127 | 128 | def lines(h) 129 | line_style(h) 130 | points = h["points"] 131 | x = size(points[0]["x"]) 132 | y = size(points[0]["y"]) 133 | close = h.has_key?("close") 134 | @doc.move_to(x, y) 135 | points[1..(points.size - 1)].each do |i| 136 | if i.has_key?("dx") 137 | x = x + size(i["dx"]) 138 | else 139 | x = size(i["x"]) 140 | end 141 | if i.has_key?("dy") 142 | y = y + size(i["dy"]) 143 | else 144 | y = size(i["y"]) 145 | end 146 | @doc.line_to(x, y) 147 | end 148 | if close 149 | @doc.close_and_stroke 150 | else 151 | @doc.stroke 152 | end 153 | end 154 | 155 | def multi_lines(h) 156 | line_style(h) 157 | x = size(h["x"]) 158 | y = size(h["y"]) 159 | dx = size(h["dx"]) 160 | dy = size(h["dy"]) 161 | sx = size(h["sx"]) 162 | sy = size(h["sy"]) 163 | n = h["num"].to_i 164 | n.times do |i| 165 | @doc.move_to(x, y) 166 | @doc.line_to(x + dx, y + dy) 167 | @doc.stroke 168 | x = x + sx 169 | y = y + sy 170 | end 171 | end 172 | 173 | def puts_history(year_x, month_x, value_x, h) 174 | year = h.fetch("year", "").to_s 175 | month = h.fetch("month", "").to_s 176 | put_string(year_x, y, year, font_size, font_face) 177 | x = month_x - (month.size - 1) * font_size * 0.3 178 | put_string(x, y, month, font_size, font_face) 179 | put_string(value_x, y, h["value"].to_s, font_size, font_face) 180 | end 181 | 182 | # 学歴・職歴 183 | def education_experience(h) 184 | y = size(h["y"]) 185 | year_x = size(h["year_x"]) 186 | month_x = size(h["month_x"]) 187 | value_x = size(h["value_x"]) 188 | ijo_x = size(h["ijo_x"]) 189 | dy = size(h["dy"]) 190 | caption_x = size(h["caption_x"]) 191 | font_size, font_face = get_font(h) 192 | put_string(caption_x, y, "学歴", font_size, font_face) 193 | y = y - dy 194 | education = @data["education"] 195 | education.each do |i| 196 | year = i.fetch("year", "").to_s 197 | month = i.fetch("month", "").to_s 198 | put_string(year_x, y, year, font_size, font_face) 199 | x = month_x - (month.size - 1) * font_size * 0.3 200 | put_string(x, y, month, font_size, font_face) 201 | put_string(value_x, y, i["value"].to_s, font_size, font_face) 202 | y = y - dy 203 | end 204 | put_string(caption_x, y, "職歴", font_size, font_face) 205 | y = y - dy 206 | experience = @data["experience"] 207 | experience.each do |i| 208 | year = i.fetch("year", "").to_s 209 | month = i.fetch("month", "").to_s 210 | put_string(year_x, y, year, font_size, font_face) 211 | x = month_x - (month.size - 1) * font_size * 0.3 212 | put_string(x, y, month, font_size, font_face) 213 | put_string(value_x, y, i["value"].to_s, font_size, font_face) 214 | y = y - dy 215 | end 216 | put_string(ijo_x, y, "以上", font_size, font_face) 217 | end 218 | 219 | def new_page(h) 220 | @doc.start_new_page 221 | end 222 | 223 | # 年・月・内容形式 224 | def history(h) 225 | y = size(h["y"]) 226 | year_x = size(h["year_x"]) 227 | month_x = size(h["month_x"]) 228 | value_x = size(h["value_x"]) 229 | font_size, font_face = get_font(h) 230 | data = get_value(h) 231 | dy = size(h["dy"]) 232 | return if data == "" 233 | data.each do |i| 234 | year = i.fetch("year", "").to_s 235 | month = i.fetch("month", "").to_s 236 | put_string(year_x, y, year, font_size, font_face) 237 | x = month_x - (month.size - 1) * font_size * 0.3 238 | put_string(x, y, month, font_size, font_face) 239 | put_string(value_x, y, i["value"].to_s, font_size, font_face) 240 | y = y + dy 241 | end 242 | end 243 | 244 | def textbox(h) 245 | x = size(h["x"]) 246 | y = size(h["y"]) 247 | width = size(h["width"]) 248 | height = size(h["height"]) 249 | value = get_value(h) 250 | font_size, font_face = get_font(h) 251 | @doc.bounding_box([x, y], :width => width, :height => height) do 252 | @doc.font_size font_size 253 | @doc.font font_face 254 | @doc.text value 255 | end 256 | end 257 | 258 | def generate(input_file, style_file, output_file) 259 | @data = YAML.load_file(input_file) 260 | @doc = Prawn::Document.new(:page_size => "A4") 261 | puts "input file: #{input_file}" 262 | puts "style file: #{style_file}" 263 | puts "output file: #{output_file}" 264 | yaml_style = nil 265 | if style_file =~ /\.txt$/ 266 | yaml_style = TXT2YAMLConverter.new.convert(style_file) 267 | else 268 | yaml_style = YAML.load_file(style_file) 269 | end 270 | yaml_style.each do |i| 271 | send(i["type"], i) 272 | end 273 | @doc.render_file output_file 274 | puts "Done." 275 | end 276 | end 277 | 278 | def parse_option 279 | args = {} 280 | OptionParser.new do |op| 281 | op.on("-i [datafile]", "--input [datafile]") { |v| args[:input] = v } 282 | op.on("-s [stylefile]", "--style [stylefile]") { |v| args[:style] = v } 283 | op.on("-o [output]", "--output [output]") { |v| args[:output] = v } 284 | op.parse!(ARGV) 285 | end 286 | args 287 | end 288 | 289 | def check_fonts 290 | $font_faces.each do |k, v| 291 | if !File.exist?(v) 292 | puts < a.shift, "y" => a.shift} 76 | (n - 1).times do 77 | points << {"dx" => a.shift, "dy" => a.shift} 78 | end 79 | rest(a, h) 80 | h 81 | end 82 | 83 | def multi_lines(a) 84 | h = Hash.new 85 | h["type"] = a.shift 86 | h["x"] = a.shift 87 | h["y"] = a.shift 88 | h["dx"] = a.shift 89 | h["dy"] = a.shift 90 | h["num"] = a.shift 91 | h["sx"] = a.shift 92 | h["sy"] = a.shift 93 | h 94 | end 95 | 96 | def education_experience(a) 97 | h = Hash.new 98 | h["type"] = a.shift 99 | h["y"] = a.shift 100 | h["year_x"] = a.shift 101 | h["month_x"] = a.shift 102 | h["value_x"] = a.shift 103 | h["dy"] = a.shift 104 | h["caption_x"] = a.shift 105 | h["ijo_x"] = a.shift 106 | rest(a, h) 107 | h 108 | end 109 | 110 | def new_page(a) 111 | h = {"type" => "new_page"} 112 | h 113 | end 114 | 115 | def history(a) 116 | h = Hash.new 117 | h["type"] = a.shift 118 | h["y"] = a.shift 119 | h["year_x"] = a.shift 120 | h["month_x"] = a.shift 121 | h["value_x"] = a.shift 122 | h["dy"] = a.shift 123 | h["value"] = a.shift 124 | rest(a, h) 125 | h 126 | end 127 | 128 | def ymbox(a) 129 | a.shift 130 | name = a.shift 131 | y = size(a.shift) 132 | num = a.shift.to_i 133 | value = a.shift 134 | h = Hash[*a.map { |v| v.split(/=/) }.flatten] 135 | history_fontsize = h.fetch("font_size", 12) 136 | sy = size("7mm") 137 | dy = (num + 1) * sy 138 | namepos = 104 - name.length * 1.7 139 | r = Array.new 140 | r.push box("box,0,#{y},177mm,#{dy},line_width=2".split(",")) 141 | r.push line("line,19mm,#{y + dy},0,#{-dy},line_style=dashed".split(",")) 142 | r.push line("line,31mm,#{y + dy},0,#{-dy}".split(",")) 143 | r.push multi_lines("multi_lines,0,#{y + dy - sy},177mm,0,#{num},0,-7mm".split(",")) 144 | r.push history("history,#{y + dy - sy - size("2mm")},3mm,24mm,35mm,-7mm,#{value},font_size=#{history_fontsize}".split(",")) 145 | r.push string("string,8mm,#{y + dy - size("2mm")},年,font_size=9".split(",")) 146 | r.push string("string,24mm,#{y + dy - size("2mm")},月,font_size=9".split(",")) 147 | r.push string("string,#{namepos}mm,#{y + dy - size("2mm")},#{name},font_size=9".split(",")) 148 | return r 149 | end 150 | 151 | def miscbox(a) 152 | a.shift 153 | name = a.shift 154 | y = size(a.shift) 155 | height = size(a.shift) 156 | value = a.shift 157 | h = Hash[*a.map { |v| v.split(/=/) }.flatten] 158 | textbox_fontsize = h.fetch("font_size", 12) 159 | namepos = size((88.5 - name.length * 1.7).to_s + "mm") 160 | r = Array.new 161 | r.push string("string,#{namepos},#{y + height - size("2mm")},#{name},font_size=9".split(",")) 162 | r.push line("line,0,#{y + height - size("7mm")},177mm,0".split(",")) 163 | r.push textbox("textbox,2mm,#{y + height - size("9mm")},175mm,#{height - size("9mm")},#{value},font_size=#{textbox_fontsize}".split(",")) 164 | r.push box("box,0,#{y},177mm,#{height},line_width=2".split(",")) 165 | r 166 | end 167 | 168 | def textbox(a) 169 | h = Hash.new 170 | h["type"] = a.shift 171 | h["x"] = a.shift 172 | h["y"] = a.shift 173 | h["width"] = a.shift 174 | h["height"] = a.shift 175 | h["value"] = a.shift 176 | rest(a, h) 177 | h 178 | end 179 | 180 | def convert(filename) 181 | data = [] 182 | open(filename) do |f| 183 | while line = f.gets 184 | next if line =~ /^#/ 185 | next if line.chomp == "" 186 | a = line.chomp.split(/,/) 187 | d = send(a[0], a) 188 | next if d == nil 189 | if d.kind_of?(Array) 190 | data = data + d 191 | else 192 | data.push d 193 | end 194 | end 195 | end 196 | data 197 | end 198 | end 199 | 200 | class TXT2YAMLConverter 201 | include TXT2YAML 202 | end 203 | 204 | if caller.length == 0 205 | if ARGV.size == 0 206 | puts "usage: input.txt" 207 | exit 208 | end 209 | 210 | filename = ARGV[0] 211 | data = TXT2YAMLConverter.new.convert(filename) 212 | YAML.dump(data, $stdout) 213 | end 214 | -------------------------------------------------------------------------------- /yaml2txt.rb: -------------------------------------------------------------------------------- 1 | require "yaml" 2 | 3 | def string(h) 4 | a = [] 5 | a.push h.delete("type") 6 | a.push h.delete("x") 7 | a.push h.delete("y") 8 | a.push h.delete("value") 9 | a = a + h.collect { |k, v| "#{k}=#{v}" } 10 | puts a.join(",") 11 | end 12 | 13 | def box(h) 14 | a = [] 15 | a.push h.delete("type") 16 | a.push h.delete("x") 17 | a.push h.delete("y") 18 | a.push h.delete("width") 19 | a.push h.delete("height") 20 | a = a + h.collect { |k, v| "#{k}=#{v}" } 21 | puts a.join(",") 22 | end 23 | 24 | def photo(h) 25 | a = [] 26 | a.push h.delete("type") 27 | a.push h.delete("x") 28 | a.push h.delete("y") 29 | a.push h.delete("width") 30 | a.push h.delete("height") 31 | puts a.join(",") 32 | end 33 | 34 | def line(h) 35 | a = [] 36 | a.push h.delete("type") 37 | a.push h.delete("x") 38 | a.push h.delete("y") 39 | a.push h.delete("dx") 40 | a.push h.delete("dy") 41 | a = a + h.collect { |k, v| "#{k}=#{v}" } 42 | puts a.join(",") 43 | end 44 | 45 | def lines(h) 46 | a = [] 47 | a.push h.delete("type") 48 | points = h.delete("points") 49 | a.push points.size 50 | s = points.shift 51 | a.push s["x"] 52 | a.push s["y"] 53 | points.each do |i| 54 | a.push i["dx"] 55 | a.push i["dy"] 56 | end 57 | a = a + h.collect { |k, v| "#{k}=#{v}" } 58 | puts a.join(",") 59 | end 60 | 61 | def multi_lines(h) 62 | a = [] 63 | a.push h.delete("type") 64 | a.push h.delete("x") 65 | a.push h.delete("y") 66 | a.push h.delete("dx") 67 | a.push h.delete("dy") 68 | a.push h.delete("num") 69 | a.push h.delete("sx") 70 | a.push h.delete("sy") 71 | puts a.join(",") 72 | end 73 | 74 | def education_experience(h) 75 | a = [] 76 | a.push h.delete("type") 77 | a.push h.delete("y") 78 | a.push h.delete("year_x") 79 | a.push h.delete("month_x") 80 | a.push h.delete("value_x") 81 | a.push h.delete("dy") 82 | a.push h.delete("caption_x") 83 | a.push h.delete("ijo_x") 84 | a = a + h.collect { |k, v| "#{k}=#{v}" } 85 | puts a.join(",") 86 | end 87 | 88 | def new_page(h) 89 | puts h.delete("type") 90 | end 91 | 92 | def history(h) 93 | a = [] 94 | a.push h.delete("type") 95 | a.push h.delete("y") 96 | a.push h.delete("year_x") 97 | a.push h.delete("month_x") 98 | a.push h.delete("value_x") 99 | a.push h.delete("dy") 100 | a.push h.delete("value") 101 | a = a + h.collect { |k, v| "#{k}=#{v}" } 102 | puts a.join(",") 103 | end 104 | 105 | def textbox(h) 106 | a = [] 107 | a.push h.delete("type") 108 | a.push h.delete("x") 109 | a.push h.delete("y") 110 | a.push h.delete("width") 111 | a.push h.delete("height") 112 | a.push h.delete("value") 113 | a = a + h.collect { |k, v| "#{k}=#{v}" } 114 | puts a.join(",") 115 | end 116 | 117 | if ARGV.size == 0 118 | puts "usage: input.yaml" 119 | exit 120 | end 121 | 122 | filename = ARGV[0] 123 | 124 | y = YAML.load_file(filename) 125 | 126 | y.each do |i| 127 | send(i["type"], i) 128 | end 129 | --------------------------------------------------------------------------------