Package org.faceless.pdf2.viewer2
Class Exporter
- java.lang.Object
-
- org.faceless.pdf2.viewer2.ViewerFeature
-
- org.faceless.pdf2.viewer2.Exporter
-
- Direct Known Subclasses:
PDFExporter
,TextExporter
,TIFFExporter
public abstract class Exporter extends ViewerFeature
A type ofViewerFeature
which allows PDF's to be saved in a variety of formats. It's chiefly used with theSave
widget, although it can be used in other contexts if necessary.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.
- Since:
- 2.10.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Exporter.ExporterTask
This class is aLongRunningTask
that can be run to save a PDF to an OutputStream.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
completed()
Called when the save has completed - by default, a no-op.JComponent
getComponent()
Deprecated.Subclasses should overridegetComponent(DocumentPanel,File)
insteadJComponent
getComponent(DocumentPanel panel, File file)
Return a JComponent which prompts the user for additional information after the initial save dialog.abstract Exporter.ExporterTask
getExporter(DocumentPanel panel, PDF pdf, JComponent component, OutputStream out)
Return a newExporter.ExporterTask
that would save a PDFabstract FileFilter
getFileFilter()
Get a FileFilter that matches the Files output by this Exporterabstract String
getFileSuffix()
Return the suffix of files normally output by this Exporter, such as "pdf", "tif", "jpg" etc.boolean
isEnabled(DocumentPanel docpanel)
Return true if this Exporter should be available for this DocumentPanel.void
postProcessPDF(PDF pdf)
Called byExporter.ExporterTask.savePDF()
just after the PDF is saved, you can override this method for custom processing.void
preProcessPDF(PDF pdf)
Called byExporter.ExporterTask.savePDF()
just before the PDF is saved, you can override this method for custom processing.String
validateComponent(JComponent comp)
Given the component returned bygetComponent(org.faceless.pdf2.viewer2.DocumentPanel, java.io.File)
, returnnull
if the values are valid or an error message if they're invalid.-
Methods inherited from class org.faceless.pdf2.viewer2.ViewerFeature
getAllEnabledFeatures, getAllFeatures, getCustomJavaScript, getFeatureProperty, getFeatureURLProperty, getName, initialize, isEnabledByDefault, setFeatureName, teardown, toString
-
-
-
-
Constructor Detail
-
Exporter
public Exporter(String name)
Create a new Exporter- Parameters:
name
- the name of the feature
-
-
Method Detail
-
getFileFilter
public abstract FileFilter getFileFilter()
Get a FileFilter that matches the Files output by this Exporter
-
getFileSuffix
public abstract String getFileSuffix()
Return the suffix of files normally output by this Exporter, such as "pdf", "tif", "jpg" etc.
-
isEnabled
public boolean isEnabled(DocumentPanel docpanel)
Return true if this Exporter should be available for this DocumentPanel. The default implementation always returns true.- Since:
- 2.10.3
-
getExporter
public abstract Exporter.ExporterTask getExporter(DocumentPanel panel, PDF pdf, JComponent component, OutputStream out)
Return a newExporter.ExporterTask
that would save a PDF- Parameters:
panel
- the DocumentPanel this PDF is being saved from - may be nullpdf
- the PDF being saves (not null)component
- the JComponent returned bygetComponent(org.faceless.pdf2.viewer2.DocumentPanel, java.io.File)
out
- the OutputStream to write the PDF to
-
getComponent
public JComponent getComponent(DocumentPanel panel, File file)
Return a JComponent which prompts the user for additional information after the initial save dialog. An example might be when saving to a bitmap format - this component could prompt for image resolution and so on. If this method returns
null
(the default), then no additional component will be displayed on save.By default this method calls
return getComponent()
, which calls the legacy method which was the recommended approach prior to 2.15.1- Parameters:
panel
- the DocumentPanel containing the PDF being savedfile
- the File being saved to- Since:
- 2.15.1
-
getComponent
@Deprecated public JComponent getComponent()
Deprecated.Subclasses should overridegetComponent(DocumentPanel,File)
insteadAs forgetComponent(DocumentPanel, File)
, but this method takes no DocumentPanel and File arguments. Subclasses should override thegetComponent(DocumentPanel,File)
method instead.
-
validateComponent
public String validateComponent(JComponent comp)
Given the component returned bygetComponent(org.faceless.pdf2.viewer2.DocumentPanel, java.io.File)
, returnnull
if the values are valid or an error message if they're invalid.- Parameters:
comp
- the Component returned bygetComponent(org.faceless.pdf2.viewer2.DocumentPanel, java.io.File)
-
preProcessPDF
public void preProcessPDF(PDF pdf)
Called byExporter.ExporterTask.savePDF()
just before the PDF is saved, you can override this method for custom processing. By default it's a no-op- Since:
- 2.13
-
postProcessPDF
public void postProcessPDF(PDF pdf)
Called byExporter.ExporterTask.savePDF()
just after the PDF is saved, you can override this method for custom processing. By default it's a no-op- Since:
- 2.13
-
completed
public void completed()
Called when the save has completed - by default, a no-op. Both this and theExporter.ExporterTask.completed()
method in theExporter.ExporterTask
will be called on completion, and subclasses can override either.- Since:
- 2.18.1
-
-