Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com
Cc: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Subject: [spp] [PATCH 05/11] docs: add script for generating PDF images
Date: Fri, 31 Aug 2018 18:14:35 +0900	[thread overview]
Message-ID: <20180831091441.39055-6-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <20180831091441.39055-1-ogawa.yasufumi@lab.ntt.co.jp>

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

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 <ogawa.yasufumi@lab.ntt.co.jp>
---
 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

  parent reply	other threads:[~2018-08-31  9:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-31  9:14 [spp] [PATCH 00/11] PDF documentation support ogawa.yasufumi
2018-08-31  9:14 ` [spp] [PATCH 01/11] docs: move SPP VF images ogawa.yasufumi
2018-08-31  9:14 ` [spp] [PATCH 02/11] docs: resize figures of SPP VF ogawa.yasufumi
2018-08-31  9:14 ` [spp] [PATCH 03/11] docs: resize figures of SPP ogawa.yasufumi
2018-08-31  9:14 ` [spp] [PATCH 04/11] docs: resize figures of SPP container ogawa.yasufumi
2018-08-31  9:14 ` ogawa.yasufumi [this message]
2018-08-31  9:14 ` [spp] [PATCH 06/11] project: update gitignore to exclude PDF files ogawa.yasufumi
2018-08-31  9:14 ` [spp] [PATCH 07/11] docs: add sphinx config to PDF ogawa.yasufumi
2018-08-31  9:14 ` [spp] [PATCH 08/11] makefile: add make option to compile PDF doc ogawa.yasufumi
2018-08-31  9:14 ` [spp] [PATCH 09/11] makefile: fix bug of PDF compilation ogawa.yasufumi
2018-08-31  9:14 ` [spp] [PATCH 10/11] docs: refactor for character length ogawa.yasufumi
2018-08-31  9:14 ` [spp] [PATCH 11/11] docs: fix typo of label ogawa.yasufumi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180831091441.39055-6-ogawa.yasufumi@lab.ntt.co.jp \
    --to=ogawa.yasufumi@lab.ntt.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).