How do I set the width, height, & viewBox

A discussion forum for JFreeSVG (a fast, lightweight, SVG generator for the Java platform).
Locked
DavidThi808
Posts: 106
Joined: Fri May 27, 2005 7:44 pm
Location: Boulder, CO
Contact:

How do I set the width, height, & viewBox

Post by DavidThi808 » Sun Aug 14, 2016 2:55 pm

Hi all;

How can I set the width & height in inches? And how can I set the viewBox?

I want the <svg> element to have: width="2in" height="4in" viewBox="0 0 1828800 1828800"

The reason I need this is I know the size of my SVG object. And I am passing all units for all renders in EMUs (914400/inch). So I can create the SVG canvas size in EMUs, write all objects using EMUs. Then setting the viewBox makes that all map correctly. Setting the size in inches then takes that to the size of the final object I want.

thanks - dave

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: How do I set the width, height, & viewBox

Post by david.gilbert » Tue Aug 16, 2016 10:45 pm

The viewBox feature is missing, it has been raised by another user also:

https://github.com/jfree/jfreesvg/pull/4

I'll get this feature into the next release most likely.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

DavidThi808
Posts: 106
Joined: Fri May 27, 2005 7:44 pm
Location: Boulder, CO
Contact:

Re: How do I set the width, height, & viewBox

Post by DavidThi808 » Tue Aug 16, 2016 11:05 pm

david.gilbert wrote:I'll get this feature into the next release most likely.
Please consider adding the ability to set the width/height in units too.

thanks - dave

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: How do I set the width, height, & viewBox

Post by david.gilbert » Wed Aug 17, 2016 12:04 pm

I'll research that. I guess that if the units are specified then that will also need to be synchronised with a translation on the Graphics2D instance so that the drawing units are consistent. Or how do you see that working?
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

DavidThi808
Posts: 106
Joined: Fri May 27, 2005 7:44 pm
Location: Boulder, CO
Contact:

Re: How do I set the width, height, & viewBox

Post by DavidThi808 » Wed Aug 17, 2016 1:05 pm

david.gilbert wrote:I'll research that. I guess that if the units are specified then that will also need to be synchronised with a translation on the Graphics2D instance so that the drawing units are consistent. Or how do you see that working?
No, I just need to set it at the end. I render the entire SVG using EMUs for all coordinates and telling it the size in EMUs. But think of the entire rendering as occurring in arbitrary units.

Then when I'm done I use the viewBox to give the size of those arbitrary units and set the width/height to physical inches so it knows the viewBox -> physical scaling.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: How do I set the width, height, & viewBox

Post by david.gilbert » Tue Aug 30, 2016 7:54 pm

Hi David,

I just pushed some changes to GitHub that I hope will meet your requirements. Please take a look and let me know...if all is good I'll release version 3.2.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

alarawany
Posts: 4
Joined: Sun May 20, 2018 10:54 pm
antibot: No, of course not.

Re: How do I set the width, height, & viewBox

Post by alarawany » Sun May 20, 2018 10:58 pm

The viewBox feature is missing, it has been raised by another user also
Graduated from Soran University with First Class Degree with Honours in Computer Science

Locked