From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bcmv-tmail01.ecl.ntt.co.jp (bcmv-tmail01.ecl.ntt.co.jp [124.146.185.148]) by dpdk.org (Postfix) with ESMTP id 81F7E1B125 for ; Wed, 26 Sep 2018 11:10:45 +0200 (CEST) Received: from bcmv-ns01.ecl.ntt.co.jp (bcmv-ns01.ecl.ntt.co.jp [129.60.83.123]) by bcmv-tmail01.ecl.ntt.co.jp (8.14.4/8.14.4) with ESMTP id w8Q9AiAT006963; Wed, 26 Sep 2018 18:10:44 +0900 Received: from bcmv-ns01.ecl.ntt.co.jp (localhost [127.0.0.1]) by bcmv-ns01.ecl.ntt.co.jp (Postfix) with ESMTP id 52963140; Wed, 26 Sep 2018 18:10:44 +0900 (JST) Received: from localhost.localdomain (lobster.nslab.ecl.ntt.co.jp [129.60.13.95]) by bcmv-ns01.ecl.ntt.co.jp (Postfix) with ESMTP id 3D964110; Wed, 26 Sep 2018 18:10:44 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: ferruh.yigit@intel.com, spp@dpdk.org, ogawa.yasufumi@lab.ntt.co.jp Date: Wed, 26 Sep 2018 18:08:33 +0900 Message-Id: <1537952921-20397-6-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537952921-20397-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> References: <1537952921-20397-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-TM-AS-MML: disable Subject: [spp] [PATCH v2 05/13] 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: Wed, 26 Sep 2018 09:10:46 -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