/* * This code is free software. It may only be copied or modified * if you include the following copyright notice: * * --> Copyright 2001 by Bruno Lowagie <-- * --> Copyright 2004 by Kazuya Ujihara <-- * * This code is example code of 'iText .NET'. * See http://www.ujihara.jp/iTextdotNET/examples.html * * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ using System; using com.lowagie.text; using com.lowagie.text.pdf; using System.IO; public class Chap02_hyphenation { public static void Main(String[] args) { Console.WriteLine("Chapter 2: hyphenation"); // step 1: creation of a document-object Document document = new Document(PageSize.A4, 100, 300, 100, 100); // step 2: we create a writer that listens to the document PdfWriter writer = PdfWriter.getInstance(document, new FileStream("Chap02_hyphenation.pdf", FileMode.Create)); // step 3: we open the document document.open(); // step 4: we add some content String text = "It was the best of times, it was the worst of times, " + "it was the age of wisdom, it was the age of foolishness, " + "it was the epoch of belief, it was the epoch of incredulity, " + "it was the season of Light, it was the season of Darkness, " + "it was the spring of hope, it was the winter of despair, " + "we had everything before us, we had nothing before us, " + "we were all going direct to Heaven, we were all going direct " + "the other way\u2014in short, the period was so far like the present " + "period, that some of its noisiest authorities insisted on its " + "being received, for good or for evil, in the superlative degree " + "of comparison only."; document.add(new Paragraph("GB")); Chunk ckEN = new Chunk(text); HyphenationAuto autoEN = new HyphenationAuto("en", "GB", 2, 2); ckEN.setHyphenation(autoEN); Paragraph pEN = new Paragraph(ckEN); pEN.setAlignment(Element.__Value.ALIGN_JUSTIFIED); document.add(pEN); document.add(new Paragraph("US")); Chunk ckUS = new Chunk(text); HyphenationAuto autoUS = new HyphenationAuto("en", "US", 2, 2); ckUS.setHyphenation(autoUS); Paragraph pUS = new Paragraph(ckUS); pUS.setAlignment(Element.__Value.ALIGN_JUSTIFIED); document.add(pUS); // step 5: we close the document document.close(); } }