java - Itext hyphenation in Table cells -


i´m creating table using itext.
output looks bad, because of hyphenation, seems not done properly.
allready read question how hyphenate text?
, example http://itextpdf.com/sandbox/tables/hyphenationexample
tried example in eclipse after added itext_hyph_xml.jar class path. no error thrown when run code, lines

hyphenator h = new hyphenator("de", "de", 2, 2); hyphenation s = h.hyphenate("leistungsscheinziffer"); system.out.println(s); 

print null console instead of "lei-stungs-schein-zif-fer" or similar expected.
tried playing parameters in

chunk.sethyphenation(new hyphenationauto("de", "de", 2,2)); 

but output in document never differes slightly.

the code i´m trying work looks kind of way:

for(string s: interest){         chunk chunk = new chunk(s,font[0]);         chunk.sethyphenation(new hyphenationauto("de", "de", 2,3));         table.addcell(new phrase(chunk)); 

}

ok figured out on own now.
, because couldn´t find answer on internet thought share here might have same error in future wouldn´t need week figure out.

seems in class hyphenator defaulthyphlocation set this:

private static final string defaulthyphlocation = "com/itextpdf/text/pdf/hyphenation/hyph/"; 

but structure of itext_hyph.jar looks this:
com.lowagie.text.pdf.hyphenation.hyph
loading hyph file jar surely fail, since path used hyphenator can not found. thought cause error seems null returned when loading of hyph file fails.
calling hyphenator.sethyphendir("com/lowagie/text/pdf/hyphenation/hyph/");
however wouldn´t change thing 1 think, since changes wrong string variable.
thing think of solve problem recreate itext_hyph.jar according path given in hyphenator , acctually fixed it. hyphenation working.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -