1.0.4 • Published 6 years ago

inkscape-cli v1.0.4

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

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.

paramtypedescription
pathStringPath 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.

paramtypedescription
argsArrayAn 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

paramtypedescription
commandStringA command created by generateCommand
I.runCommand(savePDF);

chainCommands(commands)

Runs multiple commands one at a time

paramtypedescription
commandsArray<String>Array of commands created by generateCommand
I.chainCommands([savePDF, savePNG]);
1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago