I'm having a problem running the hyphenation example:
Chap02_hyphenation.java under Java 1.3.1 on a Windows 2000 box. It looks to
me like there's a bug in Sun's code on this platform which is causing
problems.

Firstly, (before you ask) I do in fact have the iTextHYPH.jar in the
classpath and yes I have checked to make certain that it is not corrupted. I
have also made sure that I have the latest code: 0.93b

I have tracked the problem down to the getResourceStream() method in the
com.lowagie.text.pdf.hyphenator.Hyphenator class,

Specifically:

        // Try to use Context Class Loader to load the properties file.
        try {
            java.lang.reflect.Method getCCL =
                Thread.class.getMethod("getContextClassLoader", new
Class[0]);
            if (getCCL != null) {
                ClassLoader contextClassLoader =
                    (ClassLoader)getCCL.invoke(Thread.currentThread(),
                                               new Object[0]);
                is = contextClassLoader.getResourceAsStream("hyph/" + key
                                                            + ".hyp");
            }
        } catch (Exception e) {}

If I comment this out and let the code following it load the resource
everything works fine.

However loading the resource as a stream from the class loader
returns garbage. I even tried replacing the dynamically invoked stuff (which
I assume you have for Java 1.1 compatibility) with direct calls:

         is = Thread.currentThread().getContextClassLoader()
             .getResourceAsStream("hyph/" + key + ".hyp");

but the same problem arose.

Here is the stacktrace:

ExceptionConverter: sun.io.MalformedInputException
        at sun.io.ByteToCharUTF8.convert(Unknown Source)
        at java.io.InputStreamReader.convertInto(Unknown Source)
        at java.io.InputStreamReader.fill(Unknown Source)
        at java.io.InputStreamReader.read(Unknown Source)
        at java.io.Reader.read(Unknown Source)
        at
com.lowagie.text.pdf.hyphenation.PatternInternalParser.getHyphString(
Unknown Source)
        at
com.lowagie.text.pdf.hyphenation.PatternInternalParser.parse(Unknown
Source)
        at
com.lowagie.text.pdf.hyphenation.HyphenationTree.loadInternalPatterns
(Unknown Source)
        at
com.lowagie.text.pdf.hyphenation.Hyphenator.getFopHyphenationTree(Unk
nown Source)
        at
com.lowagie.text.pdf.hyphenation.Hyphenator.getHyphenationTree(Unknow
n Source)
        at com.lowagie.text.pdf.hyphenation.Hyphenator.<init>(Unknown
Source)
        at com.lowagie.text.pdf.HyphenationAuto.<init>(Unknown Source)
        at Chap02_hyphenation.main(Chap02_hyphenation.java:54)
ExceptionConverter: sun.io.MalformedInputException
        at sun.io.ByteToCharUTF8.convert(Unknown Source)
        at java.io.InputStreamReader.convertInto(Unknown Source)
        at java.io.InputStreamReader.fill(Unknown Source)
        at java.io.InputStreamReader.read(Unknown Source)
        at java.io.Reader.read(Unknown Source)
        at
com.lowagie.text.pdf.hyphenation.PatternInternalParser.getHyphString(
Unknown Source)
        at
com.lowagie.text.pdf.hyphenation.PatternInternalParser.parse(Unknown
Source)
        at
com.lowagie.text.pdf.hyphenation.HyphenationTree.loadInternalPatterns
(Unknown Source)
        at
com.lowagie.text.pdf.hyphenation.Hyphenator.getFopHyphenationTree(Unk
nown Source)
        at
com.lowagie.text.pdf.hyphenation.Hyphenator.getHyphenationTree(Unknow
n Source)
        at com.lowagie.text.pdf.hyphenation.Hyphenator.<init>(Unknown
Source)
        at com.lowagie.text.pdf.HyphenationAuto.<init>(Unknown Source)
        at Chap02_hyphenation.main(Chap02_hyphenation.java:61)

I noticed that you use the same technique in com.lowagie.text.pdf.BaseFont
although I'm not sure how this affects me right at the moment.

I am currently using the hyphenator code with the offending part commented
out without any further problems.

cheers

...john




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to