Package com.aowagie.text.pdf.parser
Class PdfContentStreamProcessor
- java.lang.Object
-
- com.aowagie.text.pdf.parser.PdfContentStreamProcessor
-
- Direct Known Subclasses:
SimpleTextExtractingPdfContentStreamProcessor
abstract class PdfContentStreamProcessor extends java.lang.Object
Processor for a PDF content Stream.- Since:
- 2.1.4
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
PdfContentStreamProcessor.BeginText
A content operator implementation (BT).private static class
PdfContentStreamProcessor.EndText
A content operator implementation (ET).private static class
PdfContentStreamProcessor.ModifyCurrentTransformationMatrix
A content operator implementation (cm).private static class
PdfContentStreamProcessor.MoveNextLineAndShowText
A content operator implementation (').private static class
PdfContentStreamProcessor.MoveNextLineAndShowTextWithSpacing
A content operator implementation (").private static class
PdfContentStreamProcessor.PopGraphicsState
A content operator implementation (Q).private static class
PdfContentStreamProcessor.ProcessGraphicsStateResource
A content operator implementation (gs).private static class
PdfContentStreamProcessor.PushGraphicsState
A content operator implementation (q).private static class
PdfContentStreamProcessor.SetTextCharacterSpacing
A content operator implementation (Tc).private static class
PdfContentStreamProcessor.SetTextFont
A content operator implementation (Tf).private static class
PdfContentStreamProcessor.SetTextHorizontalScaling
A content operator implementation (Tz).private static class
PdfContentStreamProcessor.SetTextLeading
A content operator implementation (TL).private static class
PdfContentStreamProcessor.SetTextRenderMode
A content operator implementation (Tr).private static class
PdfContentStreamProcessor.SetTextRise
A content operator implementation (Ts).private static class
PdfContentStreamProcessor.SetTextWordSpacing
A content operator implementation (Tw).private static class
PdfContentStreamProcessor.ShowText
A content operator implementation (Tj).private static class
PdfContentStreamProcessor.ShowTextArray
A content operator implementation (TJ).private static class
PdfContentStreamProcessor.TextMoveNextLine
A content operator implementation (T*).private static class
PdfContentStreamProcessor.TextMoveStartNextLine
A content operator implementation (Td).private static class
PdfContentStreamProcessor.TextMoveStartNextLineWithLeading
A content operator implementation (TD).private static class
PdfContentStreamProcessor.TextSetTextMatrix
A content operator implementation (Tm).
-
Field Summary
Fields Modifier and Type Field Description private java.util.Stack
gsStack
Stack keeping track of the graphics state.private java.util.Map
operators
A map with all supported operators operators (PDF syntax).private PdfDictionary
resources
Resources for the content stream.private Matrix
textLineMatrix
Text line matrix.private Matrix
textMatrix
Text matrix.
-
Constructor Summary
Constructors Constructor Description PdfContentStreamProcessor()
Creates a new PDF Content Stream Processor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private java.lang.String
decode(PdfString in)
Decodes a PdfString (which will contain glyph ids encoded in the font's encoding) based on the active font, and determine the unicode equivalentprivate void
displayPdfString(PdfString string, float tj)
Displays text.abstract void
displayText(java.lang.String text, Matrix nextTextMatrix)
Displays text.Matrix
getCurrentTextLineMatrix()
Returns the current line matrix.Matrix
getCurrentTextMatrix()
Returns the current text matrix.private float
getStringWidth(java.lang.String string, float tj)
Gets the width of a String.GraphicsState
gs()
Returns the current graphics state.private void
invokeOperator(PdfLiteral operator, java.util.ArrayList operands)
Invokes an operator.private void
populateOperators()
Loads all the supported graphics and text state operators in a map.void
processContent(byte[] contentBytes, PdfDictionary resources)
Processes PDF syntaxvoid
reset()
Resets the graphics state stack, matrices and resources.
-
-
-
Field Detail
-
operators
private java.util.Map operators
A map with all supported operators operators (PDF syntax).
-
resources
private PdfDictionary resources
Resources for the content stream.
-
gsStack
private final java.util.Stack gsStack
Stack keeping track of the graphics state.
-
textMatrix
private Matrix textMatrix
Text matrix.
-
textLineMatrix
private Matrix textLineMatrix
Text line matrix.
-
-
Method Detail
-
populateOperators
private void populateOperators()
Loads all the supported graphics and text state operators in a map.
-
reset
public void reset()
Resets the graphics state stack, matrices and resources.
-
gs
public GraphicsState gs()
Returns the current graphics state.- Returns:
- the graphics state
-
getCurrentTextMatrix
public Matrix getCurrentTextMatrix()
Returns the current text matrix.- Returns:
- the text matrix
- Since:
- 2.1.5
-
getCurrentTextLineMatrix
public Matrix getCurrentTextLineMatrix()
Returns the current line matrix.- Returns:
- the line matrix
- Since:
- 2.1.5
-
invokeOperator
private void invokeOperator(PdfLiteral operator, java.util.ArrayList operands)
Invokes an operator.- Parameters:
operator
- the PDF Syntax of the operatoroperands
- a list with operands
-
decode
private java.lang.String decode(PdfString in)
Decodes a PdfString (which will contain glyph ids encoded in the font's encoding) based on the active font, and determine the unicode equivalent- Parameters:
in
- the String that needs to be encoded- Returns:
- the encoded String
- Since:
- 2.1.7
-
displayText
public abstract void displayText(java.lang.String text, Matrix nextTextMatrix)
Displays text.- Parameters:
text
- the text that needs to be displayednextTextMatrix
- a text matrix
-
getStringWidth
private float getStringWidth(java.lang.String string, float tj)
Gets the width of a String.- Parameters:
string
- the string that needs measuringtj
- text adjustment- Returns:
- the width of a String
-
displayPdfString
private void displayPdfString(PdfString string, float tj)
Displays text.- Parameters:
string
- the text to displaytj
- the text adjustment
-
processContent
public void processContent(byte[] contentBytes, PdfDictionary resources)
Processes PDF syntax- Parameters:
contentBytes
- the bytes of a content streamresources
- the resources that come with the content stream
-
-