Package org.loboevolution.pdfview
Class PDFFile
java.lang.Object
org.loboevolution.pdfview.PDFFile
An encapsulation of a .pdf file. The methods of this class
can parse the contents of a PDF file, but those methods are
hidden. Instead, the public methods of this class allow
access to the pages in the PDF file. Typically, you create
a new PDFFile, ask it for the number of pages, and then
request one or more PDFPages.
Author Mike Wessler
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPDFFile
(ByteBuffer buf) get a PDFFile from a .pdf file.PDFFile
(ByteBuffer buf, boolean doNotParse) Constructor for PDFFile.PDFFile
(ByteBuffer buf, PDFPassword password) get a PDFFile from a .pdf file. -
Method Summary
Modifier and TypeMethodDescriptiondereference
(PDFXref ref, PDFDecrypter decrypter) Used internally to track down PDFObject references.int
return the number of pages in this PDFFile.Gets the outline tree as a tree of OutlineNode, which is a subclass of DefaultMutableTreeNode.getPage
(int pagenum) Get the page commands for a given page in a separate thread.getPage
(int pagenum, boolean wait) Get the page commands for a given page.int
getPageNumber
(PDFObject page) Gets the page number (starting from 1) of the page represented by a particular PDFObject.static boolean
isDelimiter
(int c) Is the argument a delimiter according to the PDF spec?static boolean
isRegularCharacter
(int c) return true if the character is neither a whitespace or a delimiter.static boolean
isWhiteSpace
(int c) Is the argument a white space character according to the PDF spec?.static Rectangle2D
parseNormalisedRectangle.void
stop
(int pageNum) Stop the rendering of a particular image on this page
-
Field Details
-
NUL_CHAR
public static final int NUL_CHARConstantNUL_CHAR=0
- See Also:
-
FF_CHAR
public static final int FF_CHARConstantFF_CHAR=12
- See Also:
-
-
Constructor Details
-
PDFFile
get a PDFFile from a .pdf file. The file must me a random access file at the moment. It should really be a file mapping from the nio package.Use the getPage(...) methods to get a page from the PDF file.
- Parameters:
buf
- the RandomAccessFile containing the PDF.- Throws:
IOException
- if any.
-
PDFFile
Constructor for PDFFile.
- Parameters:
buf
- aByteBuffer
object.doNotParse
- a boolean.- Throws:
IOException
- if any.
-
PDFFile
get a PDFFile from a .pdf file. The file must me a random access file at the moment. It should really be a file mapping from the nio package.Use the getPage(...) methods to get a page from the PDF file.
- Parameters:
buf
- the RandomAccessFile containing the PDF.password
- the user or owner password- Throws:
IOException
- if any.
-
-
Method Details
-
isWhiteSpace
public static boolean isWhiteSpace(int c) Is the argument a white space character according to the PDF spec?. ISO Spec 32000-1:2008 - Table 1- Parameters:
c
- aInteger
object.- Returns:
- a boolean.
-
isDelimiter
public static boolean isDelimiter(int c) Is the argument a delimiter according to the PDF spec?ISO 32000-1:2008 - Table 2
- Parameters:
c
- the character to test- Returns:
- a boolean.
-
isRegularCharacter
public static boolean isRegularCharacter(int c) return true if the character is neither a whitespace or a delimiter.- Parameters:
c
- the character to test- Returns:
- boolean
-
parseNormalisedRectangle
parseNormalisedRectangle.
- Parameters:
obj
- aPDFObject
object.- Returns:
- a
Rectangle2D
object. - Throws:
IOException
- if any.
-
getNumPages
public int getNumPages()return the number of pages in this PDFFile. The pages will be numbered from 1 to getNumPages(), inclusive.- Returns:
- a
Integer
object.
-
dereference
Used internally to track down PDFObject references. You should never need to call this.Since this is the only public method for tracking down PDF objects, it is synchronized. This means that the PDFFile can only hunt down one object at a time, preventing the file's location from getting messed around.
This call stores the current buffer position before any changes are made and restores it afterwards, so callers need not know that the position has changed.
- Parameters:
ref
- aPDFXref
object.decrypter
- aPDFDecrypter
object.- Returns:
- a
PDFObject
object. - Throws:
IOException
- if any.
-
getOutline
Gets the outline tree as a tree of OutlineNode, which is a subclass of DefaultMutableTreeNode. If there is no outline tree, this method returns null.- Returns:
- a
OutlineNode
object. - Throws:
IOException
- if any.
-
getPageNumber
Gets the page number (starting from 1) of the page represented by a particular PDFObject. The PDFObject must be a Page dictionary or a destination description (or an action).- Parameters:
page
- aPDFObject
object.- Returns:
- a number between 1 and the number of pages indicating the page number, or 0 if the PDFObject is not in the page tree.
- Throws:
IOException
- if any.
-
getPage
Get the page commands for a given page in a separate thread.- Parameters:
pagenum
- the number of the page to get commands for- Returns:
- a
PDFPage
object.
-
getPage
Get the page commands for a given page.- Parameters:
pagenum
- the number of the page to get commands forwait
- if true, do not exit until the page is complete.- Returns:
- a
PDFPage
object.
-
stop
public void stop(int pageNum) Stop the rendering of a particular image on this page- Parameters:
pageNum
- aInteger
object.
-