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.ObjectProcessor for a PDF content Stream.- Since:
- 2.1.4
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPdfContentStreamProcessor.BeginTextA content operator implementation (BT).private static classPdfContentStreamProcessor.EndTextA content operator implementation (ET).private static classPdfContentStreamProcessor.ModifyCurrentTransformationMatrixA content operator implementation (cm).private static classPdfContentStreamProcessor.MoveNextLineAndShowTextA content operator implementation (').private static classPdfContentStreamProcessor.MoveNextLineAndShowTextWithSpacingA content operator implementation (").private static classPdfContentStreamProcessor.PopGraphicsStateA content operator implementation (Q).private static classPdfContentStreamProcessor.ProcessGraphicsStateResourceA content operator implementation (gs).private static classPdfContentStreamProcessor.PushGraphicsStateA content operator implementation (q).private static classPdfContentStreamProcessor.SetTextCharacterSpacingA content operator implementation (Tc).private static classPdfContentStreamProcessor.SetTextFontA content operator implementation (Tf).private static classPdfContentStreamProcessor.SetTextHorizontalScalingA content operator implementation (Tz).private static classPdfContentStreamProcessor.SetTextLeadingA content operator implementation (TL).private static classPdfContentStreamProcessor.SetTextRenderModeA content operator implementation (Tr).private static classPdfContentStreamProcessor.SetTextRiseA content operator implementation (Ts).private static classPdfContentStreamProcessor.SetTextWordSpacingA content operator implementation (Tw).private static classPdfContentStreamProcessor.ShowTextA content operator implementation (Tj).private static classPdfContentStreamProcessor.ShowTextArrayA content operator implementation (TJ).private static classPdfContentStreamProcessor.TextMoveNextLineA content operator implementation (T*).private static classPdfContentStreamProcessor.TextMoveStartNextLineA content operator implementation (Td).private static classPdfContentStreamProcessor.TextMoveStartNextLineWithLeadingA content operator implementation (TD).private static classPdfContentStreamProcessor.TextSetTextMatrixA content operator implementation (Tm).
-
Field Summary
Fields Modifier and Type Field Description private java.util.StackgsStackStack keeping track of the graphics state.private java.util.MapoperatorsA map with all supported operators operators (PDF syntax).private PdfDictionaryresourcesResources for the content stream.private MatrixtextLineMatrixText line matrix.private MatrixtextMatrixText 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.Stringdecode(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 voiddisplayPdfString(PdfString string, float tj)Displays text.abstract voiddisplayText(java.lang.String text, Matrix nextTextMatrix)Displays text.MatrixgetCurrentTextLineMatrix()Returns the current line matrix.MatrixgetCurrentTextMatrix()Returns the current text matrix.private floatgetStringWidth(java.lang.String string, float tj)Gets the width of a String.GraphicsStategs()Returns the current graphics state.private voidinvokeOperator(PdfLiteral operator, java.util.ArrayList operands)Invokes an operator.private voidpopulateOperators()Loads all the supported graphics and text state operators in a map.voidprocessContent(byte[] contentBytes, PdfDictionary resources)Processes PDF syntaxvoidreset()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
-
-