SVG with flowroots conversion in Ruby - ruby

I'm trying to convert a SVG to PNG which has a flowroot element in it. Inkscape does it fine, when I convert using Cairo or imagemagick the flowroot elements appear as an opaque box rather than rendering the text within it.
I'm thinking this is because flowroots are a part of SVG 1.2. Does anyone know of any other gems/libraries that might help?

Why not just export it to PNG from inkscape then?
You'll find that flowRoot isn't supported anywhere except inkscape. It's defined in an old working draft of SVG 1.2 Full, and if you look at the last published SVG 1.2 Full working draft you'll find this:
Notable changes to the feature set that readers can expect to see in
the next draft include:
Replacement of the previous flowing text proposal with a superset of the SVG 1.2 Tiny textArea feature.
That said, the SVG WG is working on SVG2 instead, so you should probably look there if you want to know where things are headed.

Have you tried to install libRSVG?
This post says:
textPath is not implemented in the built-in SVG converter of IM. However if available IM will use the libRSVG library to do SVG conversion, and this does get it right.

Related

GeoJSON not visible in output rendered by code using D3.js v3

I'd like to visualize a geojson file in the EPSG:4326 coordinate reference system using D3.js version 3. I'm aware it's better to use the newest version, but alas I'm restricted because of old software that doesn't support higher versions.
I wrote this code: https://bl.ocks.org/FrieseWoudloper/141945ce346639013ac1ced8e4c071b7
In the resulting output there is an SVG element with paths, but I don't see it. I think I have the translate and scale arguments wrong, but I don't know how to determine the right values. Could you please give me any directions on how to fix this?

Difference between append("svg:g") and append("g")

I work on a d3js project and I saw some tutorial with append("g") and other with append("svg:g") without getting the difference between both.
In the very early days of D3 you were required to use the svg:g syntax because of the way SVG elements are appended to the DOM. Later versions of D3 don't require these "hints" to insert SVG elements, so the proper way to do this now would be with a simple g.
The technical details behind this are rather dull, SVG requires a namespace, so when you insert or manipulate SVG elements you use document.createElementNS('a', "http://www.w3.org/2000/svg) white plain HTML uses document.createElement('a'). Since D3 can manipulate both SVG and HTML d3.append('svg:a') was a way of saying this is an SVG anchor.
I got an answer on d3js API, its a namespace question. In svg:g, svg is the namespace (optional).
My fault, sorry i must better read API

livecode how to use svg images on cards

I'm new to livecode and I need to use some svg images in my project
I haven't find info on manual and apparently the image area object can't render an svg image
Can you help me?
Thanks
I don't believe LiveCode supports SVG natively. You might be able to use the browser object to display SVG graphics (which relies on the default browser of the system). If this doesn't work, you'll need convert your SVG to a standard image format (PNG, JPEG, GIF).
There is no native support yet for SVG in LiveCode. But there is at least one free SVG import library available. See http://revonline2.runrev.com/stack/112/SVGL.
In the mid-term (in the next 6 months or so), RunRev is planning to add some native SVG support to LiveCode, as a stretch goal that was met in the recent Kickstarter campaign. See http://www.kickstarter.com/projects/1755283828/open-source-edition-of-livecode/posts?page=2.

How can you embed multiple SVG images in a print layout using a scripted procedure?

I currently have a script that produces a large amount of 3.5-inch-square SVG images. What I need is to be able to put these SVGs in a layout which can be easily and accurately printed.
I have tried using an HTML template, but HTML/CSS does not have sufficiently robust printing support.
What document layout language is most appropriate for handling SVG images, and how could this be implemented in a scripting language?
I use Ruby to generate my SVGs, and although preferable, it is not required that Ruby also be the language used to generate the print layout.
I'd suggest compiling all SVGs to a larger SVG, placing everything where you want it, and convert that to PDF using one of multiple options:
Using Inkscape on the command line, like
inkscape -f in.svg -A out.pdf
Using Batik
java -jar batik-rasterizer.jar -m application/pdf -d out.pdf in.svg
Using librsvg, like
rsvg-convert -f pdf -o out.pdf in.svg
(Probably the most lightweight option)
You might also be able to use the rsvg2 Ruby gem with a Cairo PDF surface. Documentation seems scarce or scattered, though.
If you have a budget, Prince is what you want. Since you've already tried to use CSS+HTML to get it working, you may have a working solution almost ready. Just generate the HTML, SVG, and CSS (use the CSS3 paged media extensions for best control), then pass it off to Prince to generate the PDF. I've used this for several projects, and it works great.
There are free options that work like Prince, notably wkhtmltopdf, but they might not respect your paging options as much as Prince.
Otherwise, you might be able to hack something together using Cairo, by creating a page-sized SVG image and laying it out, adding links to the multiple external SVG files.
Either of these options will end up generating a PDF, which is the only way to ensure that it will print the same no matter which browser or OS is being used.

Importing SVG into an RMagick RVG session

We have some code that draws things using RVG in RMagick. We scale them at various sizes. What I'm trying to do is use a file that's saved as an SVG as a template.
The problem is, is when I load an SVG using Magick::Image.read, and then 'use' it, it rasterizes it, and then scales it, instead of producing pretty vectors.
Is there a way one might go about doing this properly?
Thanks!
Thoughts:
Imagemagick is fundamentally raster oriented. If you want to keep your image in vector format, don't use Imagemagick, as the author will tell you. That said, even though imagemagick may by default convert your image to raster, you can convert it back from raster into vector format (sometimes).
SVuGy may help. It doesn't appear to have a lot of support, but may work. I haven't used it.
The rmagick developer claims to have a SVG to RVG parser, you might try contacting him at rmagick AT rubyforge DOT org.
If all else fails, punt. You could write an xslt to convert your svg to rvg. The two formats are close enough that this might not be too painful. Else a tool like genshi might be a faster conversion path for you if you know more python than xlst.

Resources