Class HyphenationAuto

java.lang.Object
com.lowagie.text.pdf.HyphenationAuto
All Implemented Interfaces:
HyphenationEvent

public class HyphenationAuto extends Object implements HyphenationEvent
Hyphenates words automatically accordingly to the language and country. The hyphenator engine was taken from FOP and uses the TEX patterns. If a language is not provided and a TEX pattern for it exists, it can be easily adapted.
  • Field Details

    • hyphenator

      protected Hyphenator hyphenator
      The hyphenator engine.
    • post

      protected String post
      The second part of the hyphenated word.
  • Constructor Details

    • HyphenationAuto

      public HyphenationAuto(String lang, String country, int leftMin, int rightMin)
      Creates a new hyphenation instance usable in Chunk.
      Parameters:
      lang - the language ("en" for English, for example)
      country - the country ("GB" for Great-Britain or "none" for no country, for example)
      leftMin - the minimum number of letters before the hyphen
      rightMin - the minimum number of letters after the hyphen
  • Method Details

    • getHyphenSymbol

      public String getHyphenSymbol()
      Gets the hyphen symbol.
      Specified by:
      getHyphenSymbol in interface HyphenationEvent
      Returns:
      the hyphen symbol
    • getHyphenatedWordPre

      public String getHyphenatedWordPre(String word, BaseFont font, float fontSize, float remainingWidth)
      Hyphenates a word and returns the first part of it. To get the second part of the hyphenated word call getHyphenatedWordPost().
      Specified by:
      getHyphenatedWordPre in interface HyphenationEvent
      Parameters:
      word - the word to hyphenate
      font - the font used by this word
      fontSize - the font size used by this word
      remainingWidth - the width available to fit this word in
      Returns:
      the first part of the hyphenated word including the hyphen symbol, if any
    • getHyphenatedWordPost

      public String getHyphenatedWordPost()
      Gets the second part of the hyphenated word. Must be called after getHyphenatedWordPre().
      Specified by:
      getHyphenatedWordPost in interface HyphenationEvent
      Returns:
      the second part of the hyphenated word