Beginner's question regarding default_mm template/absolute svg sizes
Hi,
sorry if this is FAQ, but I have searched Google and the archive and did not find a suitable answer.
I have a small problem. I need to prepare some SVG files for the use with Apache's FOP. Inkscape seems to be the perfect tool for this, so I installed the latest version 0.45. However, I discovered that FOP measures a pixel as a 1/72 inch, while Inkscape measures a pixel as a 1/90 inch. Then I found out that there are default templates of various sizes, and one of them is "default_mm", which actually announces the image size in the <svg> element in absolute units. Unfortunately, whenever I resize the document size, Inkscape falls back into pixel mode when saving the file. What am I doing wrong? Is it an intended behaviour or is it a bug? I found a workaround, namely scaling the image by 72/90, however, I would prefer a clean solution.
Thanks in advance for any answer.
Klaus
Klaus Malorny wrote:
Hi,
sorry if this is FAQ, but I have searched Google and the archive and did not find a suitable answer.
I have a small problem. I need to prepare some SVG files for the use with Apache's FOP. Inkscape seems to be the perfect tool for this, so I installed the latest version 0.45. However, I discovered that FOP measures a pixel as a 1/72 inch, while Inkscape measures a pixel as a 1/90 inch. Then I found out that there are default templates of various sizes, and one of them is "default_mm", which actually announces the image size in the <svg> element in absolute units. Unfortunately, whenever I resize the document size, Inkscape falls back into pixel mode when saving the file. What am I doing wrong? Is it an intended behaviour or is it a bug? I found a workaround, namely scaling the image by 72/90, however, I would prefer a clean solution.
Thanks in advance for any answer.
Klaus
Hi all,
no ideas to my problem anyone?
regards,
Klaus
Donn wrote:
no ideas to my problem anyone?
Doesn't look like anyone here, including me, knows what a FOP is. If we knew, we'd surely help you. Sounds like you need to google, or write a better description of your problem.
hth /d
Hi Donn,
Apache FOP happens to be an XSL:FO processor which allows the inclusion of SVG graphics. But actually the problem is rather unrelated to FOP itself.
My problem relates to two attributes "width" and "height" in the <svg> root element. With CORELDraw! generated SVG files, I get sizes with units, e.g.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1 .1/DTD/svg11.dtd"> <!-- Creator: CorelDRAW --> <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve"
width="19.4564mm" <<<==== with units "mm" height="15.0114mm" <<<==== with units "mm"
style="..." viewBox="0 0 18.9613 14.6294" xmlns:xlink="http://www.w3.org/1999/xlink%22%3E ... </svg>
while with Inkscape, I get:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://web.resource.org/cc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="627.14209" <<==== no units = pixels width="361.4173" <<==== no units = pixels
id="svg2" sodipodi:version="0.32" inkscape:version="0.45" sodipodi:docname="Structures.svg" inkscape:output_extension="org.inkscape.output.svg.inkscape" sodipodi:docbase="K:\t\telnic\nsp\knipp-docs\nsp-ps\design" sodipodi:modified="true" version="1.0"> ... </svg>
What I want to achieve is the first variant, as the actual size of a pixel is unspecified by the SVG standard. Inkscape seems to have a fixed definition of 90dpi, while FOP seems to have a fixed definition of 72dpi.
The fact is that even if I start with a "default_mm" template, which indeed generates the first variant, Inkscape falls back into the second variant if I apply any changes in the "Document properties" dialog, still using "mm" units. To me, this looks like a bug, but since I am new to Inkscape, it may simply be my fault also.
Regards,
Klaus
Klaus, When I said we would help you, I meant the boffins on the list -- I'm an idjit :)
You seem to be saying that if you start with a template .svg file that contains (say) "19mm" and "15mm" , when you open the document properties dialog and change *something* (not specified), the dimension of the page, in the svg, change to numbers without units.
If so, (and I could have the wrong end of the stick) and you are using 0.45, I would have to say my experience is not the same. I did this: 1. Opened Ink. Made a 19mm by 15mm document. Drew a square just bcoz. 2. Saved this to mmtest.svg 3. Opened that in an editor. Changed the width and height strings to literally "19mm" and "15mm", form the non-unit numbers that were there. 4. Opened mmtest.svg in ink. Messed with the document - changed backdrop alpha and changed it's default units to mm (which displayed as px). 5. Saved mmtest.svg 6. Opened it in an editor again -- the two sizes were still as in step 3.
(Just in case)TH, /d
Donn wrote:
Klaus, When I said we would help you, I meant the boffins on the list -- I'm an idjit :)
You seem to be saying that if you start with a template .svg file that contains (say) "19mm" and "15mm" , when you open the document properties dialog and change *something* (not specified), the dimension of the page, in the svg, change to numbers without units.
I think he is talking about the width and height of the entire document, which is pretty much the only way to properly use real-world units in SVG (as far as I'm concerned at least). Inkscape doesn't really support this though (at least not yet), so for the moment you'll have to work around it.
Inkscape does understand documents which use this feature though and it only seems to remove the necessary attributes when you change the document size, so just create a document of the right size manually. For example, to create a document which is 10cm wide and 5cm tall:
<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100mm" height="50mm" viewBox="0 0 100 50" xmlns="http://www.w3.org/2000/svg" version="1.1"> </svg>
Jasper van de Gronde wrote:
Donn wrote:
Klaus, When I said we would help you, I meant the boffins on the list -- I'm an idjit :)
You seem to be saying that if you start with a template .svg file that contains (say) "19mm" and "15mm" , when you open the document properties dialog and change *something* (not specified), the dimension of the page, in the svg, change to numbers without units.
I think he is talking about the width and height of the entire document, which is pretty much the only way to properly use real-world units in SVG (as far as I'm concerned at least). Inkscape doesn't really support this though (at least not yet), so for the moment you'll have to work around it.
Inkscape does understand documents which use this feature though and it only seems to remove the necessary attributes when you change the document size, so just create a document of the right size manually. For example, to create a document which is 10cm wide and 5cm tall:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100mm" height="50mm" viewBox="0 0 100 50" xmlns="http://www.w3.org/2000/svg" version="1.1">
</svg>
Yes, that's exactly the problem. Thanks for clarification!!
Klaus
Klaus Malorny wrote:
I have a small problem. I need to prepare some SVG files for the use with Apache's FOP. Inkscape seems to be the perfect tool for this, so I installed the latest version 0.45. However, I discovered that FOP measures a pixel as a 1/72 inch, while Inkscape measures a pixel as a 1/90 inch. Then I found out that there are default templates of various sizes, and one of them is "default_mm", which actually announces the image size in the <svg> element in absolute units. Unfortunately, whenever I resize the document size, Inkscape falls back into pixel mode when saving the file. What am I doing wrong? Is it an intended behaviour or is it a bug? I found a workaround, namely scaling the image by 72/90, however, I would prefer a clean solution.
Absolute sizes in svg is a huge can of worms. HUGE! First problem is that svg paths can only be specified in a mythical "user unit" aka "px". Secondly the SVG spec calls for the svg application to determine the pixel per inch ratio from the ppi of the display device. Deep down in the depths of the code Inkscape makes a hard assumption that the ratio is 90 pixels per inch. I believe this behavior is actually exemplified in the spec. Most postscript descendant apps make the 1pt == 1pixel asumption or 72pixels per inch. So there is the rub. Just imagine what might happen if you mix absolute units and "user units" in one document and the user agent determines ppi from the display device.
So I believe the current short answer is that you will need to scale your SVG to 80%. I'd guess this should be easy to script by wrapping the whole drawing in a <g transform="scale(.8,.8)" /> or something similar.
Aaron Spike
Klaus Malorny wrote:
I have a small problem. I need to prepare some SVG files for the use with Apache's FOP. Inkscape seems to be the perfect tool for this, so I installed the latest version 0.45. However, I discovered that FOP measures a pixel as a 1/72 inch, while Inkscape measures a pixel as a 1/90 inch. Then I found out that there are default templates of various sizes, and one of them is "default_mm", which actually announces the image size in the <svg> element in absolute units. Unfortunately, whenever I resize the document size, Inkscape falls back into pixel mode when saving the file. What am I doing wrong? Is it an intended behaviour or is it a bug? I found a workaround, namely scaling the image by 72/90, however, I would prefer a clean solution.
I should also mention that I think Andy Fitzsimon is our resident FOP+SVG expert. Perhaps we can attract his attention to your question.
Aaron Spike
participants (4)
-
Aaron Spike
-
Donn
-
Jasper van de Gronde
-
Klaus Malorny