Most often, the command-line interface is used for exporting SVG documents into other formats. There are command-line parameters for exporting to PNG (18.9 Bitmap Export), PS, EPS, and PDF (1.5.1.1 Adobe’s Vector Formats). For example, exporting to PDF is as simple as:
$ inkscape --export-pdf=file.pdf file.svg
This will create file.pdf; no GUI is loaded, and after completing the export, Inkscape quits. Similarly, you can use --export-ps
, --export-eps
, and --export-png
.
Also, there is --export-plain-svg
for converting a document into plain SVG (1.4 A Brief History of SVG). It can be used not only for stripping an Inkscape SVG document of Inkscape-specific metadata, but also for converting any of the supported import formats into SVG (Appendix B). For example, this will convert a CorelDRAW file into SVG format:
$ inkscape --export-plain-svg=file.svg file.cdr
By default, the document’s page (2.3 Interface Overview) is exported, so objects falling outside the page are invisible in export. You can add --export-area-drawing
to make the export cover all visible objects of the document, regardless of its page size. The only exception is EPS, where the default is exporting drawing; for this format, you can limit export to page with --export-area-page
(however, due to the limitations of EPS, this area will be contracted inwards to the edge of objects in the page if they do not reach to the edges of the page). For example:
$ inkscape --export-png=file.png --export-area-drawing file.svg
You can also export single objects out of a document, so that the exported file covers only that object’s bounding box. The object you need is specified by its id
attribute (A.9 Linking):
$ inkscape --export-eps=file.eps --export-id=text2054 file.svg
If other objects overlap with the exported object’s bounding box and are visible, they will also show in the exported PNG file. To suppress them and make a rendering of only the chosen object and nothing else, add --export-id-only
. For PDF, PS, and EPS, this is the only possible mode—other objects are always hidden if you specify --export-id
.
For PNG export, you can also specify the export area explicitly by specifying the two corner points. For example:
$ inkscape --export-png=file.png --export-area=0:0:200:100 file.svg
will export the area that spans from the point (0, 0) to the point (200, 100).
Also for PNG export, no matter which method was used for specifying the area, you can “snap” this area to pixel grid, that is, round it to the nearest whole coordinates in px
. This is very useful when you export at the default 90 dpi and want your objects drawn to the pixel grid (7.2 Grids) to be crisp in the exported bitmap no matter what area you are exporting.
For PNG export, you can specify the size of the exported bitmap or its resolution (by default, 90 dpi). For example:
$ inkscape --export-png=file.png --export-dpi=600 file.svg $ inkscape --export-png=file.png --export-width=1000 file.svg $ inkscape --export-png=file.png --export-height=400 file.svg
The first line will export at the resolution of 600 dpi, so that a document 1.1 What Vector Graphics Is and Why It Matters inches wide will export to a bitmap 1800 pixels wide. The other two examples explicitly set the pixel size of the export, and the resolution is calculated to match this requirement.
Areas that have no objects in them come out as transparent in all export formats. However, in PNG export (but not PDF, PS, or EPS), you can specify any background color or opacity for your document during export. For example, if you want a solid opaque black background, use:
$ inkscape --export-png=file.png --export-background=#000000 \ --export-background-opacity=1.0 file.svg
Every time you export a single selected object to PNG via the GUI (18.9 Bitmap Export), the export filename and resolution are recorded into an export hint added to the document. If, after that, you save the document with these hints, they can later be used for command-line export to PNG as well. For example, if you write:
$ inkscape --export-id=text2035 --export-use-hints file.svg
only the object with the ID text2035
will be exported to the same file and with the same resolution it was most recently exported from the GUI. Note that the --export-png
specifying the filename is not present because the name is derived from the export hint.
For PDF, PS, and EPS, there are more export options that correspond to some of the choices in these formats’ export dialogs in the GUI. Thus:
$ inkscape --export-pdf=file.pdf --export-text-to-path file.svg
converts all text objects to paths on export, so that the resulting vector file needs and embeds no fonts, whereas:
$ inkscape --export-pdf=file.pdf --export-ignore-filters file.svg
will ignore any filters, exporting the filtered objects as if they are not filtered, instead of rasterizing them (which is the default).