Package com.lowagie.text.pdf.parser
Class PdfContentStreamHandler
- java.lang.Object
-
- com.lowagie.text.pdf.parser.PdfContentStreamHandler
-
public class PdfContentStreamHandler extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
PdfContentStreamHandler.BeginMarked
A content operator implementation (BMC).private static class
PdfContentStreamHandler.BeginMarkedDict
A content operator implementation (BDC).(package private) static class
PdfContentStreamHandler.BeginText
A content operator implementation (BT).private class
PdfContentStreamHandler.Do
private static class
PdfContentStreamHandler.EndMarked
A content operator implementation (EMC).(package private) static class
PdfContentStreamHandler.EndText
A content operator implementation (ET).(package private) static class
PdfContentStreamHandler.ModifyCurrentTransformationMatrix
A content operator implementation (cm).(package private) static class
PdfContentStreamHandler.MoveNextLineAndShowText
A content operator implementation (').(package private) static class
PdfContentStreamHandler.MoveNextLineAndShowTextWithSpacing
A content operator implementation (").(package private) static class
PdfContentStreamHandler.PopGraphicsState
A content operator implementation (Q).(package private) static class
PdfContentStreamHandler.ProcessGraphicsStateResource
A content operator implementation (gs).(package private) static class
PdfContentStreamHandler.PushGraphicsState
A content operator implementation (q).(package private) static class
PdfContentStreamHandler.SetTextCharacterSpacing
A content operator implementation (Tc).(package private) static class
PdfContentStreamHandler.SetTextFont
A content operator implementation (Tf).(package private) static class
PdfContentStreamHandler.SetTextHorizontalScaling
A content operator implementation (Tz).(package private) static class
PdfContentStreamHandler.SetTextLeading
A content operator implementation (TL).(package private) static class
PdfContentStreamHandler.SetTextRenderMode
A content operator implementation (Tr).(package private) static class
PdfContentStreamHandler.SetTextRise
A content operator implementation (Ts).(package private) static class
PdfContentStreamHandler.SetTextWordSpacing
A content operator implementation (Tw).(package private) static class
PdfContentStreamHandler.ShowText
A content operator implementation (Tj).(package private) static class
PdfContentStreamHandler.ShowTextArray
A content operator implementation (TJ).(package private) static class
PdfContentStreamHandler.TextMoveNextLine
A content operator implementation (T*).(package private) static class
PdfContentStreamHandler.TextMoveStartNextLine
A content operator implementation (Td).(package private) static class
PdfContentStreamHandler.TextMoveStartNextLineWithLeading
A content operator implementation (TD).(package private) static class
PdfContentStreamHandler.TextSetTextMatrix
A content operator implementation (Tm).
-
Field Summary
Fields Modifier and Type Field Description private java.util.Stack<java.lang.String>
contextNames
private java.util.Stack<GraphicsState>
gsStack
Stack keeping track of the graphics state.private java.util.Map<java.lang.String,ContentOperator>
operators
A map with all supported operators operators (PDF syntax).private TextAssembler
renderListener
detail parser for text within a marked section.private java.util.List<TextAssemblyBuffer>
textFragments
private java.util.Stack<java.util.List<TextAssemblyBuffer>>
textFragmentStreams
private Matrix
textLineMatrix
Text line matrix.private Matrix
textMatrix
Text matrix.
-
Constructor Summary
Constructors Constructor Description PdfContentStreamHandler(TextAssembler renderListener)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
applyTextAdjust(float tj)
Adjusts the text matrix for the specified adjustment value (see TJ operator in the PDF spec for information)(package private) void
displayPdfString(PdfString string)
Displays text.CMapAwareDocumentFont
getCurrentFont()
protected Matrix
getCurrentTextLineMatrix()
Returns the current line matrix.protected Matrix
getCurrentTextMatrix()
Returns the current text matrix.private static Matrix
getMatrix(java.util.List<PdfObject> operands)
java.lang.String
getResultantText()
(package private) GraphicsState
graphicsState()
Returns the current graphics state.protected void
installDefaultOperators()
Loads all the supported graphics and text state operators in a map.void
invokeOperator(PdfLiteral operator, java.util.List<PdfObject> operands, PdfDictionary resources)
Invokes an operator.java.util.Optional<ContentOperator>
lookupOperator(java.lang.String operatorName)
Get the operator to process a command with a given name(package private) void
popContext()
(package private) void
pushContext(java.lang.String newContextName)
void
registerContentOperator(ContentOperator operator)
Registers a content operator that will be called when the specified operator string is encountered during content processing.void
reset()
-
-
-
Field Detail
-
textFragmentStreams
private final java.util.Stack<java.util.List<TextAssemblyBuffer>> textFragmentStreams
-
contextNames
private final java.util.Stack<java.lang.String> contextNames
-
renderListener
private final TextAssembler renderListener
detail parser for text within a marked section. used by TextAssembler
-
operators
private java.util.Map<java.lang.String,ContentOperator> operators
A map with all supported operators operators (PDF syntax).
-
gsStack
private java.util.Stack<GraphicsState> gsStack
Stack keeping track of the graphics state.
-
textMatrix
private Matrix textMatrix
Text matrix.
-
textLineMatrix
private Matrix textLineMatrix
Text line matrix.
-
textFragments
private java.util.List<TextAssemblyBuffer> textFragments
-
-
Constructor Detail
-
PdfContentStreamHandler
public PdfContentStreamHandler(TextAssembler renderListener)
-
-
Method Detail
-
registerContentOperator
public void registerContentOperator(ContentOperator operator)
Registers a content operator that will be called when the specified operator string is encountered during content processing. Each operator may be registered only once (it is not legal to have multiple operators with the same operatorString)- Parameters:
operator
- the operator that will receive notification when the operator is encountered- Since:
- 2.1.7
-
installDefaultOperators
protected void installDefaultOperators()
Loads all the supported graphics and text state operators in a map.
-
lookupOperator
public java.util.Optional<ContentOperator> lookupOperator(java.lang.String operatorName)
Get the operator to process a command with a given name- Parameters:
operatorName
- name of the operator that we might need to call- Returns:
- the operator or null if none present
-
invokeOperator
public void invokeOperator(PdfLiteral operator, java.util.List<PdfObject> operands, PdfDictionary resources)
Invokes an operator.- Parameters:
operator
- the PDF Syntax of the operatoroperands
- a list with operandsresources
- Pdf Resources found in the file containing the stream.
-
popContext
void popContext()
-
pushContext
void pushContext(java.lang.String newContextName)
-
graphicsState
GraphicsState graphicsState()
Returns the current graphics state.- Returns:
- the graphics state
-
reset
public void reset()
-
getCurrentTextMatrix
protected Matrix getCurrentTextMatrix()
Returns the current text matrix.- Returns:
- the text matrix
- Since:
- 2.1.5
-
getCurrentTextLineMatrix
protected Matrix getCurrentTextLineMatrix()
Returns the current line matrix.- Returns:
- the line matrix
- Since:
- 2.1.5
-
applyTextAdjust
void applyTextAdjust(float tj)
Adjusts the text matrix for the specified adjustment value (see TJ operator in the PDF spec for information)- Parameters:
tj
- the text adjustment
-
getCurrentFont
public CMapAwareDocumentFont getCurrentFont()
- Returns:
- current font in processing state
-
displayPdfString
void displayPdfString(PdfString string)
Displays text.- Parameters:
string
- the text to display
-
getResultantText
public java.lang.String getResultantText()
- Returns:
- result text
-
-