public abstract class Importer extends ViewerFeature
A type of ViewerFeature
which takes care of loading a PDF file into
a PDFViewer
. Subclasses of this feature are supplied that can load
PDF documents directly (PDFImporter
) and by converting bitmap images
(ImageImporter
), and further custom loaders can be written.
Here's an example of how to load a PDF into the viewer from a file
PDFImporter importer = new PDFImporter(); Importer.ImporterTask task = importer.getImporter(viewer, file); task.start(viewer, "Loading");The
start
method will start a background thread and return immediately.
modal | If set to not null, the loading wil open a modal dialog, preventing any other actions on the viewer while loading. The default is false. |
---|---|
mostrecent | If set to not false, files loaded with this Importer will not be added to the "most recent" list. The default is "true". |
This code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.
Modifier and Type | Class and Description |
---|---|
class |
Importer.ImporterTask
This class is a
LongRunningTask that can be run to load a PDF
into the viewer. |
Modifier | Constructor and Description |
---|---|
protected |
Importer(String name)
Create a new Importer
|
Modifier and Type | Method and Description |
---|---|
boolean |
canLoad(String mimeType)
Returns true if this importer can load a file or stream of the
specified MIME Content-Type.
|
abstract FileFilter |
getFileFilter()
Get a
FileFilter that can be used to choose files
acceptable to this Importer. |
abstract Importer.ImporterTask |
getImporter(PDFViewer viewer,
File file)
Return an
Importer.ImporterTask that will load a PDF into the viewer from the specifed File. |
abstract Importer.ImporterTask |
getImporter(PDFViewer viewer,
InputStream in,
String title,
File savefile)
Return an
Importer.ImporterTask that will load a PDF into the viewer from the specifed InputStream. |
Importer.ImporterTask |
getImporter(PDFViewer viewer,
URL url)
Return an
Importer.ImporterTask that will load a PDF into the viewer from the specified URL. |
protected PDFParser |
getParser(PDF pdf)
Create a
PDFParser for the specified PDF. |
void |
initialize(PDFViewer viewer)
Called when the feature is first added to a viewer
|
boolean |
isAddToMostRecent()
Indicates whether import tasks from this importer will add the
associated file to the most recently used list.
|
protected boolean |
isPDFImporter()
Indicates whether this importer loads from a PDF document.
|
abstract boolean |
matches(File file)
Return true if this Importer can load the specified file.
|
protected void |
processPDF(PDF pdf)
Perform any processing on the PDF after it has been loaded but before
it's handed off to the viewer.
|
void |
setAddToMostRecent(boolean addToMRU)
Sets whether import tasks from this importer will add the
associated file to the most recently used list.
|
getAllEnabledFeatures, getAllFeatures, getCustomJavaScript, getFeatureProperty, getFeatureURLProperty, getName, isEnabledByDefault, setFeatureName, teardown, toString
protected Importer(String name)
name
- the name of this featurepublic void initialize(PDFViewer viewer)
ViewerFeature
initialize
in class ViewerFeature
public boolean isAddToMostRecent()
public void setAddToMostRecent(boolean addToMRU)
addToMRU
- if true, add to the listprotected boolean isPDFImporter()
public abstract FileFilter getFileFilter()
FileFilter
that can be used to choose files
acceptable to this Importer.public abstract boolean matches(File file) throws IOException
file
- the File to be checked.IOException
public boolean canLoad(String mimeType)
mimeType
- the MIME content typepublic abstract Importer.ImporterTask getImporter(PDFViewer viewer, File file)
Importer.ImporterTask
that will load a PDF into the viewer from the specifed File.viewer
- the PDFViewerfile
- the FILE to load the PDF fromImporter.ImporterTask
to load the PDFpublic abstract Importer.ImporterTask getImporter(PDFViewer viewer, InputStream in, String title, File savefile)
Importer.ImporterTask
that will load a PDF into the viewer from the specifed InputStream.viewer
- the PDFViewerin
- the InputStream to load the PDF fromtitle
- the title to give that PDF - may be nullsavefile
- if the PDF is later saved, the file to initialize the path to - may be null.Importer.ImporterTask
to load the PDFpublic Importer.ImporterTask getImporter(PDFViewer viewer, URL url) throws IOException
Importer.ImporterTask
that will load a PDF into the viewer from the specified URL.viewer
- the PDFViewerurl
- the URL to load the PDF fromImporter.ImporterTask
to load the PDFIOException
protected void processPDF(PDF pdf)
protected PDFParser getParser(PDF pdf)
PDFParser
for the specified PDF. By default
this method simply returns new PDFParser(pdf)
-
if necessary this can be overridden to return a custom subclass
of PDFParser.pdf
- the PDFCopyright © 2001-2017 Big Faceless Organization