inkscape-cli v1.0.4
inkscape-cli
inkscape-cli is a Node.js binding for Inkscape's command line interface. You need to have Inkscape installed to your computer. Furthermore, inkscape-cli is designed for Windows. Other platforms may not work well.
Github: https://github.com/The3DSquare/inkscape-cli
NPM: https://www.npmjs.com/package/inkscape-cli
Quick start:
Import the library into your code and start coding!
const I = require('inkscape-cli');
const save_as_pdf = I.generate_command([
I.O.file('.\\File.svg'),
I.O.export_area_page,
I.O.export_pdf('.\\File.pdf')
]);
I.run_command(save_as_pdf);
Documentation
setFolder(path)
Tells inkscape-cli that inkscape.exe
is in the folder specified by path
.
param | type | description |
---|---|---|
path | String | Path to Inkscape's folder |
I.inkscape_folder("C:\\Program Files\\Inkscape\\");
- Path must use
\\
instead of/
- It's ok to leave spaces in the path
O
inkscape-cli has an object called O
. O
has all the options one can use when creating a command with generateCommand
. Go to https://inkscape.org/doc/inkscape-man.html for specific details about each command.
Here are some examples:
I.O.file('.\\File.svg');
I.O.export_area_drawing;
I.O.export_png('.\\File Image.png');
File paths need to use \\
instead of /
. Feel free to leave spaces in a filepath as well.
Options with no parameter can be left without ()
. Options that do need parameters can put them in via a function call.
generateCommand(args)
Generates a command inkscape-cli can run.
param | type | description |
---|---|---|
args | Array | An array of I.O. values |
const savePDF = I.generateCommand([
I.O.file('.\\File.svg'),
I.O.export_area_page,
I.O.export_pdf('.\\File.pdf')
]);
const savePNG = I.generateCommand([
I.O.file('.\\File.svg'),
I.O.export_area_drawing,
I.O.export_width(2024),
I.O.export_height(1024),
I.O.export_png('.\\File.png')
]);
runCommand(command)
Runs a command generated by generateCommand
param | type | description |
---|---|---|
command | String | A command created by generateCommand |
I.runCommand(savePDF);
chainCommands(commands)
Runs multiple commands one at a time
param | type | description |
---|---|---|
commands | Array<String> | Array of commands created by generateCommand |
I.chainCommands([savePDF, savePNG]);