Op 20/05/2011 21:46, pdfengine schreef:
The result looks still not very good.
In your screen shot, I can clearly see that some lines are hyphenated: "in-vest", "cor-porate",... You say the result is "not very good", probably because the word "International" isn't hyphenated. However, when I use the latest iText version like this:
Hyphenator h = new Hyphenator("en", "US", 2, 2); Hyphenation s = h.hyphenate("International"); System.out.println(s); I get "In-ter-na-tion-al". So there's no problem with the hyphenation XML. To find out if there's a problem with iText, I've made a standalone sample to see if I could reproduce the problem. See HyphenationExample.java and the resulting PDF in attachment. The results looks fine. The word "International" is hyphenated correctly. In other words: this is yet another question that can be filed as "not reproducable". I'm sorry, but we can't fix things that aren't broken. If you say that something doesn't work, you need to provide proof. I hope you understand.
<<< text/html; name="hyph.pdf": Unrecognized >>>
package examples.hyph; import java.io.FileOutputStream; import java.io.IOException; import com.itextpdf.text.Chunk; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.Element; import com.itextpdf.text.Paragraph; import com.itextpdf.text.pdf.ColumnText; import com.itextpdf.text.pdf.HyphenationAuto; import com.itextpdf.text.pdf.PdfWriter; import com.itextpdf.text.pdf.hyphenation.Hyphenation; import com.itextpdf.text.pdf.hyphenation.Hyphenator; public class HyphenationExample { public static final String TEXT = "James Moffett of Scout International UMBWX shares Jain's reluctance to invest directly in China, but because of doubts over corporate governance and legal protection, not out of concern over economic growth. Therefore, while Moffett has avoided Chinese stocks entirely, unlike Jain he has specifically sought exposure to China's rapid growth through overseas stocks such as BHP Billiton and Komatsu."; public static void main(String[] args) throws DocumentException, IOException { Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("results/hyph.pdf")); document.open(); Hyphenator h = new Hyphenator("en", "US", 2, 2); Hyphenation a = h.hyphenate("International"); System.out.println(a); Chunk ck = new Chunk(TEXT); ck.setHyphenation(new HyphenationAuto("en", "US", 2, 2)); ColumnText ct = new ColumnText(writer.getDirectContent()); ct.setAlignment(Element.ALIGN_JUSTIFIED); ct.setSimpleColumn(36, 36, 216, 806); ct.addText(ck); ct.go(); document.close(); } }
------------------------------------------------------------------------------ What Every C/C++ and Fortran developer Should Know! Read this article and learn how Intel has extended the reach of its next-generation tools to help Windows* and Linux* C/C++ and Fortran developers boost performance applications - including clusters. http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php