public class PDFImporter extends Importer
A subclass of Importer
that allows PDF files to be loaded
into the viewer. This feature is essential for regular operation
of the Viewer - if not included in the list of features passed
into the PDFViewer
constructor, it will be added automatically.
To customize the list of EncryptionHandler
s used when loading a
PDF, this class can be altered. For example, to always use a specific
password when loading a PDF you could do the following.
// First, get rid of the default PDFImporter from the list Collection features = new ArrayList(ViewerFeature.getDefaultFeatures()); for (Iterator i = features.iterator();i.hasNext();) { if (i.next() instanceof PDFImporter) { i.remove(); } } // Next, create a new PDFImporter and set its EncryptionHandler PDFImporter importer = new PDFImporter(); Set handlers = importer.getEncryptionHandlers(); handlers.clear(); StandardEncryptionHandler pwhandler = new StandardEncryptionHandler(); pwhandler.setUserPassword("secret"); handlers.add(pwhandler); // Add that feature to the list and pass it into the PDFViewer features.add(importer); PDFViewer viewer = new PDFViewer(features);
useInputStream | If set to 'true' the setUseInputStream(boolean) method will be called with true as an argument. |
---|
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.
Importer.ImporterTask
Constructor and Description |
---|
PDFImporter()
Create a new PDFImporter
|
Modifier and Type | Method and Description |
---|---|
boolean |
canLoad(String mimeType)
This importer can load the "application/pdf" MIME type.
|
Set<EncryptionHandler> |
getEncryptionHandlers()
Return the set of
EncryptionHandler objects used to possibly decrypt
PDF files loaded with this Importer. |
FileFilter |
getFileFilter()
Get a
FileFilter that can be used to choose files
acceptable to this Importer. |
Importer.ImporterTask |
getImporter(PDFViewer viewer,
File file)
Return an
Importer.ImporterTask that will load a PDF into the viewer from the specifed File. |
Importer.ImporterTask |
getImporter(PDFViewer viewer,
InputStream in,
String title,
File file)
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. |
void |
initialize(PDFViewer viewer)
Called when the feature is first added to a viewer
|
boolean |
matches(File file)
Return true if this Importer can load the specified file.
|
void |
setUseInputStream(boolean stream)
When opening a PDF from a File, this flag determines whether
to open the PDF using the
File
constructor or InputStream
PDFReader constructor. |
getParser, isAddToMostRecent, isPDFImporter, processPDF, setAddToMostRecent
getAllEnabledFeatures, getAllFeatures, getCustomJavaScript, getFeatureProperty, getFeatureURLProperty, getName, isEnabledByDefault, setFeatureName, teardown, toString
public void initialize(PDFViewer viewer)
ViewerFeature
initialize
in class Importer
public FileFilter getFileFilter()
Importer
FileFilter
that can be used to choose files
acceptable to this Importer.getFileFilter
in class Importer
public boolean matches(File file) throws IOException
Importer
matches
in class Importer
file
- the File to be checked.IOException
public boolean canLoad(String mimeType)
public Set<EncryptionHandler> getEncryptionHandlers()
EncryptionHandler
objects used to possibly decrypt
PDF files loaded with this Importer. This set may be altered.public void setUseInputStream(boolean stream)
File
constructor or InputStream
PDFReader constructor.stream
- whether to load PDF files from a FileInputStream (true) or a File (false)public Importer.ImporterTask getImporter(PDFViewer viewer, File file)
Importer
Importer.ImporterTask
that will load a PDF into the viewer from the specifed File.getImporter
in class Importer
viewer
- the PDFViewerfile
- the FILE to load the PDF fromImporter.ImporterTask
to load the PDFpublic Importer.ImporterTask getImporter(PDFViewer viewer, InputStream in, String title, File file)
Importer
Importer.ImporterTask
that will load a PDF into the viewer from the specifed InputStream.getImporter
in class Importer
viewer
- the PDFViewerin
- the InputStream to load the PDF fromtitle
- the title to give that PDF - may be nullfile
- 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
Importer.ImporterTask
that will load a PDF into the viewer from the specified URL.getImporter
in class Importer
viewer
- the PDFViewerurl
- the URL to load the PDF fromImporter.ImporterTask
to load the PDFIOException
Copyright © 2001-2017 Big Faceless Organization