How do I set the width, height, & viewBox

A discussion forum for JFreeSVG (a fast, lightweight, SVG generator for the Java platform).

How do I set the width, height, & viewBox

Postby 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
DavidThi808
 
Posts: 106
Joined: Fri May 27, 2005 7:44 pm
Location: Boulder, CO

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

Postby 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: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
david.gilbert
JFreeChart Project Leader
 
Posts: 11615
Joined: Fri Mar 14, 2003 10:29 am

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

Postby 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
DavidThi808
 
Posts: 106
Joined: Fri May 27, 2005 7:44 pm
Location: Boulder, CO

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

Postby 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: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
david.gilbert
JFreeChart Project Leader
 
Posts: 11615
Joined: Fri Mar 14, 2003 10:29 am

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

Postby 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.
DavidThi808
 
Posts: 106
Joined: Fri May 27, 2005 7:44 pm
Location: Boulder, CO

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

Postby 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: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
david.gilbert
JFreeChart Project Leader
 
Posts: 11615
Joined: Fri Mar 14, 2003 10:29 am


Return to JFreeSVG

Who is online

Users browsing this forum: No registered users and 3 guests