From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from tama50.ecl.ntt.co.jp (tama50.ecl.ntt.co.jp [129.60.39.147]) by dpdk.org (Postfix) with ESMTP id B3EC12C55 for ; Fri, 31 Aug 2018 11:14:52 +0200 (CEST) Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id w7V9EpRf030935; Fri, 31 Aug 2018 18:14:51 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 9FBEFEA8115; Fri, 31 Aug 2018 18:14:51 +0900 (JST) Received: from localhost.localdomain (unknown [129.60.13.51]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 88CF3EA6DDE; Fri, 31 Aug 2018 18:14:51 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com Cc: Yasufumi Ogawa Date: Fri, 31 Aug 2018 18:14:35 +0900 Message-Id: <20180831091441.39055-6-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20180831091441.39055-1-ogawa.yasufumi@lab.ntt.co.jp> References: <20180831091441.39055-1-ogawa.yasufumi@lab.ntt.co.jp> X-TM-AS-MML: disable Subject: [spp] [PATCH 05/11] docs: add script for generating PDF images X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Aug 2018 09:14:53 -0000 From: Yasufumi Ogawa To compile a PDF document, each of embedded images also should PDF. SVG is not supported for embedding an image in the PDF document. This update is to add a helper script for generating PDF images from SVG with inkscape command which is a recommended tool for editing a SVG file in DPDK. Signed-off-by: Yasufumi Ogawa --- docs/guides/gen_pdf_imgs.py | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 docs/guides/gen_pdf_imgs.py diff --git a/docs/guides/gen_pdf_imgs.py b/docs/guides/gen_pdf_imgs.py new file mode 100644 index 0000000..4459316 --- /dev/null +++ b/docs/guides/gen_pdf_imgs.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Nippon Telegraph and Telephone Corporation + +# Generate PDF images form SVG to embed targetting PDF document. + +import os +import subprocess + +DPI = 300 # resolution for export + + +def filter_list(alist, ext='svg'): + """Filter files with given extension""" + + res = [] + for ent in alist: + ent_ext = ent.split('.').pop() + if ent_ext == ext: + res.append(ent) + return res + + +def main(): + work_dir = os.path.dirname(__file__) + if work_dir == '': + work_dir = '.' + + img_dir_info = os.walk('%s/images' % work_dir) + for root, dirs, files in img_dir_info: + if len(files) > 0: + svg_files = filter_list(files) + for fname in svg_files: + # setup inkscape options + tmp = fname.split('.') + tmp.pop() + base_fname = tmp[0] + svg_f = base_fname + '.svg' + pdf_f = base_fname + '.pdf' + svg_fpath = '%s/%s' % (root, svg_f) + pdf_fpath = '%s/%s' % (root, pdf_f) + + cmd = 'inkscape -d %d -D -f %s --export-pdf %s' % ( + DPI, svg_fpath, pdf_fpath) + print(cmd) + subprocess.call(cmd, shell=True) + + +if __name__ == "__main__": + main() -- 2.7.4