Package org.apache.pdfbox.tools
Class PDFText2Markdown.FontState
java.lang.Object
org.apache.pdfbox.tools.PDFText2Markdown.FontState
- Enclosing class:
PDFText2Markdown
A helper class to maintain the current font state. Its public methods will emit opening and
closing tags as needed and in the correct order.
Responsible for applying Markdown formatting based on font properties. Supports bold and italic text based on font descriptors.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclear()Closes all open Markdown formatting.private Stringprivate Stringprivate intcloseUntil(StringBuilder tagsBuilder, String endTag) private booleanisBold(PDFontDescriptor descriptor) private booleanisItalic(PDFontDescriptor descriptor) private Stringprivate Stringprotected Stringpush(StringBuilder buffer, char character, TextPosition textPosition) push(String text, List<TextPosition> textPositions) Pushes newTextPositionsinto the font state.
-
Field Details
-
stateList
-
stateSet
-
-
Constructor Details
-
FontState
private FontState()
-
-
Method Details
-
push
Pushes newTextPositionsinto the font state. The state is only preserved correctly for each letter if the number of letters intextmatches the number ofTextPositionobjects. 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
Closes all open Markdown formatting.- Returns:
- A string that contains the closing tags of all currently open Markdown formatting.
-
push
-
open
-
close
-
closeUntil
-
openTag
-
closeTag
-
isBold
-
isItalic
-