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 MrPatol <lo...@cryms.com> on 2006/07/12 15:16:04 UTC

avoid extra borders

Hello I have an svg file generated by Adobe Illustrator. 
If I render with Batik or Firefox it's ok, if I render in java application
to generate png or jpeg image i get extra borders to some figures like in
this example.

http://www.cryms.com/svg.jpg 

Is possible to avoid this with some transcoding hints or some other
workaround ?

this is my code:


PNGTranscoder t = new PNGTranscoder();
t.addTranscodingHint(PNGTranscoder.KEY_INDEXED, new Integer(5));
t.addTranscodingHint(PNGTranscoder.KEY_XML_PARSER_VALIDATING, new
Boolean(false));

SVGGraphics2D svgGenerator = new SVGGraphics2D(mapDoc);

Element root = mapDoc.getDocumentElement();
svgGenerator.getRoot(root);
svgGenerator = null;

TranscoderInput input = new TranscoderInput(mapDoc);

// set the transcoding hints
Rectangle r = new Rectangle((int)(offsetX), (int)(offsetY),
(int)(imageWidth), (int)(imageHeight));

t.addTranscodingHint(ImageTranscoder.KEY_AOI, r);
t.addTranscodingHint(ImageTranscoder.KEY_WIDTH, new Float(imageWidth));
t.addTranscodingHint(ImageTranscoder.KEY_HEIGHT, new Float(imageHeight));

TranscoderOutput output = new TranscoderOutput(response.getOutputStream());

t.transcode(input, output);


Thank You for any help
-- 
View this message in context: http://www.nabble.com/avoid-extra-borders-tf1930768.html#a5288417
Sent from the Batik - Users forum at Nabble.com.

Re: avoid extra borders or SVG regenerated

Posted by MrPatol <lo...@cryms.com>.
:-) Final resolution

after this code

SVGGraphics2D svgGenerator = new SVGGraphics2D(mapDoc);
Element root = mapDoc.getDocumentElement();
svgGenerator.getRoot(root);

the attribute stroke of svg root tag has black as default value, which is
taken as default for the rest of the document.

I just added this:

root.setAttribute("stroke","none");

and everything get generated fine.

hope it will be useful to other people ;-)
ciao MrPatol
-- 
View this message in context: http://www.nabble.com/avoid-extra-borders-tf1930768.html#a5302780
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: avoid extra borders or SVG regenerated

Posted by MrPatol <lo...@cryms.com>.
Hello again, i investigated more and found that the following piece of code

SVGGraphics2D svgGenerator = new SVGGraphics2D(mapDoc);
Element root = mapDoc.getDocumentElement();
svgGenerator.getRoot(root);

make the source to be rebuilt completely by batik giving this result

http://www.cryms.com/retest.svg

now just have to find out what is missing or wrong and how to patch the
regenerated SVG


-- 
View this message in context: http://www.nabble.com/avoid-extra-borders-tf1930768.html#a5302647
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: avoid extra borders

Posted by MrPatol <lo...@cryms.com>.
Thank You Thomas,
I've isolated the SVG in a smaller files, that behaves the same way,
downloadable here:

http://www.cryms.com/test.svg

following my tests it must be the default stroke that has not the "none"
value, in fact modifiing the svg source and adding attribute stroke="none"
to the path tags it shows correctly....but the original file is 2Mb.

How can I define the default stroke to "none" if not present in a tag ?

Thanks MrPatol
-- 
View this message in context: http://www.nabble.com/avoid-extra-borders-tf1930768.html#a5297798
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: avoid extra borders

Posted by th...@kodak.com.
Hi Mr. Patol,

MrPatol <lo...@cryms.com> wrote on 07/12/2006 09:16:04 AM:

> Hello I have an svg file generated by Adobe Illustrator. If I render 
with 
> Batik or Firefox it's ok, if I render in java application to generate 
png or 
> jpeg image i get extra borders to some figures like in this example. 

   I would have to see the SVG document to know why it is stroking
these elements.

> Is possible to avoid this with some transcoding hints or some other 
workaround ? 

   Since the Batik viewer gets it right I'm sure it can be fixed/worked 
around
fairly easily but I'm having a hard time coming up with a really good 
reason
why one would end up with a 'stroke' and the other doesn't (something with
entities or default parameters is my best guess...).

> this is my code: 
> 
> PNGTranscoder t = new PNGTranscoder();
> t.addTranscodingHint(PNGTranscoder.KEY_INDEXED, new Integer(5));
> t.addTranscodingHint(PNGTranscoder.KEY_XML_PARSER_VALIDATING, new 
Boolean(false));
> 
> SVGGraphics2D svgGenerator = new SVGGraphics2D(mapDoc);
> 
> Element root = mapDoc.getDocumentElement();
> svgGenerator.getRoot(root);
> svgGenerator = null;
> 
> TranscoderInput input = new TranscoderInput(mapDoc);
> 
> // set the transcoding hints
> Rectangle r = new Rectangle((int)(offsetX), (int)(offsetY), 
(int)(imageWidth),
> (int)(imageHeight));
> 
> t.addTranscodingHint(ImageTranscoder.KEY_AOI, r);
> t.addTranscodingHint(ImageTranscoder.KEY_WIDTH, new Float(imageWidth));
> t.addTranscodingHint(ImageTranscoder.KEY_HEIGHT, new 
Float(imageHeight));
> 
> TranscoderOutput output = new 
TranscoderOutput(response.getOutputStream());
> 
> t.transcode(input, output);

> 
> Thank You for any help 
> View this message in context: avoid extra borders
> 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