Inkscape.org
Beginners' Questions 1.2 beta: multi-page vs. command-line
  1. #1
    ronburk ronburk @ronburk

    Sure would be cool to use the new multi-page support in the upcoming release.

    Alas, I need to be able to programmatically export individual pages as bitmaps via the command-line. Probably no way to do that but thought I would ask if anybody knew different.

    Seems like a variety of doesn't-work-with-multi-page command-line options would be enabled if there were just a command-line option to specify which page one is interested in (and for a really 21st century feature, maybe even the ability to query the number of pages in the file). I *think* the model chosen automatically associated an ascending integer starting at 1 with each "page". Can't see any such option in the --help spew tho.

    For my own personal neck of the woods, it might have been nicer if each page could have an associated filename, allowing one to fluidly switch between editing pages all at once or (watch me run out of memory/CPU!) individually, he said, wishing upon a star.

  2. #2
    Samir Ouchene Samir Ouchene @s.ouchene
    *

    There should be a better solution, but here is a workaround (assuming you're on Linux):

    • Export the multi-page SVG document to a multi-page PDF document:

               inkscape --export-type=pdf document.svg

    • Convert each PDF page to its own SVG file. You can use for example the command pdf2svg:

               pdf2svg document.pdf output-page%03d.svg all

              You should get many files: output-page001.svg, output-page002.svg, etc. 

    • Use Inkscape to convert those SVG files to PNG:

               for f in $(find . -type f -name 'output-page*' -printf "%f\n"); do inkscape --export-type=png $f; done

  3. #3
    Samir Ouchene Samir Ouchene @s.ouchene
    👍

    To find the number of pages, you can use:

    grep -c "<inkscape:page" document.svg

  4. #4
    ronburk ronburk @ronburk

    Thanks -- you make me think!  The reason I desire files as the underlying storage is so the update times are available for use by my build system. I'm not willing to wait for the rebuild of 7 pages when only one has changed (adds minutes per page to a build I often do several times per day). Roundtripping to PDF from SVG also seems unlikely to be idempotent for complex images that are tuned to a particular DPI. But, as you point out, the info is (almost) all there in the XML.

    If I'm crazy enough (and anybody who uses XSLT probably is), I could use an XSLT script to scan (e.g.) multi-page-proj.svg and compare each inkscape:page element to a distinct page-n-proj.svg file. The build system's normal check of dependencies and timestamps then just carries on. If Inkscape doesn't gratuitously change the XML structure on pages I don't edit, seems like it could possibly work.

    Next step would be to see whether Inkscape multi-page can really handle a dozen complex pages without becoming grindingly slow. 12 cores and 64GB is no guarantee of speed :-)

Inkscape Inkscape.org Inkscape Forum Beginners' Questions 1.2 beta: multi-page vs. command-line