Class PDFPageParser

java.lang.Object
com.inductiveautomation.rm.pdf.reader.PDFPageParser

public class PDFPageParser extends Object
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 Details

    • PDFPageParser

      public PDFPageParser(PDFFile aPdfFile, int aPageIndex)
      Creates a new page parser for a given PDF file and a page index.
  • Method Details

    • getTokens

      public int getTokens(byte[] pageBytes, int offset, int end, List tokens)
      The lexer. Fills the tokens list from the page contents. Returns the index of the character after the last successfully consumed character.
    • getPDFHexString

      public static byte[] getPDFHexString(String s)
    • 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

      public void parse(List tokenList, byte[] pageBytes)
      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

      public void executeForm(PDFForm f)
    • executePatternStream

      public void executePatternStream(TilingPattern pat)
    • parseTextOperator

      public boolean parseTextOperator(byte oper, int tindex, int numops, PDFGState gs, byte[] pageBytes)
    • 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

      public void drawImage(Image im)
      Establishes an image transform and tells markup engine to draw the image
    • establishClip

      public void establishClip(GeneralPath newclip, boolean intersect)
      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.