Inkscape.org
Creating New Extensions Using Inkscape command line to convert multi-page PDF to SVG
  1. #1
    mscheortter mscheortter @mscheortter

    I am trying to use the Inkscape command line to convert a multi-page PDF document to multiple SVG files but the only output I get is the first page, all other pages return a blank page:

    This works fine:

    "C:\Program Files\Inkscape\bin\inkscape.exe" d:\test\multipage.pdf --export-type=svg --export-filename=d:\test\page_2.svg --export-page=1 --export-plain-svg

    Whereas when I specific --export-page=2, Inkscape outputs a simple svg that doesn't have the document's content.  Manually outputting the pages to SVG in Inkscape works fine. 

    "C:\Program Files\Inkscape\bin\inkscape.exe" d:\test\multipage.pdf --export-type=svg --export-filename=d:\test\page_2.svg --export-page=2 --export-plain-svg
     

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!-- Created with Inkscape (http://www.inkscape.org/) -->

    <svg
       version="1.1"
       id="svg1"
       width="816"
       height="1056"
       viewBox="0 0 816 1056"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:svg="http://www.w3.org/2000/svg">
      <defs
         id="defs1" />
      <g
         id="g1">
        <g
           id="g3" />
        <g
           id="g4" />
      </g>
    </svg>


    Any suggestions?

    Thanks,
    Michael

  2. #2
    inklinea inklinea @inklinea⛰️

    I'm using Ubuntu, this works for me:

    inkscape --pages=1-9999 --export-type=svg --export-filename=1.svg ./document.pdf

    However I found that some pdfs crash Inkscape. 

    For those pdfs:

    I  had to use this Linux tool to preprocess before running the command line.

    mutool clean -s ./document.pdf ./fixed.pdf

Inkscape Inkscape.org Inkscape Forum Creating New Extensions Using Inkscape command line to convert multi-page PDF to SVG