public class PdfContentStreamProcessor extends Object
Modifier and Type | Class and Description |
---|---|
private static class |
PdfContentStreamProcessor.BeginMarkedContent
A content operator implementation (BMC).
|
private static class |
PdfContentStreamProcessor.BeginMarkedContentDictionary
A content operator implementation (BDC).
|
private static class |
PdfContentStreamProcessor.BeginText
A content operator implementation (BT).
|
private static class |
PdfContentStreamProcessor.Do
A content operator implementation (Do).
|
private static class |
PdfContentStreamProcessor.EndMarkedContent
A content operator implementation (BMC).
|
private static class |
PdfContentStreamProcessor.EndText
A content operator implementation (ET).
|
private static class |
PdfContentStreamProcessor.FormXObjectDoHandler
An XObject subtype handler for FORM
|
private static class |
PdfContentStreamProcessor.IgnoreOperatorContentOperator
A content operator implementation (unregistered).
|
private static class |
PdfContentStreamProcessor.IgnoreXObjectDoHandler
An XObject subtype handler that does nothing
|
private static class |
PdfContentStreamProcessor.ImageXObjectDoHandler
An XObject subtype handler for IMAGE
|
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.ResourceDictionary
A resource dictionary that allows stack-like behavior to support resource dictionary inheritance
|
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).
|
Modifier and Type | Field and Description |
---|---|
private Map<Integer,CMapAwareDocumentFont> |
cachedFonts |
static String |
DEFAULTOPERATOR
Default operator
|
private Stack<GraphicsState> |
gsStack
Stack keeping track of the graphics state.
|
private Stack<MarkedContentInfo> |
markedContentStack
A stack containing marked content info.
|
private Map<String,ContentOperator> |
operators
A map with all supported operators operators (PDF syntax).
|
private RenderListener |
renderListener
Listener that will be notified of render events
|
private PdfContentStreamProcessor.ResourceDictionary |
resources
Resources for the content stream.
|
private Matrix |
textLineMatrix
Text line matrix.
|
private Matrix |
textMatrix
Text matrix.
|
private Map<PdfName,XObjectDoHandler> |
xobjectDoHandlers
A map with all supported XObject handlers
|
Constructor and Description |
---|
PdfContentStreamProcessor(RenderListener renderListener)
Creates a new PDF Content Stream Processor that will send it's output to the
designated render listener.
|
Modifier and Type | Method and Description |
---|---|
private void |
applyTextAdjust(float tj)
Adjusts the text matrix for the specified adjustment value (see TJ operator in the PDF spec for information)
|
private void |
beginMarkedContent(PdfName tag,
PdfDictionary dict)
Add to the marked content stack
|
private void |
beginText()
Used to trigger beginTextBlock on the renderListener
|
private 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
|
private void |
displayPdfString(PdfString string)
Displays text.
|
private void |
displayXObject(PdfName xobjectName)
Displays an XObject using the registered handler for this XObject's subtype
|
private void |
endMarkedContent()
Remove the latest marked content from the stack.
|
private void |
endText()
Used to trigger endTextBlock on the renderListener
|
CMapAwareDocumentFont |
getFont(PRIndirectReference ind)
Gets the font pointed to by the indirect reference.
|
private GraphicsState |
gs()
Returns the current graphics state.
|
private void |
invokeOperator(PdfLiteral operator,
ArrayList<PdfObject> operands)
Invokes an operator.
|
private void |
populateOperators()
Loads all the supported graphics and text state operators in a map.
|
private void |
populateXObjectDoHandlers() |
void |
processContent(byte[] contentBytes,
PdfDictionary resources)
Processes PDF syntax
|
ContentOperator |
registerContentOperator(String operatorString,
ContentOperator operator)
Registers a content operator that will be called when the specified operator string is encountered during content processing.
|
XObjectDoHandler |
registerXObjectDoHandler(PdfName xobjectSubType,
XObjectDoHandler handler)
Registers a Do handler that will be called when Do for the provided XObject subtype is encountered during content processing.
|
void |
reset()
Resets the graphics state stack, matrices and resources.
|
public static final String DEFAULTOPERATOR
private final Map<String,ContentOperator> operators
private PdfContentStreamProcessor.ResourceDictionary resources
private final Stack<GraphicsState> gsStack
private Matrix textMatrix
private Matrix textLineMatrix
private final RenderListener renderListener
private final Map<PdfName,XObjectDoHandler> xobjectDoHandlers
private final Map<Integer,CMapAwareDocumentFont> cachedFonts
private final Stack<MarkedContentInfo> markedContentStack
public PdfContentStreamProcessor(RenderListener renderListener)
renderListener
- the RenderListener
that will receive rendering notificationsprivate void populateXObjectDoHandlers()
public XObjectDoHandler registerXObjectDoHandler(PdfName xobjectSubType, XObjectDoHandler handler)
xobjectSubType
- the XObject subtype this handler will process, or PdfName.DEFAULT for a catch-all handlerhandler
- the handler that will receive notification when the Do operator for the specified subtype is encounteredpublic CMapAwareDocumentFont getFont(PRIndirectReference ind)
ind
- the indirect reference ponting to the fontprivate void populateOperators()
public ContentOperator registerContentOperator(String operatorString, ContentOperator operator)
operatorString
- the operator id, or DEFAULTOPERATOR for a catch-all operatoroperator
- the operator that will receive notification when the operator is encounteredpublic void reset()
private GraphicsState gs()
private void invokeOperator(PdfLiteral operator, ArrayList<PdfObject> operands) throws Exception
operator
- the PDF Syntax of the operatoroperands
- a list with operandsException
private void beginMarkedContent(PdfName tag, PdfDictionary dict)
tag
- the tag of the marked contentdict
- the PdfDictionary associated with the marked contentprivate void endMarkedContent()
private String decode(PdfString in)
in
- the String that needs to be encodedprivate void beginText()
private void endText()
private void displayPdfString(PdfString string)
string
- the text to displayprivate void displayXObject(PdfName xobjectName) throws IOException
xobjectName
- the name of the XObject to retrieve from the resource dictionaryIOException
private void applyTextAdjust(float tj)
tj
- the text adjustmentpublic void processContent(byte[] contentBytes, PdfDictionary resources)
contentBytes
- the bytes of a content streamresources
- the resources that come with the content streamWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses