|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.pdf2.viewer2.ViewerFeature
org.faceless.pdf2.viewer2.ViewerWidget
org.faceless.pdf2.viewer2.feature.NetworkSave
public class NetworkSave
Create a button that will submit a PDF to a network URL. By default this feature is disabled - to enable it in an applet:
<applet code="org.faceless.pdf2.viewer2.PDFViewerApplet" name="pdfapplet" archive="bfopdf.jar, bfopdf-cmap.jar"> <param name="pdf" value="/myservice/getpdf?pdf=1234" /> <param name="feature.NetworkSave" value="true" /> <param name="feature.NetworkSave.url" value="/myservice/putpdf?pdf=1234" /> <param name="feature.NetworkSave.premessage" value="Save PDF to MyService?" /> <param name="feature.NetworkSave.postmessage" value="PDF Saved" /> </applet>or to use it in an application, you would add a new NetworkSave instance to the list of features passed in to the
PDFViewer.PDFViewer(java.util.Collection)
constructor:
ArrayList f = new ArrayList(ViewerFeature.getAllEnabledFeatures()); NetworkSave save = new NetworkSave(); save.setURL(new URL("http://localhost:8080/savepdf")); f.add(save); PDFViewer viewer = new PDFViewer(f);
The URL
attribute must be set on this feature before it can be used,
either via the url
initialization parameter or by calling the setURL(java.net.URL)
method. It may contain a Base64-encoded username and password if necessary. The PDF
will be rendered and sent directly to the URL connection's
OutputStream
. If the filename of the PDF is known,
it will be submitted via the X-BFOPDF-File
HTTP header - if more customization
is required you can override the setAdditionalHeaders(java.net.URLConnection, org.faceless.pdf2.viewer2.DocumentPanel)
method to modify
the PDF and/or the connection headers before the PDF is submitted
url | The URL to submit the save action to |
---|---|
premessage | The message to display to the user before submission. If not null, the value will be displayed to the user with an "OK" or "Cancel" prompt before saving |
postmessage | The message to display to the user after submission. If not null, the value will be displayed to the user with an "OK" prompt after saving. The special value "response" can be used to display the HMTL response from the server |
fieldname | If set, the PDF will be sent as if submitted via an HTTP Form - "fieldname" would be the name of the field. It null, the PDF will simply be written as the body of the HTTP content (since 2.11.19). |
filename | The filename parameter to send in the submission (defaults to the PDF filename) |
timeout | The connection timeout value in milliseconds (0 is infinite) |
readTimeout | The read timeout value in milliseconds (0 is infinite) |
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.
Constructor Summary | |
---|---|
NetworkSave()
|
Method Summary | |
---|---|
void |
action(ViewerEvent event)
The method that's run when this feature is activated |
void |
documentUpdated(DocumentPanelEvent event)
Called when an DocumentPanelEvent is raised |
void |
initialize(PDFViewer viewer)
Called when the feature is first added to a viewer |
boolean |
isEnabledByDefault()
Return true if this feature is enabled by default (the default). |
void |
save(ViewerEvent event,
Exporter exporter,
URL url)
Save the Document to the network |
void |
setAdditionalHeaders(URLConnection con,
DocumentPanel panel)
Set any additional headers on the connection, or modify the PDF if necessary before saving. |
void |
setFieldName(String fieldname)
Set the field name which the PDF will be submitted as (as if it were sent from an HTML Form). |
void |
setFileName(String filename)
Set the file name which the PDF will be submitted as (as if it were sent from an HTML Form). |
void |
setPostMessage(String message)
Set the message which will be displayed to the user after a successful save. |
void |
setPreMessage(String message)
Set the message which will be displayed to the user before saving as a prompt - the save will only continue if the user selects "OK". |
void |
setReadTimeout(int timeout)
Set the timeout in milliseconds that should be used when reading from a URL. |
void |
setTimeout(int timeout)
Set the timeout in milliseconds that should be used when connecting to a URL. |
void |
setURL(URL url)
Set the URL the PDF will be submitted to. |
Methods inherited from class org.faceless.pdf2.viewer2.ViewerWidget |
---|
createActionListener, getComponent, getViewer, isButtonEnabledByDefault, isDocumentRequired, isMenuEnabledByDefault, setButton, setComponent, setDocumentRequired, setMenu, setMenu, setToolBarEnabled, setToolBarEnabledAlways, setToolBarFloatable, setToolBarFloating, toString |
Methods inherited from class org.faceless.pdf2.viewer2.ViewerFeature |
---|
getAllEnabledFeatures, getAllFeatures, getCustomJavaScript, getFeatureProperty, getFeatureURLProperty, getName, setFeatureName, teardown |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NetworkSave()
Method Detail |
---|
public boolean isEnabledByDefault()
ViewerFeature
ViewerFeature.getAllEnabledFeatures()
and by the PDFViewerApplet
and PDFTool
isEnabledByDefault
in class ViewerFeature
public void initialize(PDFViewer viewer)
ViewerFeature
initialize
in class ViewerWidget
public void setTimeout(int timeout)
timeout
- the number of milliseconds to wait while connecting to a URL before timing outpublic void setReadTimeout(int timeout)
timeout
- the number of milliseconds to wait while reading from a URL before timing outpublic void setURL(URL url)
url
- the URLpublic void setPreMessage(String message)
message
- the message to displaypublic void setPostMessage(String message)
message
- the message to displaypublic void setFieldName(String fieldname)
fieldname
- the field namepublic void setFileName(String filename)
filename
- the file namepublic void documentUpdated(DocumentPanelEvent event)
DocumentPanelListener
DocumentPanelEvent
is raised
documentUpdated
in interface DocumentPanelListener
public void action(ViewerEvent event)
ViewerWidget
action
in class ViewerWidget
public void save(ViewerEvent event, Exporter exporter, URL url)
event
- the ViewerEvent that launched this actionexporter
- the Exporter
to use, or null to default to a PDFExporter
url
- the URL to submit the PDF topublic void setAdditionalHeaders(URLConnection con, DocumentPanel panel)
save(org.faceless.pdf2.viewer2.ViewerEvent, org.faceless.pdf2.viewer2.Exporter, java.net.URL)
method just before the PDF is
sent, by default this method does nothing.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |