Top Description Fields Constructors Methods
com.dlsc.pdfviewfx

public Class PDFBoxDocument

extends Object
implements SearchableDocument
Class Inheritance
All Implemented Interfaces
com.dlsc.pdfviewfx.PDFView.SearchableDocument, com.dlsc.pdfviewfx.PDFView.Document
Imports
com.dlsc.pdfviewfx.PDFView.Document, .PDFView.SearchableDocument, javafx.geometry.Rectangle2D, org.apache.commons.lang3.StringUtils, org.apache.pdfbox.Loader, org.apache.pdfbox.io.RandomAccessReadBufferedFile, org.apache.pdfbox.pdmodel.PDDocument, .PDPage, org.apache.pdfbox.pdmodel.common.PDRectangle, org.apache.pdfbox.printing.PDFPageable, org.apache.pdfbox.rendering.ImageType, .PDFRenderer, .RenderDestination, org.apache.pdfbox.text.PDFTextStripper, .TextPosition, java.awt.image.BufferedImage, java.awt.print.Pageable, java.io.File, .IOException, .InputStream, .Writer, java.util.ArrayList, .List

An implementation of Document for the Apache PDFBox library.
See Also
PDFView#setDocument(Document)

Field Summary

Modifier and TypeField and Description
private final PDDocument

Constructor Summary

AccessConstructor and Description
public
PDFBoxDocument(InputStream pdfInputStream)

public

Method Summary

Modifier and TypeMethod and Description
private Rectangle2D
calculateMarkerPosition(String searchText, String snippetText, List<TextPosition> textPositions)

private int
calculateTextPositionStartIndex(String searchText, String snippetText, List<TextPosition> textPositions)

Note that the number of textPositions might not be equal to the length of the snippetText.

public void
close()

Implements com.dlsc.pdfviewfx.PDFView.Document.close.

Closes the document.

public int
getNumberOfPages()

Implements com.dlsc.pdfviewfx.PDFView.Document.getNumberOfPages.

Returns the total number of pages inside the document.

public Pageable
getPageable()

Implements com.dlsc.pdfviewfx.PDFView.Document.getPageable.

Returns a set of pages to be printed.

public List<PDFView.SearchResult>
getSearchResults(String
the text for which to search
searchText
)

Implements com.dlsc.pdfviewfx.PDFView.SearchableDocument.getSearchResults.

Returns the list of search results for the given search text.

public boolean
isLandscape(int
the page
pageNumber
)

Implements com.dlsc.pdfviewfx.PDFView.Document.isLandscape.

Determines if the given page has a landscape orientation.

public BufferedImage
renderPage(int
the page number
pageNumber
,
float
the scale
scale
)

Implements com.dlsc.pdfviewfx.PDFView.Document.renderPage.

Renders the page specified by the given number at the given scale.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

documentback to summary
private final PDDocument document

Constructor Detail

PDFBoxDocumentback to summary
public PDFBoxDocument(InputStream pdfInputStream)
PDFBoxDocumentback to summary
public PDFBoxDocument(File file) throws IOException

Method Detail

calculateMarkerPositionback to summary
private Rectangle2D calculateMarkerPosition(String searchText, String snippetText, List<TextPosition> textPositions)
calculateTextPositionStartIndexback to summary
private int calculateTextPositionStartIndex(String searchText, String snippetText, List<TextPosition> textPositions)

Note that the number of textPositions might not be equal to the length of the snippetText. So we need to account for that.

See: org.apache.pdfbox.text.PDFTextStripper.WordWithTextPositions

closeback to summary
public void close()

Implements com.dlsc.pdfviewfx.PDFView.Document.close.

Doc from com.dlsc.pdfviewfx.PDFView.Document.close.

Closes the document.

Annotations
@Override
getNumberOfPagesback to summary
public int getNumberOfPages()

Implements com.dlsc.pdfviewfx.PDFView.Document.getNumberOfPages.

Doc from com.dlsc.pdfviewfx.PDFView.Document.getNumberOfPages.

Returns the total number of pages inside the document.

Returns:int

the total number of pages

Annotations
@Override
getPageableback to summary
public Pageable getPageable()

Implements com.dlsc.pdfviewfx.PDFView.Document.getPageable.

Doc from com.dlsc.pdfviewfx.PDFView.Document.getPageable.

Returns a set of pages to be printed.

Returns:Pageable

a set of pages to be printed

Annotations
@Override
getSearchResultsback to summary
public List<PDFView.SearchResult> getSearchResults(String searchText)

Implements com.dlsc.pdfviewfx.PDFView.SearchableDocument.getSearchResults.

Doc from com.dlsc.pdfviewfx.PDFView.SearchableDocument.getSearchResults.

Returns the list of search results for the given search text.

Parameters
searchText:String

the text for which to search

Returns:List<PDFView.SearchResult>

the list of search results

Annotations
@Override
isLandscapeback to summary
public boolean isLandscape(int pageNumber)

Implements com.dlsc.pdfviewfx.PDFView.Document.isLandscape.

Doc from com.dlsc.pdfviewfx.PDFView.Document.isLandscape.

Determines if the given page has a landscape orientation.

Parameters
pageNumber:int

the page

Returns:boolean

true if the page has to be shown in landscape mode

Annotations
@Override
renderPageback to summary
public BufferedImage renderPage(int pageNumber, float scale)

Implements com.dlsc.pdfviewfx.PDFView.Document.renderPage.

Doc from com.dlsc.pdfviewfx.PDFView.Document.renderPage.

Renders the page specified by the given number at the given scale.

Parameters
pageNumber:int

the page number

scale:float

the scale

Returns:BufferedImage

the generated buffered image

Annotations
@Override