Class PDFText2HTML.FontState

  • Enclosing class:
    PDFText2HTML

    private static class PDFText2HTML.FontState
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<java.lang.String> stateList  
      private java.util.Set<java.lang.String> stateSet  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private FontState()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String clear()
      Closes all open states.
      private java.lang.String close​(java.lang.String tag)  
      private java.lang.String closeTag​(java.lang.String tag)  
      private int closeUntil​(java.lang.StringBuilder tagsBuilder, java.lang.String endTag)  
      private boolean isBold​(PDFontDescriptor descriptor)  
      private boolean isItalic​(PDFontDescriptor descriptor)  
      private java.lang.String open​(java.lang.String tag)  
      private java.lang.String openTag​(java.lang.String tag)  
      protected java.lang.String push​(java.lang.StringBuilder buffer, char character, TextPosition textPosition)  
      java.lang.String push​(java.lang.String text, java.util.List<TextPosition> textPositions)
      Pushes new TextPositions into the font state.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • stateList

        private final java.util.List<java.lang.String> stateList
      • stateSet

        private final java.util.Set<java.lang.String> stateSet
    • Constructor Detail

      • FontState

        private FontState()
    • Method Detail

      • push

        public java.lang.String push​(java.lang.String text,
                                     java.util.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 java.lang.String clear()
        Closes all open states.
        Returns:
        A string that contains the closing tags of all currently open states.
      • push

        protected java.lang.String push​(java.lang.StringBuilder buffer,
                                        char character,
                                        TextPosition textPosition)
      • open

        private java.lang.String open​(java.lang.String tag)
      • close

        private java.lang.String close​(java.lang.String tag)
      • closeUntil

        private int closeUntil​(java.lang.StringBuilder tagsBuilder,
                               java.lang.String endTag)
      • openTag

        private java.lang.String openTag​(java.lang.String tag)
      • closeTag

        private java.lang.String closeTag​(java.lang.String tag)