public class MCParser extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
MCParser.PdfOperator
PDF Operator interface.
|
Modifier and Type | Field and Description |
---|---|
protected PdfArray |
annots
the annotations of the page that is being processed.
|
protected ByteArrayOutputStream |
baos
The contents of the new content stream of the page.
|
protected boolean |
btWrite
Did we postpone writing a BT operator?
|
static String |
DEFAULTOPERATOR
Constant used for the default operator.
|
protected boolean |
etExtra
Did we postpone writing a BT operator?
|
protected boolean |
inText
Are we inside a BT/ET sequence?
|
protected StructureItems |
items
The list with structure items.
|
protected static Logger |
LOGGER
The Logger instance
|
protected Map<String,MCParser.PdfOperator> |
operators
A map with all supported operators operators (PDF syntax).
|
protected PdfDictionary |
page
The page dictionary
|
protected PdfIndirectReference |
pageref
The reference to the page dictionary
|
protected static RandomAccessSourceFactory |
RASFACTORY
Factory that will help us build a RandomAccessSource.
|
protected PdfNumber |
structParents
the StructParents of the page that is being processed.
|
protected StringBuffer |
text
A buffer containing text state.
|
static PdfLiteral |
TSTAR
A new line operator
|
protected PdfDictionary |
xobjects
the XObject dictionary of the page that is being processed.
|
Constructor and Description |
---|
MCParser(StructureItems items)
Creates an MCParser object.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkBT()
Checks if a BT operator is waiting to be added.
|
protected void |
convertToXObject(StructureObject item)
Converts an annotation structure item to a Form XObject annotation.
|
protected void |
dealWithMcid(PdfNumber mcid)
When an MCID is encountered, the parser will check the list structure items and turn an annotation into an XObject if necessary.
|
protected void |
dealWithXObj(PdfName xobj)
When an XObject with a StructParent is encountered, we want to remove it from the stack.
|
void |
parse(PdfDictionary page, PdfIndirectReference pageref)
Parses the content of a page, inserting the normal (/N) appearances (/AP) of annotations into the content stream as Form XObjects.
|
protected void |
populateOperators()
Populates the operators variable.
|
protected void |
println(PdfObject o)
Writes a PDF object to the OutputStream, followed by a newline character.
|
protected void |
printOperator(PdfLiteral operator, List<PdfObject> operands)
Adds an operator and its operands (if any) to baos.
|
protected void |
printsp(PdfObject o)
Writes a PDF object to the OutputStream, followed by a space character.
|
protected void |
printTextOperator(PdfLiteral operator, List<PdfObject> operands)
Adds an operator and its operands (if any) to baos, keeping track of the text state.
|
protected void |
processOperator(PdfLiteral operator, List<PdfObject> operands)
Processes an operator, for instance: write the operator and its operands to baos.
|
protected void |
setInText(boolean inText)
Informs the parser that we're inside or outside a text object.
|
protected static final Logger LOGGER
protected static final RandomAccessSourceFactory RASFACTORY
public static final String DEFAULTOPERATOR
public static final PdfLiteral TSTAR
protected Map<String,MCParser.PdfOperator> operators
protected StructureItems items
protected ByteArrayOutputStream baos
protected PdfDictionary page
protected PdfIndirectReference pageref
protected PdfArray annots
protected PdfNumber structParents
protected PdfDictionary xobjects
protected boolean btWrite
protected boolean etExtra
protected boolean inText
protected StringBuffer text
public MCParser(StructureItems items)
items
- a list of StructureItem objects
protected void populateOperators()
public void parse(PdfDictionary page, PdfIndirectReference pageref) throws IOException, DocumentException
page
- a page dictionary
pageref
- the reference to the page dictionary
finalPage
- indicates whether the page being processed is the final page in the document
IOException
DocumentException
protected void dealWithXObj(PdfName xobj)
xobj
- the name of an XObject
protected void dealWithMcid(PdfNumber mcid) throws IOException, DocumentException
mcid
- the MCID that was encountered in the content stream
IOException
DocumentException
protected void convertToXObject(StructureObject item) throws IOException, DocumentException
item
- the structure item
IOException
DocumentException
protected void processOperator(PdfLiteral operator, List<PdfObject> operands) throws IOException, DocumentException
operator
- the operator
operands
- the operator's operands
IOException
DocumentException
protected void printOperator(PdfLiteral operator, List<PdfObject> operands) throws IOException
operator
- the operator
operands
- its operands
IOException
protected void printTextOperator(PdfLiteral operator, List<PdfObject> operands) throws IOException
operator
- the operator
operands
- its operands
IOException
protected void printsp(PdfObject o) throws IOException
o
- a PdfObject
IOException
protected void println(PdfObject o) throws IOException
o
- a PdfObject
IOException
protected void checkBT() throws IOException
IOException
protected void setInText(boolean inText)
inText
- true if we're inside.
Copyright © 2016. All rights reserved.