■blockdiag/nwdiag/actdiagでA4縦、A4横に自動的にSVG/PDFを拡大、縮小出力する。 余談 -> inkscapeやps2pdfとの連携。 参考:SVGの座標 http://www6.airnet.ne.jp/manyo/xml/svg/step2.html 実際にSVGの内容が表示される領域 -> viewPort SVGの内容の大きさから見て狭いviewportに合うようにする -> viewBox SVGの内容を表示する領域をA4とすることで、元の図が収まるよう自動的にリサイズしてくれる。 viewBoxより、viewportの方が大きいと拡大 viewBoxより、viewportの方が小さいと縮小 -> 1ページサイズという点に注意。 ■90dpiでA4サイズ(210mmx297mm)を計算。 「744.094」ですか。。。 $ echo "297 210" | awk '{print $1*90/25.4,$2*90/25.4}' 1052.36 744.094 ■小数点第二位までに制限 $ echo "297 210" | awk '{printf "%4.2f %4.2f\n",$1*90/25.4,$2*90/25.4}' 1052.36 744.09 ■サンプルファイルの取得 nwdiag 出力サンプル http://blockdiag.com/ja/nwdiag/nwdiag-examples.html $ cat nw_sample.diag nwdiag { network dmz { address = "210.x.x.x/24" web01 [address = "210.x.x.1"]; web02 [address = "210.x.x.2"]; } network internal { address = "172.x.x.x/24"; web01 [address = "172.x.x.1"]; web02 [address = "172.x.x.2"]; db01; db02; } } ■python-*diagで出力されるSVGにはviewPortの属性の設定が無い。 $ nwdiag -T svg nw_sample.diag && grep "^<svg" nw_sample.svg <svg viewBox="0 0 760 444" xmlns="http://www.w3.org/2000/svg" xmlns:inkspace="http://www.inkscape.org/namespaces/inkscape" xmlns:xlink="http://www.w3.org/1999/xlink"> ■A4縦(inkscapeでPDF出力) ※svgの時点でA4縦なので、そのままinkscapeで編集出来る。 $ nwdiag -T svg nw_sample.diag && \ sed -i s%"^<svg "%"&width=\"744.09\" height=\"1052.36\" "% nw_sample.svg && \ inkscape -A nw_sample.pdf nw_sample.svg ■A4横(inkscapeでPDF出力) ※svgの時点でA4横なので、そのままinkscapeで編集出来る。 $ nwdiag -T svg nw_sample.diag && \ sed -i s%"^<svg "%"&width=\"1052.36\" height=\"744.09\" "% nw_sample.svg && \ inkscape -A nw_sample.pdf nw_sample.svg ■A4縦(ps2pdfを介す版) ※psが縦の場合は「=」。「-sPAGESIZE=a4」 $ nwdiag -T svg nw_sample.diag && \ sed -i s%"^<svg "%"&width=\"744.09\" height=\"1052.36\" "% nw_sample.svg && \ inkscape -P nw_sample.ps nw_sample.svg && \ ps2pdf -sPAGESIZE=a4 nw_sample.ps nw_sample.pdf ※ps2pdfのpsがA4横の場合は「=」を「#」にすれば出来るはずだが上手くいかなかった。 上記の方法か、inkscapeでSVGをGUIで開いてPDF保存する方法でも良い。 自動でなくてもよいのであれば、inkscapeのGUIでも出来る。。。