Consider the following multi-page SVG document. See this screenshot.
I want to export the three pages in that document using the command line. Upon completion of the command, I should have three files Page 1.png, Page 2.png and Page 3.png just like performing a "Batch Export" of all pages from the Inkscape interface. (for those that are not familiar with this feature: see this screenshot)
I know that I can export the first page by executing $ inkscape --actions="export-filename:/tmp/foo/Page 1.png; export-dpi: 10; export-do" /tmp/foo/a.svg . However, I don't know how to export the second and the third page.
Why I need to export a multi-page SVG document from the command line? In my use case, I have multiple SVG document and each of them have multiple pages. I export the SVG files to PNG files with the desired DPI. Sometimes I want to change the DPI of all PNG files. Therefore, I need to export all the SVG files again, so instead of opening each SVG file with Inkscape and performing the "Batch export" interactively, it would be very convenient for me if I could do it from the command line.
I found this issue in the Gitlab's official repository in which a user reports that --export-area-page only exports the viewBox in a multi-page SVG document. The user suggests adding an option for exporting selected pages.
Consider the following multi-page SVG document. See this screenshot.
I want to export the three pages in that document using the command line. Upon completion of the command, I should have three files
Page 1.png
,Page 2.png
andPage 3.png
just like performing a "Batch Export" of all pages from the Inkscape interface. (for those that are not familiar with this feature: see this screenshot)I know that I can export the first page by executing
$ inkscape --actions="export-filename:/tmp/foo/Page 1.png; export-dpi: 10; export-do" /tmp/foo/a.svg
. However, I don't know how to export the second and the third page.Why I need to export a multi-page SVG document from the command line? In my use case, I have multiple SVG document and each of them have multiple pages. I export the SVG files to PNG files with the desired DPI. Sometimes I want to change the DPI of all PNG files. Therefore, I need to export all the SVG files again, so instead of opening each SVG file with Inkscape and performing the "Batch export" interactively, it would be very convenient for me if I could do it from the command line.
I found this issue in the Gitlab's official repository in which a user reports that
--export-area-page
only exports the viewBox in a multi-page SVG document. The user suggests adding an option for exporting selected pages.Template attached for simple workaround example:
It uses a layer with rectangles which have fill and stroke set to none. The rectangles are snapped to the page corners.
Each rectangle has an id that corresponds to the page it sits on.
inkscape --actions="export-dpi:300;export-id:Page_rect_3;export-filename:test_page_3.png;export-do;export-id:Page_rect_7;export-filename:test_page_7.png;export-do;export-id:Page_rect_9;export-filename:test_page_9.png;export-do" ./10_pages.svg