Class PdfCanvasParser
java.lang.Object
com.itextpdf.kernel.pdf.canvas.parser.util.PdfCanvasParser
Parses the page or form XObject content.
-
Constructor Summary
ConstructorDescriptionPdfCanvasParser
(PdfTokenizer tokeniser) Creates a new instance of PdfContentParserPdfCanvasParser
(PdfTokenizer tokeniser, PdfResources currentResources) Creates a new instance of PdfContentParser -
Method Summary
Modifier and TypeMethodDescriptionGets the tokeniser.boolean
Reads the next token skipping over the comments.Parses a single command from the content.Reads an array.Reads a dictionary.Reads a pdf object.void
setTokeniser
(PdfTokenizer tokeniser) Sets the tokeniser.
-
Constructor Details
-
PdfCanvasParser
Creates a new instance of PdfContentParser- Parameters:
-
tokeniser
- the tokeniser with the content
-
PdfCanvasParser
Creates a new instance of PdfContentParser- Parameters:
-
tokeniser
- the tokeniser with the content -
currentResources
- current resources of the content stream. It is optional parameter, which is used for performance improvements of specific cases of inline images parsing.
-
-
Method Details
-
parse
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
- anArrayList
to use. It will be cleared before using. If it'snull
will create a newArrayList
- Returns:
-
the same
ArrayList
given as argument or a new one - Throws:
-
IOException
- on error
-
getTokeniser
Gets the tokeniser.- Returns:
- the tokeniser.
-
setTokeniser
Sets the tokeniser.- Parameters:
-
tokeniser
- the tokeniser
-
readDictionary
Reads a dictionary. The tokeniser must be positioned past the "<<" token.- Returns:
- the dictionary
- Throws:
-
IOException
- on error
-
readArray
Reads an array. The tokeniser must be positioned past the "[" token.- Returns:
- an array
- Throws:
-
IOException
- on error
-
readObject
Reads a pdf object.- Returns:
- the pdf object
- Throws:
-
IOException
- on error
-
nextValidToken
Reads the next token skipping over the comments.- Returns:
-
true
if a token was read,false
if the end of content was reached - Throws:
-
IOException
- on error
-