Class PDFParser

All Implemented Interfaces:
Watchable, Runnable

public class PDFParser extends BaseWatchable
PDFParser is the class that parses a PDF content stream and produces PDFCmds for a PDFPage. You should never ever see it run: it gets created by a PDFPage only if needed, and may even run in its own thread.
Author:
Mike Wessler
  • Field Details

    • DEBUG_DCTDECODE_DATA

      public static final String DEBUG_DCTDECODE_DATA
      emit a file of DCT stream data.
      See Also:
    • debuglevel

      public static int debuglevel
  • Constructor Details

    • PDFParser

      public PDFParser(PDFPage cmds, byte[] stream, HashMap<String, PDFObject> resources)
      Don't call this constructor directly. Instead, use PDFFile.getPage(int pagenum) to get a PDFPage. There should never be any reason for a user to create, access, or hold on to a PDFParser.
  • Method Details

    • debug

      public static void debug(String msg, int level)
    • escape

      public static String escape(String msg)
    • setDebugLevel

      public static void setDebugLevel(int level)
    • setup

      public void setup()
      Called to prepare for some iterations
      Overrides:
      setup in class BaseWatchable
    • iterate

      public int iterate() throws Exception
      parse the stream. commands are added to the PDFPage initialized in the constructor as they are encountered.

      Page numbers in comments refer to the Adobe PDF specification.
      commands are listed in PDF spec 32000-1:2008 in Table A.1

      Specified by:
      iterate in class BaseWatchable
      Returns:
      • Watchable.RUNNING when there are commands to be processed
      • Watchable.COMPLETED when the page is done and all the commands have been processed
      • Watchable.STOPPED if the page we are rendering into is no longer available
      Throws:
      Exception
    • cleanup

      public void cleanup()
      Cleanup when iteration is done
      Overrides:
      cleanup in class BaseWatchable
    • dumpStreamToError

      public void dumpStreamToError()
    • dumpStream

      public String dumpStream()
    • emitDataFile

      public static void emitDataFile(byte[] ary, String name)
      take a byte array and write a temporary file with it's data. This is intended to capture data for analysis, like after decoders.
      Parameters:
      ary -
      name -