Class PDFText2HTML.FontState

java.lang.Object
org.apache.pdfbox.tools.PDFText2HTML.FontState
Enclosing class:
PDFText2HTML

private static class PDFText2HTML.FontState extends Object
A helper class to maintain the current font state. It's public methods will emit opening and closing tags as needed, and in the correct order.
  • Field Details

    • stateList

      private final List<String> stateList
    • stateSet

      private final Set<String> stateSet
  • Constructor Details

    • FontState

      private FontState()
  • Method Details

    • push

      public String push(String text, List<TextPosition> textPositions)
      Pushes new TextPositions into the font state. The state is only preserved correctly for each letter if the number of letters in text matches the number of TextPosition objects. Otherwise, it's done once for the complete array (just by looking at its first entry).
      Returns:
      A string that contains the text including tag changes caused by its font state.
    • clear

      public String clear()
      Closes all open states.
      Returns:
      A string that contains the closing tags of all currently open states.
    • push

      protected String push(StringBuilder buffer, char character, TextPosition textPosition)
    • open

      private String open(String tag)
    • close

      private String close(String tag)
    • closeUntil

      private int closeUntil(StringBuilder tagsBuilder, String endTag)
    • openTag

      private String openTag(String tag)
    • closeTag

      private String closeTag(String tag)
    • isBold

      private boolean isBold(PDFontDescriptor descriptor)
    • isItalic

      private boolean isItalic(PDFontDescriptor descriptor)