Dimensions problem when exporting as SVG

SharkD shared this question 4 years ago
Answered

GeoGebra Classic 5.0.481.0-d (19 July 2018)

The attached worksheet is supposed to be 300 pixels per unit. There is a button to the side of the worksheet containing the code I used to set this value.

This works properly when exporting as PNG using the "Size in pixels" export option. Since the export region is 2.3x2.3 units, the PNG image should be 690x690px. And it is. No problem.

However, when exporting as SVG, the result when viewed in Inkscape or uploading to Wikipedia is ~862x862px. I think the problem is that the SVG file has pixel dimensions configured in the "viewBox" attribute, and centimeter dimensions configured in the "width" and "height" attributes. Inkscape and Wikipedia both seem to prioritize the latter over the former.

Could GeoGebra be reconfigured to set the "viewBox" attribute to pixels instead of centimeters when using the "Size in pixels" export option?

Thanks.

[edit]

I forgot to say I am using the "Export_1" and "Export_2" points, and that I hid them. You may want to make them visible again.

Best Answer
photo

Please try GeoGebra Classic 6 - it has a better SVG export

Comments (4)

photo
1

hello. an idea


50 pixel=1cm in standar view. if you select standar view and you creates A=free point, B=A+(6,-6) you get two corners for a 300x300 pixels. then you can do Export_1=AttachCopyToView(A, 1 ) and Export_2=AttachCopyToView(B,1)


you can move, zoom or scale the view. then try to exportimage and test the pixels of exported file. report here the result


I got this xml data doing this:


 version="1.1"
     baseProfile="full"
     xmlns="http://www.w3.org/2000/svg";
     xmlns:xlink="http://www.w3.org/1999/xlink";
     xmlns:ev="http://www.w3.org/2001/xml-...;
     width="4.71388953391742cm"
     height="4.698228771346265cm"
     viewBox="0 0 299 299"
I suppose viewBox="0 0 299 299" means 300x300 pixels, but I can be wrong because it is the first svg in my life

photo
1

Have you tried using the ExportImage command?

https://wiki.geogebra.org/e...

I'm sure that it's implemented in v.6 Classic, not sure that is also available for v.5, but can't check right now, because I'm using an iPad.

photo
1

Please try GeoGebra Classic 6 - it has a better SVG export

photo
1

You are correct. This problem does not exist in GGB 6.

photo
© 2022 International GeoGebra Institute