I'd like to export a specific area of my SVG to a PDF and I'd like to automate it from the command line.
My issue is that Inkscape can only export the whole page or drawing, or a single object (and only this object).
Things I tried but don't work:
- ignores
Code: Select all
--export-pdf=filename.pdf
completely and always exports the whole page or drawing.Code: Select all
--export-area=x1:y1:x2:y2
- Using works, but it only exports the specified object, i.e. Inkscape acts like
Code: Select all
--export-id=objectid
is set. This is the same behaviour I see when I use the GUI to export a PDF and restrict export to an object ID.Code: Select all
--export-id-only
Both of these (--export-area and --export-id) work as intended when exporting a PNG.
The only method that does work is actively changing the page area:
Code: Select all
cp $svg_file $tmp_svg_file
inkscape --select=$object_id --verb=FitCanvasToSelection --verb=FileSave --verb=FileClose --verb=FileQuit $tmp_svg_file
inkscape --export-pdf="$exported_file" "$tmp_svg_file"
rm $tmp_svg_file
Unfortunately, this is slow as the whole Inkscape GUI has to be started first. The actual PDF export (the second call to Inkscape above) only takes half a second while simply changing the page area takes about 7 seconds and quickly flashes a window.
I also tried a current nightly build (0.91 r13322) without success
