Class PdfCanvasParser
- java.lang.Object
-
- com.itextpdf.kernel.pdf.canvas.parser.util.PdfCanvasParser
-
public class PdfCanvasParser extends java.lang.ObjectParses the page or form XObject content.
-
-
Field Summary
Fields Modifier and Type Field Description private PdfResourcescurrentResourcesprivate PdfTokenizertokeniserHolds value of property tokeniser.
-
Constructor Summary
Constructors Constructor Description PdfCanvasParser(PdfTokenizer tokeniser)Creates a new instance of PdfContentParserPdfCanvasParser(PdfTokenizer tokeniser, PdfResources currentResources)Creates a new instance of PdfContentParser
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PdfTokenizergetTokeniser()Gets the tokeniser.booleannextValidToken()Reads the next token skipping over the comments.java.util.List<PdfObject>parse(java.util.List<PdfObject> ls)Parses a single command from the content.PdfArrayreadArray()Reads an array.PdfDictionaryreadDictionary()Reads a dictionary.PdfObjectreadObject()Reads a pdf object.voidsetTokeniser(PdfTokenizer tokeniser)Sets the tokeniser.
-
-
-
Field Detail
-
tokeniser
private PdfTokenizer tokeniser
Holds value of property tokeniser.
-
currentResources
private PdfResources currentResources
-
-
Constructor Detail
-
PdfCanvasParser
public PdfCanvasParser(PdfTokenizer tokeniser)
Creates a new instance of PdfContentParser- Parameters:
tokeniser- the tokeniser with the content
-
PdfCanvasParser
public PdfCanvasParser(PdfTokenizer tokeniser, PdfResources currentResources)
Creates a new instance of PdfContentParser- Parameters:
tokeniser- the tokeniser with the contentcurrentResources- current resources of the content stream. It is optional parameter, which is used for performance improvements of specific cases of inline images parsing.
-
-
Method Detail
-
parse
public java.util.List<PdfObject> parse(java.util.List<PdfObject> ls) throws java.io.IOException
Parses a single command from the content. Each command is output as an array of arguments having the command itself as the last element. The returned array will be empty if the end of content was reached.
A specific behaviour occurs when inline image is encountered (BI command): in that case, parser would continue parsing until it meets EI - end of the inline image; as a result in this case it will return an array with inline image dictionary and image bytes encapsulated in PdfStream object as first element and EI command as second element.- Parameters:
ls- anArrayListto use. It will be cleared before using. If it'snullwill create a newArrayList- Returns:
- the same
ArrayListgiven as argument or a new one - Throws:
java.io.IOException- on error
-
getTokeniser
public PdfTokenizer getTokeniser()
Gets the tokeniser.- Returns:
- the tokeniser.
-
setTokeniser
public void setTokeniser(PdfTokenizer tokeniser)
Sets the tokeniser.- Parameters:
tokeniser- the tokeniser
-
readDictionary
public PdfDictionary readDictionary() throws java.io.IOException
Reads a dictionary. The tokeniser must be positioned past the "<<" token.- Returns:
- the dictionary
- Throws:
java.io.IOException- on error
-
readArray
public PdfArray readArray() throws java.io.IOException
Reads an array. The tokeniser must be positioned past the "[" token.- Returns:
- an array
- Throws:
java.io.IOException- on error
-
readObject
public PdfObject readObject() throws java.io.IOException
Reads a pdf object.- Returns:
- the pdf object
- Throws:
java.io.IOException- on error
-
nextValidToken
public boolean nextValidToken() throws java.io.IOExceptionReads the next token skipping over the comments.- Returns:
trueif a token was read,falseif the end of content was reached- Throws:
java.io.IOException- on error
-
-