On 03/23/2011 01:03 PM, Terry Brown wrote:
On Wed, 23 Mar 2011 09:47:48 -0700 (PDT) unkown UN <crashoverride025@...12...> wrote:
Has anyone been successful with creating templates with inkscape in which you can automate the generation of PDFs?
For example:
I have:
- Datasource [XML] that contains a list of data items
- The Visual Representation (as an inkscape file)
- A script that would combine the two and produce a pdf based on the datasource specifications
I know I asked a similar question to this before, but I was wondering if anyone had success at automating this task.
I've done it quite a bit. Depends what elements of the svg you're trying to manipulate.
Text is easy, I've done that with simple sed driven text replacement of [SITE_NAME] place holders.
Images you can do without editing the SVG by changing the content of the linked file (or symbolic link).
But for more complex things I've used Python's lxml library and Inkscape's XML editing to set the id attributes of the parts of the template I want to adjust, so I can find them easily with xpath in python.
Most recently as well as text and image substitutions I adjusted the length of a scale bar rectangle in the svg.
I just use os.system() to run inkscape to do the export.
But if you're looking for a pre-built tool which parses a list of inputs and feeds them through the template, I'm not aware of anything like that.
I wrote a little python script to help me make animations with inkscape. It does search-and-replace changes to a source SVG file, based on info you provide it in a little "config file". For example, you can manually edit the SVG to make the fill color of an object change between #FF0000 and #00FF00 over a number of frames. It doesn't do any XML parsing or tree traversal, and you need to manually add search-and-replace identifiers into your source SVG, but it works pretty well for my purposes. Hope it helps.
http://www.mbeckler.org/inkscape/svgani/
Thanks, Matthew Beckler