You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Sudhakar S <ye...@hotmail.com> on 2006/09/01 12:52:03 UTC
Getting Selected Area for Print Preview
Hi All,
I am trying to give print preview for selected area using Rectangle element.
I can able show only the selected area when SVG Canvas is not Zoomed In.
also I can shrink the selected area within single page.
But this is not happening while Zoom In the SVG Canvas to larger size. It is
scaling the document to smaller size lesser than expected page size. So it
is showing the whole document.
Please see the code below, so that you can find the problem.
.
.
.
Element elt = ((SVGDocument)svgDoc).getRootElement();
AffineTransform usr2dev = ViewBox.getViewTransform(null, elt,
(int)rec.getWidth(), (int)rec.getHeight());
if (fitPage) {
// width refers paper width
// height refers paper width
xscale = width/_selArea.getWidth() ;
yscale = height/_selArea.getHeight();
double scale = Math.min(xscale, yscale);
usr2dev.setToScale(scale, scale);
//After scaled the document, now I am getting the scaled selected area size
Rectangle r = usr2dev.createTransformedShape(_selArea).getBounds();
usr2dev.translate(-r.getX(), -r.getY());
return getImage(usr2dev,(int)r.getWidth(), (int)r.getHeight());
} else {
Dimension size = getPreferredSize();
xscale = width / (float)size.getWidth();
yscale = height / (float)size.getHeight();
double scale = Math.min(xscale, yscale);
usr2dev.setToScale(scale, scale);
}
Here "usr2dev.createTransformedShape(_selArea).getBounds()" returns proper
width or height of the zoomed out rectangle area.
So please anybody explain how to resolve this problem?
Thanks,
Sudhakar
--
View this message in context: http://www.nabble.com/Getting-Selected-Area-for-Print-Preview-tf2201896.html#a6096488
Sent from the Batik - Users forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
Re: Getting Selected Area for Print Preview
Posted by Sudhakar S <ye...@hotmail.com>.
Hi All,
I have found the problem. There was problem in caculating the scale value.
So it scaled the docment smaller in size.
Thanks,
Sudhakar
--
View this message in context: http://www.nabble.com/Getting-Selected-Area-for-Print-Preview-tf2201896.html#a6121462
Sent from the Batik - Users forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org