Class PDFFile
- java.lang.Object
-
- com.inductiveautomation.rm.pdf.reader.PDFFile
-
public class PDFFile extends java.lang.Object
This class is used to read a PDF file for parsing.
-
-
Constructor Summary
Constructors Constructor Description PDFFile(byte[] bytes)
Creates a new PDF file for the PDF file bytes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearPageCache()
Clears the page cache.ColorFactory
getColorFactory()
FontFactory
getFontFactory()
Graphics object creation factoriesImageFactory
getImageFactory()
PDFMarkupHandler
getMarkupHandler()
The callback handlerPDFPage
getPage(int aPageIndex)
Returns an individual PDF page for the given page index.int
getPageCount()
Returns the number of PDF pages in the PDF file.PathFactory
getPathFactory()
float
getVersion()
Gets the pdf version as a float.java.lang.Object
getXRefObject(PDFXEntry anEntry)
Returns the object from the xref table, reading it if necessary.int
getXRefTablePosition()
PDF reading starts at file end - this routine starts at end and searches backwards until it finds startxref key It returns file offset to the xref table (also checks that a valid EOF is present).java.lang.Object
inheritedAttributeForKeyInPage(java.lang.String aKey, java.util.Map aPage)
Returns x.java.lang.Object
readCompressedEntry(int ostmNum, int objIndex)
void
resetXRefTable()
Call this to clear the state of all xref table entries.java.lang.Object
resolveObject(java.lang.Object obj)
Given an object, check to see if its an indirect reference - if so, resolve the reference.void
setColorFactory(ColorFactory c)
void
setFontFactory(FontFactory f)
void
setImageFactory(ImageFactory f)
void
setMarkupHandler(PDFMarkupHandler h)
void
setPathFactory(PathFactory p)
void
setStripsExtendedGStates(boolean flag)
-
-
-
Method Detail
-
getVersion
public float getVersion()
Gets the pdf version as a float.
-
getPage
public PDFPage getPage(int aPageIndex)
Returns an individual PDF page for the given page index. This function used to create a new instance every time, but it gets called repeatedly by imagereader and pageparser, so half a dozen (at least) page instances were getting created for every pdf import. This of course also defeated any useful caching behavior in the RMPDFPage.The file could be hundreds of pages big, and we're most likely only ever looking at one page. Creating a sparse array hundreds of elements large seems silly, so we'll use a map instead.
-
clearPageCache
public void clearPageCache()
Clears the page cache.
-
getPageCount
public int getPageCount()
Returns the number of PDF pages in the PDF file.
-
inheritedAttributeForKeyInPage
public java.lang.Object inheritedAttributeForKeyInPage(java.lang.String aKey, java.util.Map aPage)
Returns x.
-
getXRefTablePosition
public int getXRefTablePosition()
PDF reading starts at file end - this routine starts at end and searches backwards until it finds startxref key It returns file offset to the xref table (also checks that a valid EOF is present).
-
getXRefObject
public java.lang.Object getXRefObject(PDFXEntry anEntry)
Returns the object from the xref table, reading it if necessary.
-
resolveObject
public java.lang.Object resolveObject(java.lang.Object obj)
Given an object, check to see if its an indirect reference - if so, resolve the reference.
-
readCompressedEntry
public java.lang.Object readCompressedEntry(int ostmNum, int objIndex)
-
resetXRefTable
public void resetXRefTable()
Call this to clear the state of all xref table entries. This will allow objects created while examining the file to get garbage collected.
-
setStripsExtendedGStates
public void setStripsExtendedGStates(boolean flag)
-
getFontFactory
public FontFactory getFontFactory()
Graphics object creation factories
-
setFontFactory
public void setFontFactory(FontFactory f)
-
getPathFactory
public PathFactory getPathFactory()
-
setPathFactory
public void setPathFactory(PathFactory p)
-
getColorFactory
public ColorFactory getColorFactory()
-
setColorFactory
public void setColorFactory(ColorFactory c)
-
getImageFactory
public ImageFactory getImageFactory()
-
setImageFactory
public void setImageFactory(ImageFactory f)
-
getMarkupHandler
public PDFMarkupHandler getMarkupHandler()
The callback handler
-
setMarkupHandler
public void setMarkupHandler(PDFMarkupHandler h)
-
-