Given the following test.svg file
<?xml version="1.0" encoding="utf-8" ?>
<svg baseProfile="tiny"
height="5cm" version="1.2"
viewBox="-1 -1 2 2"
width="5cm" xmlns="http://www.w3.org/2000/svg"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs />
<rect fill="blue" height="1" width="1" x="0" y="0" />
</svg>
using the command
inkscape -D -z --file=test.svg --export-pdf=text.pdf --export-latex
I get a pdf of 25mm x 25mm. The proportions are correct (I use only half the width and half the height), my question is how do avoid an automatic crop of the picture. I need a PDF of 50mm x 50mm, with only the left upper square filled.
In the inkscape documentation for the option -D (that I use) there is the comment without margins or cropping that is exactly what I need. The result is as described above, cropped.
man inkscape shows the following explanation for -D:
In SVG, PNG, PDF, PS, and EPS export, exported area is the drawing (not page), i.e. the bounding box of all objects of the document...
That is what you describe as cropping. For -C it says:
In SVG, PNG, PDF, PS, and EPS export, exported area is the page. This is the default for SVG, PNG, PDF, and PS, so you don't need to specify this...
So, simply leave off the -D option.
Related
This question may have been answered in multiple websites. However, I am having issues getting it to work correctly.
My goal is to convert an SVG file to BMP using command line. Below is the content of a simple SVG file. Note the resolution must be 912x1140px. Thus the resulting BMP file must be 912x1140px as defined in the SVG.
<?xml version="1.0" encoding="utf-8" ?>
<svg baseProfile="full" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink" width="912px" height="1140px" preserveAspectRatio="none" viewBox="0,0,9.855,6.1614"><defs />
<rect fill="#FFF" height="100%" width="100%" x="0" y="0" />
<rect x="4" y="2.5" width="1.0" height="1.0" fill="#000" />
</svg>
When I use GIMP using GUI, the resulting BMP file is correct as expected having a size of 912x1140px. The size of the file is ~3.96MB. However I must use the GUI to open my SVG file and manually convert it to BMP. I prefer to use command line because I have a batch of SVG files I want to convert.
When I use ImageMagick to convert, the resulting BMP file gets resized to 855x1069px instead of staying at 912x1140px. The resulting BMP file ~3.48MB: convert myfile.svg myfile.bmp
When I use rsvg-convert, the resulting BMP file is correct 912x1140 but its around 7KB. I am unsure if rsvg-convert even supports BMP format because according to the docs, BMP is not listed as the support format. Thus this leads me to question if the convert BMP file is even correct. rsvg-convert -o myfile.bmp myfile.svg
When I use command line Inkscape, the resulting BMP file is correct resolution of 912x1140, but size is around 6.51KB. I am unsure if this is correct since the BMP file generated using GIMP results in a file size of 3.96MB. Secondly, Inkscape GUI doens't have any options to export to BMP. In addition, it defaults to 32 bits. I want it to be 24 bit depth. inkscape -z myfile.svg -e myfile.bmp
I keep exporting a PSD element with a clear background as an SVG and I continue to get
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="0.972in" height="0.861in">
<image x="0px" y="0px" width="70px" height="62px" xlink:href="data:img/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAAA+CAMAAAChgZ0aAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACfFBMVEUnKzT///8nKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQnKzQ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mCC" />
</svg>
I would like to export this as a <path> element instead of <image>
this is the PNG of what that SVG is:
I have converted already tried to image trace this on illustrator but the path gets sloppy.
Thanks,
Zlerp
Sorry but Photoshop just doesn't do SVGs like that. SVG is a vector format and the only things in photoshop that are vectors are paths and selections and neither of those have things like line thickness and color so they'd be invisible as an image.
That's what Illustrator is for. Or for a free option, there's InkScape.
When I use
rsvg-convert.exe -f pdf -o <output-name>.pdf <input-name>.svg
I get a result that differs from how the SVG is rendered in Inkscape and Firefox.
This is a simple test SVG:
<svg width="150" height="100" xmlns="http://www.w3.org/2000/svg">
<text y="50" font-size="12" fill="black">Test</text>
<text x="50" y="50" font-size="12pt" fill="black">Test</text>
<text x="100" y="50" font-size="16px" fill="black">Test</text>
</svg>
In Inkscape and Firefox the middel and right text have the exact same size since these applications seem to assume that 1pt = 1.333333px which is the CSS recommendation. However, rsvg seems to assume 1pt = 1.25px which leads to different sizes of the texts. How can I get rsvg to output it correctly (as Inkscape and Firefox).
I tried the options -p and -d with 96 but that didn't give the correct result either.
Setting the dpi works here with rsvg-convert 2.40.20:
rsvg-convert -f pdf --dpi-x=96 --dpi-y=96 -o <output-name>.pdf <input-name>.svg
I also confirmed setting the output format to svg (text will be converted to paths) and comparing the height in Inkscape.
Many applications correctly handle SVG where the width and height are inches, such as
<svg width="1.5in" height="1in" xmlns="http://www.w3.org/2000/svg">
</svg>
I'm not familiar with rsvg-convert.exe, but it's the first thing I'd try. Adjust the width and height as needed.
In SVG is it possible to slant text to specified angle? This is of course different from rotate or putting on a path etc. One of things I want to do is to have a parallelogram with embedded text, with text tilted to the angle of the parallelogram.
Thank you.
Yes. You need to use the transform attribute.
<?xml version="1.0" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="500" height="100">
<text font-size="50" transform="translate(20,50) skewX(20)">Skewed text</text>
</svg>
Note that the transform applies to the text position (x and y attributes) as well. That's why I have used a translate to set the text position instead.
I've got an SVG element that I've created with Inkscape. I then take that SVG and put in as part of an XSL-FO stylesheet that is used to transform XML data and then passed through the IBEX renderer to create a pdf (which is usually then printed). As an example, I have elements in the svg/stylesheet that look like this (extra noise due to the Inkscape export):
<text x="114" x="278.36218" id="id1" xml:space="preserve" style="big-long-style-string-from-inkscape">
<tspan x="114" y="278.36218" id="id2" style="style-string">
<xsl:value-of select="Alias1"/>
</tspan>
</text>
My problem lies in the fact that I don't know how big this text area is going to be. For this particular one, I've got an image to the right of the text in the SVG. However, if this string is the maximum allowed number of W's, it's way too long and goes over the image. What I'd like (in a perfect world) is a way to tell it how many pixels wide I want the text block to be and then have it automatically make the text smaller until it fits in that area. If I can't do that, truncating the text would also work. As a last ditch resort, I'm going to use a fixed width font and do the string truncation myself in the XML generation, although that creates something both less usable and less pretty.
I've poked around the SVG documentation and looked into flowRegions a bit as well as paths, but neither seem to be be quite what I want (maybe they are though). If it helps, here's that style string that Inkscape generates:
"font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
Thanks in advance for the help.
You have text of arbitrary line length (in terms of characters) and you want to scale it to fit inside a fixed amount of space? The only way I can think of to rescale text to a fixed size is to place it inside an svg element and then scale the SVG to that size:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Resizing Text</title>
<defs>
<svg id="text-1" viewBox="0 0 350 20">
<text id="text-2" x="0" y="0" fill="#000" alignment-baseline="before-edge">It's the end of the world as we know it, and I feel fine!</text>
</svg>
</defs>
<rect x="500" y="100" width="200" height="40" fill="#eee" />
<use x="510" y="110" width="180" height="20" xlink:href="#text-1" />
</svg>
However, as seen above, the viewBox on the encapsulating svg element needs to be set to the width of the text, which you presumably don't know.
If you're referencing this SVG inside a user agent with scripting available (e.g. a web browser) then you could easily write a script to capture the width of the text or tspan element and set the viewBox accordingly.