Inkscape command line programming - command-line

I'd like to be able to derive new images from a pre-existing image from the command line. To do that, I'd turn on/off specific layers that have portions of the image and then save the resulting image to a file. However, while I can see a number of commands listed in the help to manipulate layers, I don't see any that would allow one to select a specific one and turn it on/off.

If what you want to do can be achieved by deleting a few unwanted elements by their id (say, layer17 and layer4711), you can do it this way:
inkscape image.svg \
--select=layer17 --verb=EditDelete \
--select=layer4711 --verb=EditDelete \
--verb=FileSave --verb=FileClose
Note that this will overwrite image.svg with the result, so if you're scripting this, be sure to work on a copy rather than your originals.

inkscape image.svg --export-id-only --export-id=layer17 --export-png=image.png --export-width=100 --export-height=100
On a Mac you might have to do:
/Applications/Inkscape.app/Contents/Resources/bin/inkscape --without-gui --file=image.svg --export-id-only --export-id=layer17 --export-png=image.png --export-width=100 --export-height=100

I've written an Inkscape extension for work like this. It outputs one file for each option layer found. It will also show various layer combinations as needed. Scriptable as well. I call it the SLiCk Layer Combinator:
https://github.com/juanitogan/slick

Related

Merge 2 pdf files and preserve forms

I'd like to merge at least 2 PDF files into one while preserving all the form elements in the original PDFs. The form elements include text fields, radio buttons, check boxes, drop down menus and others. Please have a look at this sample PDF file with forms:
http://foersom.com/net/HowTo/data/OoPdfFormExample.pdf
Now try to merge it with any other arbitrary PDF file.
Can you do it?
EDIT: As for the implementation, I'd ideally prefer a command line solution on a linux plattform using open source tools such as 'ghostscript', or any other tool that you think is appropriate to solve this task.
Of course, everybody is welcome to supply any working solution to this problem, including a coded solution that involves writing a script which makes some API calls to a pdf-processing library. However, I'd suggest to take the path of least resistance first (CMD Solution).
Best Regards
EDIT #2: Well there are indeed several CMD tools that merge PDFs. However, these tools don't seem to, AFAIK, to preserve the forms in the original PDFs! These tools appear to simply just concatenate the printouts of all those PDFs into a single Printout, which is then presented as a single PDF.
Furthermore, If you printout a PDF file with forms into a file, you lose all the forms in it. This clearly not what I'm looking for.
I have found success using pdftk, which is an open-source software that runs on linux and can be called from your terminal.
To concatenate multiple pdfs into one (and preserve form-fillable elements), you can use the following command:
pdftk input1.pdf input2.pdf cat output output-file.pdf

Change color in svg file through command line (inkscape)

I have an .svg file with only one color. I want to change this color to another and export it through command line. (I have to do it about 100 times, so doing it by hand doesn't work.) I use Inkscape at the moment.
I am able to change the background color and export with this command:
inkscape -f name.svt -e output_name.png -b #000080
But I cannot find the way to change the normal color.
I find this verb:
org.inkscape.color.replacecolor
But I don't know, how to add the color I want to use, somewhere I read, that I cannot add variables to verbes, but in that case how can be this verb used?
Thank you in advance.
This is not a general purpose solution, but since a SVG file is just XML internally, if your SVG file is simple enough you might be able to get away with a simple sed replacement. For example the following replaces #000000 (black) with #ffffff (white):
sed -e "s/#000000/#ffffff/" input.svg >output.svg
This may or may not be good enough for your needs.
Although inkscape is a powerful tool, I think you will have more luck (control) with xlst tranformations. This will allow you to do anything to an xml file rather than parsing the file as an svg image and relying on the available API. You might take a look at a tool like xsltproc for this.

Is it possible to combine Doxygen commands?

\todo \image html clone.png
The intent here is to place an image inside the todo but it appears that when you put one tag after another, the tag is ignored. Is there a way to do this? I've tried it with more than just \image, it appears to be the case with any two tags you use in succession.
There are many ways to get images into your documentation. Maybe try with html and it might not break your \todo command.
\todo <IMG SRC=clone.png>
You can also create an alias in your setup file that makes it easy and clean to include your image.
I too have found that some commands seem to end other commands. Note that not ALL commands will end your "\todo" command. Font commands such as \c like in the example for \arg does not end the command.
http://www.doxygen.nl/manual/commands.html#cmdarg

how to remove characters from a font file?

i've downloaded the DejaVu open source font and want to use it ad a WebFont, but even when converting it, i get a large file, and because the website i'll use will be only in few languages (arabic, french, amazigh) then, i dont need some characters.
so is there a way to browse the font file and delete the unnecessary range of unicode characters that i'll not need?
Using FontForge, you may open Element->Font Info->Unicode Ranges. You will see all available ranges and you can select a whole Unicode range with a single click. Then, you can tune your selection and delete using Encoding->Detach & Remove Glyphs.
Also, you can use Edit->Select->Select by Script.
The easiest method I found is to use pyftsubset tool from FontTools. Here's an example:
$ pyftsubset NotoSans-Regular.ttf \
--unicodes=U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116 \
--output-file=NotoSans-Regular.cyrillic.woff2 \
--flavor=woff2
Note: woff2 output requires Brotli.
I wrote a simple script around it which automates the whole process including generation of a CSS file after splitting the font file. You may find it here: https://github.com/johncf/ttf2web

Gnuplot incremental filename using macro

Hell,
I need to plot points out of my c++ application.
So I simply save my points to a points.txt
and then run system("gnuplot 'plotmakro'");
which contains:
set output 'plot.png' set terminal png
set grid set multiplot
plot pointsa.txt' ', 'pointb.txt'
Is there a solution so that I get plot2.png, plot3.png when running the makro again?
As far as I understand your problem two possible solutions come to my mind:
sed the output of your gnuplot script to another location before running gnuplot with the newly created script or
output the png to some arbitrary file like tmp_plot.png and change the file name after gnuplot is done to your liking.
However, with both suggestions I somehow feel that there is a nicer and cleaner solution to your problem. Maybe you want to think about your interface between your application an gnuplot...