org.faceless.pdf2.viewer2.feature
Class NetworkSave

java.lang.Object
  extended by org.faceless.pdf2.viewer2.ViewerFeature
      extended by org.faceless.pdf2.viewer2.ViewerWidget
          extended by org.faceless.pdf2.viewer2.feature.NetworkSave
All Implemented Interfaces:
DocumentPanelListener

public class NetworkSave
extends ViewerWidget
implements DocumentPanelListener

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

The following initialization parameters can be specified to configure this feature. .
urlThe URL to submit the save action to
premessageThe 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
postmessageThe 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
fieldnameIf 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).
filenameThe filename parameter to send in the submission (defaults to the PDF filename)
timeoutThe connection timeout value in milliseconds (0 is infinite)
readTimeoutThe read timeout value in milliseconds (0 is infinite)
The name of this feature is NetworkSave

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.11.17

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

NetworkSave

public NetworkSave()
Method Detail

isEnabledByDefault

public boolean isEnabledByDefault()
Description copied from class: ViewerFeature
Return true if this feature is enabled by default (the default). Disabled features are excluded from the list returned by ViewerFeature.getAllEnabledFeatures() and by the PDFViewerApplet and PDFTool

Overrides:
isEnabledByDefault in class ViewerFeature

initialize

public void initialize(PDFViewer viewer)
Description copied from class: ViewerFeature
Called when the feature is first added to a viewer

Overrides:
initialize in class ViewerWidget

setTimeout

public void setTimeout(int timeout)
Set the timeout in milliseconds that should be used when connecting to a URL. A value of 0 (the default) means infinite.

Parameters:
timeout - the number of milliseconds to wait while connecting to a URL before timing out

setReadTimeout

public void setReadTimeout(int timeout)
Set the timeout in milliseconds that should be used when reading from a URL. A value of 0 (the default) means infinite.

Parameters:
timeout - the number of milliseconds to wait while reading from a URL before timing out

setURL

public void setURL(URL url)
Set the URL the PDF will be submitted to. This must be set for this feature to work.

Parameters:
url - the URL

setPreMessage

public 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". Setting this value to null (the default) means no prompt will be given before saving.

Parameters:
message - the message to display

setPostMessage

public void setPostMessage(String message)
Set the message which will be displayed to the user after a successful save. If this is null (the default) no message will be displayed. The special value "response" can be used to display the HTML response from the server.

Parameters:
message - the message to display

setFieldName

public void setFieldName(String fieldname)
Set the field name which the PDF will be submitted as (as if it were sent from an HTML Form). If null (the default), the PDF will simply be written to the HTTP stream.

Parameters:
fieldname - the field name
Since:
2.11.19

setFileName

public void setFileName(String filename)
Set the file name which the PDF will be submitted as (as if it were sent from an HTML Form). If null (the default), the filename of the PDF will be used.

Parameters:
filename - the file name
Since:
2.11.19

documentUpdated

public void documentUpdated(DocumentPanelEvent event)
Description copied from interface: DocumentPanelListener
Called when an DocumentPanelEvent is raised

Specified by:
documentUpdated in interface DocumentPanelListener

action

public void action(ViewerEvent event)
Description copied from class: ViewerWidget
The method that's run when this feature is activated

Overrides:
action in class ViewerWidget

save

public void save(ViewerEvent event,
                 Exporter exporter,
                 URL url)
Save the Document to the network

Parameters:
event - the ViewerEvent that launched this action
exporter - the Exporter to use, or null to default to a PDFExporter
url - the URL to submit the PDF to

setAdditionalHeaders

public void setAdditionalHeaders(URLConnection con,
                                 DocumentPanel panel)
Set any additional headers on the connection, or modify the PDF if necessary before saving. Called by the 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.



Copyright © 2001-2010 Big Faceless Organization