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 Diwakar Mantha <dm...@i2.com> on 2001/05/16 19:06:25 UTC
rasterizer help...
Resending, since the original message did not seem to have made it to the
list... sorry if it duplicates...
=====
Hi,
I am trying the Batik rasterizer (batik-1.0beta2) for the first time, and am
running into the following problems. Any help is highly appreciated. I
have written a simple test class that takes a given SVG file and writes the
corresponding JPEG file. The Java and SVG code, and the program output are
attached. When I run my test class, I have the following problems,
1. The JPEG only shows a white rectangle. The SVG had a red rectangle on
top of a bigger white one, so why is the JPEG not the same?
2. Initially there are several messages of the type "Font specified in
font.properties not found [-urw-itc
zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]" that appear.
What do these mean, and how to fix them?
3. I was forced to specify (arbitrary) values for KEY_WIDTH and KEY_HEIGHT
for the JPEGTranscoder, otherwise there was an error at run-time
"org.apache.batik.transcoder.TranscoderException: Width (-2147483360) and
height (0) must be > 0", and the JPEG file was not generated correctly. The
Javadoc says KEY_WIDTH and KEY_HEIGHT are optional, so why do I get this
error?
4. Which of the several jar files that come with batik-1.0beta2.zip are
really needed? For now, I have added ALL 20 of them to the classpath.
5. The program does not terminate after printing "!!! DONE !!!".
I apologize for the lengthy mail, and the probably elementary questions.
Thanks...
==== trnscd.java (Java file) ======
import java.io.FileNotFoundException;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.BufferedInputStream;
import org.apache.batik.transcoder.TranscoderException;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.image.ImageTranscoder;
import org.apache.batik.transcoder.image.JPEGTranscoder;
public class trnscd {
public static void main (String args[]) {
System.out.println("Creating ImageTranscoder...");
ImageTranscoder t = new JPEGTranscoder();
t.addTranscodingHint(JPEGTranscoder.KEY_XML_PARSER_CLASSNAME,
"org.apache.crimson.parser.XMLReaderImpl");
t.addTranscodingHint(ImageTranscoder.KEY_WIDTH, new Float(150));
t.addTranscodingHint(ImageTranscoder.KEY_HEIGHT, new Float(150));
System.out.println("Creating OutputStream...");
FileOutputStream fos = null;
try {
fos = new FileOutputStream("jj.jpeg");
} catch (FileNotFoundException e) {
System.out.println(e);
}
OutputStream os = new BufferedOutputStream (fos);
System.out.println("Creating InputStream...");
FileInputStream fis = null;
try {
fis = new FileInputStream("jj.svg");
} catch (FileNotFoundException e) {
System.out.println(e);
}
InputStream is = new BufferedInputStream (fis);
System.out.println("Creating TranscoderInput/Output...");
TranscoderInput ti = new TranscoderInput(is);
TranscoderOutput to = new TranscoderOutput(os);
System.out.println("Transcoding...");
try {
t.transcode(ti, to);
} catch (TranscoderException e) {
System.out.println(e);
}
System.out.println("!!! DONE !!!");
}
}
==== Console output ===============
Creating ImageTranscoder...
Font specified in font.properties not found [-urw-itc
zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
<19 more of the above messages have been deleted here>
Creating OutputStream...
Creating InputStream...
Creating TranscoderInput/Output...
Transcoding...
ERROR: unknown language:
ERROR: The JPEG quality has not been specified. Use the default one: no
compression
!!! DONE !!!
==== jj.svg (SVG file) ============
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20001102//EN'
'http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd'>
<svg style="fill-opacity:1; color-interpolation:sRGB; color-rendering:auto;
text-rendering:auto; stroke:black; stroke-linecap:square;
stroke-miterlimit:10; stroke-opacity:1; shape-rendering:auto; fill:black;
stroke-dasharray:none; font-weight:normal; stroke-width:1;
font-family:'Arial'; font-style:normal; stroke-linejoin:miter;
font-size:12; image-rendering:auto; stroke-dashoffset:0;" width="2147483647"
height="2147483647">
<!--Generated by the Batik Graphics2D SVG Generator-->
<script language="javascript">window.x = "kk"; function bz() {
alert('bz'); }; var y = window.iii; alert(y);</script>
<defs id="genericDefs" />
<g>
<g style="fill:red; stroke:red;">
<rect x="10" y="10" width="100" style="stroke:none;" height="100" />
</g>
</g>
</svg>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
RE: rasterizer help...
Posted by Diwakar Mantha <dm...@i2.com>.
Thanks a lot, Thierry. Setting the correct SVG size helped in obtaining the
correct JPEG file.
-----Original Message-----
From: Thierry Kormann [mailto:tkormann@sophia.inria.fr]
Sent: Thursday, May 17, 2001 7:05 AM
To: Batik Users
Subject: Re: rasterizer help...
On Wednesday 16 May 2001 19:06, you wrote:
> 2. Initially there are several messages of the type "Font specified in
> font.properties not found [-urw-itc
> zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]" that appear.
> What do these mean, and how to fix them?
Some of the fonts are not available on your platform.
You can have a look at the jdk problem/answer section on sun website.
> 3. I was forced to specify (arbitrary) values for KEY_WIDTH and KEY_HEIGHT
> for the JPEGTranscoder, otherwise there was an error at run-time
> "org.apache.batik.transcoder.TranscoderException: Width (-2147483360) and
> height (0) must be > 0", and the JPEG file was not generated correctly.
> The Javadoc says KEY_WIDTH and KEY_HEIGHT are optional, so why do I get
> this error?
I have seen that you have specified the width and height attributes on your
outermost SVG element to huge values such as:
width="2147483647" height="2147483647">
Those values represents the size of the canvas/image.
Trying to rasterize an image of this size fails.
By specifying the KEY_WIDTH and KEY_HEIGHT transcoding hints, you 'override'
these values so your document can be rasterized.
Solution: change the width and height attribute if you don't want to use the
transcoding hints.
Hope this helps,
Thierry.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: rasterizer help...
Posted by Thierry Kormann <tk...@sophia.inria.fr>.
On Wednesday 16 May 2001 19:06, you wrote:
> 2. Initially there are several messages of the type "Font specified in
> font.properties not found [-urw-itc
> zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]" that appear.
> What do these mean, and how to fix them?
Some of the fonts are not available on your platform.
You can have a look at the jdk problem/answer section on sun website.
> 3. I was forced to specify (arbitrary) values for KEY_WIDTH and KEY_HEIGHT
> for the JPEGTranscoder, otherwise there was an error at run-time
> "org.apache.batik.transcoder.TranscoderException: Width (-2147483360) and
> height (0) must be > 0", and the JPEG file was not generated correctly.
> The Javadoc says KEY_WIDTH and KEY_HEIGHT are optional, so why do I get
> this error?
I have seen that you have specified the width and height attributes on your
outermost SVG element to huge values such as:
width="2147483647" height="2147483647">
Those values represents the size of the canvas/image.
Trying to rasterize an image of this size fails.
By specifying the KEY_WIDTH and KEY_HEIGHT transcoding hints, you 'override'
these values so your document can be rasterized.
Solution: change the width and height attribute if you don't want to use the
transcoding hints.
Hope this helps,
Thierry.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org