Class PDFPageParser
java.lang.Object
com.inductiveautomation.rm.pdf.reader.PDFPageParser
This class parses the page marking operators for a specific page number (it gets the
contents for that page from n RMPDFParser.) It uses the various factory objects for
graphic object creation and a MarkupHandler to do the actual drawing.
Currently unsupported: - Ignores hyperlinks (annotations) - Type 1 & Type 3 fonts - Transparency blend modes other than /Normal ...
-
Constructor Summary
ConstructorsConstructorDescriptionPDFPageParser
(PDFFile aPdfFile, int aPageIndex) Creates a new page parser for a given PDF file and a page index. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Establishes an image transform and tells markup engine to draw the imagevoid
establishClip
(GeneralPath newclip, boolean intersect) Called when the clipping path changes.void
void
static int
getPDFHexString
(byte[] pageBytes, int start, int end, com.inductiveautomation.rm.pdf.reader.Range r) Replace ascii hex in pageBytes with actual bytes.static byte[]
int
The lexer.void
parse()
Main entry point.void
The meat and potatoes of the pdf parser.int
parseInlineImage
(int tIndex, byte[] pageBytes) Converts the tokens & data inside a BI/EI block into an image and draws it.boolean
parseTextOperator
(byte oper, int tindex, int numops, PDFGState gs, byte[] pageBytes)
-
Constructor Details
-
PDFPageParser
Creates a new page parser for a given PDF file and a page index.
-
-
Method Details
-
getTokens
The lexer. Fills the tokens list from the page contents. Returns the index of the character after the last successfully consumed character. -
getPDFHexString
-
getPDFHexString
public static int getPDFHexString(byte[] pageBytes, int start, int end, com.inductiveautomation.rm.pdf.reader.Range r) Replace ascii hex in pageBytes with actual bytes. Start points to first char after the '<', end is the upper limit to seek through. r gets filled with the actual ranbge of the converted bytes return value is index of last character swallowed. See comment for getPDFString... about destructive behavior. -
parse
public void parse()Main entry point. Runs the lexer on the pdf content and passes the list of tokens to the parser. By separating out a routine that operates on the list of tokens, we can implement Forms & patterns by recursively calling the parse routine with a subset of the token list. -
parse
The meat and potatoes of the pdf parser. Translates the token list into a series of calls to either a Factory class, which creates a Java2D object (like GeneralPath, Font, Image, GlyphVector, etc.), or the markup handler, which does the actual drawing. -
executeForm
-
executePatternStream
-
parseTextOperator
-
parseInlineImage
public int parseInlineImage(int tIndex, byte[] pageBytes) Converts the tokens & data inside a BI/EI block into an image and draws it. Returns the index of the last token consumed. -
drawImage
Establishes an image transform and tells markup engine to draw the image -
establishClip
Called when the clipping path changes. The clip in the gstate is defined to be in page space. Whenever the clip is changed, we calculate the new clip, which can be intersected with the old clip, and save it in the gstate.NB. This routine modifies the path that's passed in to it.
-