-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I'm doing some research for an application that i might write. It would use cairo to draw some complex graphics (using math!), and users would want to export these graphics + some text and numbers (derived from the same math) into something printable (pdf is the obvious choice, but svg should be OK too - it's highly desirable that graphic object should be in a vector format, not raster, otherwise it doesn't print well). You know, like generating a report - that sort of thing.
Now, the graphic object should probably go as-is (no one really needs to alter it in any way; scale it maybe - that's all), but the layout of the page is something users should be able to change. Which means that there should be some kind of mechanism for creating page templates, and my application would just paste graphics and numbers into them.
Thus PDF is out of the question. That leaves SVG.
When i started writing this message, i thought that i was going to ask about clipboard formats Inkscape understands. I thought that it would be enough to just swap the cairo-gdk surface used in my drawing function for a cairo-svg surface, write svg into memory, put it into clipboard and somehow paste into Inkscape.
Now, don't get me wrong, that would _still_ be awesome. So if you know how to do it - i'm all ears.
But that, of course, won't do anything about the rest of the contents that should go into page.
So now i'm thinking of something different: create a template SVG document in Inkscape (putting placeholders in places where stuff should be inserted), give it to my application, and it will replace placehonders with real stuff (i hope i know XML well enough to just insert proper XML elements into right places) and save the result as an SVG.
However, Inkscape does not seem to be terribly good at layout out text either, and copy-pasting drawings from Inkscape to OpenOffice produced mixed results (and i still don't know how to do it programmatically). So...what would you advise me to do?
- -- O< ascii ribbon - stop html email! - www.asciiribbon.org
2013/10/14 LRN <lrn1986@...400...>:
When i started writing this message, i thought that i was going to ask about clipboard formats Inkscape understands. I thought that it would be enough to just swap the cairo-gdk surface used in my drawing function for a cairo-svg surface, write svg into memory, put it into clipboard and somehow paste into Inkscape.
This is fairly simple. You just need to use the GTK clipboard API. https://developer.gnome.org/gtk3/stable/gtk3-Clipboards.html
Specifically, you need to use gtk_clipboard_set_with_data() and then optionally gtk_clipboard_set_can_store().
So now i'm thinking of something different: create a template SVG document in Inkscape (putting placeholders in places where stuff should be inserted), give it to my application, and it will replace placehonders with real stuff (i hope i know XML well enough to just insert proper XML elements into right places) and save the result as an SVG.
For this you need a standalone SVG renderer with Cairo support to render the SVG page template, for example librsvg. After you render the template using rsvg_handle_render_cairo(), reuse the Cairo context to add your own content. https://developer.gnome.org/rsvg/2.40/
However, Inkscape does not seem to be terribly good at layout out text either, and copy-pasting drawings from Inkscape to OpenOffice produced mixed results (and i still don't know how to do it programmatically). So...what would you advise me to do?
If there are problems with copy and paste between Inkscape and OO.o / LibreOffice, please report them as bugs or discuss on this mailing list.
I'm not sure whether there's a way to paste into OO.o / LibreOffice from a program, but you might find something useful in the examples section here. In particular, the "GraphicsInserter" example might be relevant. http://api.libreoffice.org/
Regards, Krzysztof
participants (2)
-
Krzysztof Kosiński
-
LRN