|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.pdf2.PDFAction
public final class PDFAction
An action tells the PDF viewer how to navigate around the document.
Actions are performed when the user clicks on a PDFBookmark
,
when a Form
element or one of it's WidgetAnnotation
children
specifies an event, or optionally when an event occurs on a PDF
or PDFPage
, such as when the document is opened, printed or a page
is opened or closed.
The PDFAction
class has no public constructor, just a number of
static methods returning a new action of the specified type.
Event
,
PDFPage.setAction(org.faceless.pdf2.Event, org.faceless.pdf2.PDFAction)
,
PDF.setAction(org.faceless.pdf2.Event, org.faceless.pdf2.PDFAction)
,
FormElement.setAction(org.faceless.pdf2.Event, org.faceless.pdf2.PDFAction)
,
WidgetAnnotation.setAction(org.faceless.pdf2.Event, org.faceless.pdf2.PDFAction)
,
PDFBookmark
Field Summary | |
---|---|
static int |
METHOD_FDF
Method for the formSubmit(java.lang.String, int) action specifying that the form should
be submitted in the Adobe Forms Data Format. |
static int |
METHOD_FDF_WITH_ALL_ANNOTATIONS
Method for the formSubmit(java.lang.String, int) action specifying that the form should
be submitted in the Adobe Forms Data Format, and that it should include
all the annotations in the document. |
static int |
METHOD_FDF_WITH_MY_ANNOTATIONS
Method for the formSubmit(java.lang.String, int) action specifying that the form should
be submitted in the Adobe Forms Data Format, and that it should include
any annotations that have been created by the "current user". |
static int |
METHOD_FLAG_CANONICALDATES
Flag that can be added to the method passed to formSubmit(java.lang.String, int) to specify
that all dates should be submitted in "canonical" D:YYYYMMDDHHMMSS format |
static int |
METHOD_FLAG_EMPTYFIELDS
Flag that can be added ot the method passed to formSubmit(java.lang.String, int) tp specify
that values for empty fields should be submitted as well. |
static int |
METHOD_HTTP_IMAGEMAP_POST
Method for the formSubmit(java.lang.String, int) action specifying that the form should
be submitted as a standard HTTP POST, in the same way as an HTML form. |
static int |
METHOD_HTTP_POST
Method for the formSubmit(java.lang.String, int) action specifying that the form should
be submitted as a standard HTTP POST, in the same way as an HTML form |
static int |
METHOD_PDF
Method for the formSubmit(java.lang.String, int) action specifying that the form should
be submitted as a PDF. |
static int |
METHOD_XML
Method for the formSubmit(java.lang.String, int) action specifying that the form should
be submitted as XFDF XML. |
static int |
METHOD_XML_WITH_ALL_ANNOTATIONS
Method for the formSubmit(java.lang.String, int) action specifying that the form should
be submitted as XFDF XML, and that it should include all the annotations
in the document. |
Method Summary | |
---|---|
static PDFAction |
formImportData(String file)
Return a new PDFAction which imports a Forms Data Format (FDF)
file into the document AcroForm, setting some or all of the forms values. |
static PDFAction |
formJavaScript(String javascript)
Return a new PDFAction which executes a JavaScript action. |
static PDFAction |
formReset()
Return a new PDFAction which resets the documents AcroForm,
setting every field to its default values. |
static PDFAction |
formSubmit(String url,
int method)
Return a new PDFAction which submits the documents AcroForm. |
WidgetAnnotation |
getAnnotation()
For hideWidget(org.faceless.pdf2.WidgetAnnotation) and showWidget(org.faceless.pdf2.WidgetAnnotation) actions,
return the annotation being toggled shown or hidden. |
Collection |
getFormSubmitFields()
Return the list of fields to be submitted by this form-submit action, or null if this action is not a form-submit action or is
not part of a PDF. |
int |
getFormSubmitFlags()
For formSubmit actions, return the raw "Flags" field of the action. |
int |
getFormSubmitMethod()
For formSubmit actions, return the method by which the form is submitted - one of the METHOD parameters
defined in this class. |
float[] |
getGoToCoordinates()
Return the co-ordinates of a GoTo action. |
String |
getJavaScript()
For JavaScript type annotations, return the JavaScript
that is being executed. |
PDFAction |
getNext()
Return the action that's next in the chain after this one, or null if no further actions are defined. |
PDFPage |
getPage()
For actions that refer to a page - any of the "GoTo" actions except "GoToURL" - return the page the action refers to. |
String |
getRemoteFilename()
For goToRemote(java.lang.String, int, float, float, float) and goToFitRemoteRectangle(java.lang.String, int, float, float, float, float) actions, return the file name
that this action refers to. |
int |
getRemotePageNumber()
For goToRemote(java.lang.String, int, float, float, float) and goToFitRemoteRectangle(java.lang.String, int, float, float, float, float) actions, return the page number
that this action refers to, starting at 1. |
PDFSound |
getSound()
For "Sound" actions, return the PDFSound object this action refers to. |
String |
getType()
Return the type of action. |
String |
getURL()
For formSubmit, goToURL and formImportData actions, return the URL that is the destination of the action (or source of the data). |
static PDFAction |
goTo(PDFPage page)
Return a new PDFAction which jumps to the specified page in the PDF document. |
static PDFAction |
goTo(PDFPage page,
float x,
float y,
float zoom)
Return a new PDFAction which jumps to the specified page in the PDF document, at the specified x, y and zoom level. |
static PDFAction |
goToFit(PDFPage page)
Return a new PDFAction which jumps to the specified page in the PDF document. |
static PDFAction |
goToFitHeight(PDFPage page,
float x)
Return a new PDFAction which jumps to the specified page in the PDF document. |
static PDFAction |
goToFitRectangle(PDFPage page,
float x1,
float y1,
float x2,
float y2)
Return a new PDFAction which jumps to the specified page in the PDF document. |
static PDFAction |
goToFitRemoteRectangle(String filename,
int pagenumber,
float left,
float bottom,
float width,
float height)
As for goToFitRectangle(org.faceless.pdf2.PDFPage, float, float, float, float) , but returns a new PDFAction which moves to a page in another
PDF. |
static PDFAction |
goToFitWidth(PDFPage page,
float y)
Return a new PDFAction which jumps to the specified page in the PDF document. |
static PDFAction |
goToRemote(String filename,
int pagenumber,
float x,
float y,
float zoom)
As for goTo(org.faceless.pdf2.PDFPage) , but returns a new PDFAction which moves to a page in another
PDF. |
static PDFAction |
goToRemote(String filename,
int pagenumber,
float x,
float y,
float zoom,
String newwindow)
As for goTo(org.faceless.pdf2.PDFPage) , but returns a new PDFAction which moves to a page in another
PDF. |
static PDFAction |
goToURL(URI uri,
boolean isImageMap)
Return a new PDFAction which jumps to the specified URI. |
static PDFAction |
goToURL(URL url)
Return a new PDFAction which jumps to the specified URL. |
static PDFAction |
goToURL(URL url,
boolean isImageMap)
Return a new PDFAction which jumps to the specified URL. |
static PDFAction |
hideWidget(WidgetAnnotation annot)
Return a new PDFAction which hides the specified WidgetAnnotation . |
static PDFAction |
launch(String filename,
String newwindow)
Create a "Launch" action. |
static PDFAction |
named(String name)
Return a new PDFAction which runs the named action. |
static PDFAction |
playSound(PDFSound s)
Return a new PDFAction which plays a PDFSound when activated. |
static PDFAction |
playSound(PDFSound sound,
int volume,
boolean repeat,
boolean mix)
Return a new PDFAction which plays a PDFSound when activated. |
void |
setNext(PDFAction action)
The setNext method allows you to create "chains" of actions
which are executed whenever the first entry in the chain is run. |
static PDFAction |
showWidget(WidgetAnnotation annot)
Return a new PDFAction which makes the specified WidgetAnnotation
visible on screen. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int METHOD_HTTP_POST
formSubmit(java.lang.String, int)
action specifying that the form should
be submitted as a standard HTTP POST, in the same way as an HTML form
public static final int METHOD_HTTP_IMAGEMAP_POST
formSubmit(java.lang.String, int)
action specifying that the form should
be submitted as a standard HTTP POST, in the same way as an HTML form. The
co-ordinates where the submit button was clicked are included in the
submission as name.x and name.y, where name is the name of
the submit button that was clicked.
public static final int METHOD_FDF
formSubmit(java.lang.String, int)
action specifying that the form should
be submitted in the Adobe Forms Data Format.
public static final int METHOD_XML
formSubmit(java.lang.String, int)
action specifying that the form should
be submitted as XFDF XML.
This method requires PDF 1.4 (Acrobat 5.0) or later.
public static final int METHOD_XML_WITH_ALL_ANNOTATIONS
formSubmit(java.lang.String, int)
action specifying that the form should
be submitted as XFDF XML, and that it should include all the annotations
in the document.
This method requires PDF 1.4 (Acrobat 5.0) or later.
public static final int METHOD_FDF_WITH_ALL_ANNOTATIONS
formSubmit(java.lang.String, int)
action specifying that the form should
be submitted in the Adobe Forms Data Format, and that it should include
all the annotations in the document.
This method requires PDF 1.4 (Acrobat 5.0) or later.
public static final int METHOD_FDF_WITH_MY_ANNOTATIONS
formSubmit(java.lang.String, int)
action specifying that the form should
be submitted in the Adobe Forms Data Format, and that it should include
any annotations that have been created by the "current user". The spec is
a bit vague on how the current user is determined, but we include this method
for completeness.
This method requires PDF 1.4 (Acrobat 5.0) or later.
public static final int METHOD_PDF
formSubmit(java.lang.String, int)
action specifying that the form should
be submitted as a PDF.
This method requires PDF 1.4 (Acrobat 5.0) or later.
public static final int METHOD_FLAG_CANONICALDATES
formSubmit(java.lang.String, int)
to specify
that all dates should be submitted in "canonical" D:YYYYMMDDHHMMSS format
public static final int METHOD_FLAG_EMPTYFIELDS
formSubmit(java.lang.String, int)
tp specify
that values for empty fields should be submitted as well. By default this is
not the case
Method Detail |
---|
public static PDFAction goTo(PDFPage page)
page
- the page this action should jump topublic static PDFAction goTo(PDFPage page, float x, float y, float zoom)
page
- the page this action should jump to.x
- the X position on the new page to scroll to, or Float.NaN
to keep the X position unchanged.y
- the Y position on the new page to scroll to, or Float.NaN
to keep the Y position unchanged.zoom
- The zoom level. A value of 0 or Float.NaN
leaves the zoom unchanged, 1 sets the zoom to 100%, 2 to 200% and so on.public static PDFAction goToFit(PDFPage page)
page
- the page this action should jump topublic static PDFAction goToFitWidth(PDFPage page, float y)
page
- the page this action should jump toy
- if the page is too tall to fit in the windows, the Y position on the new
page to scroll to.public static PDFAction goToFitHeight(PDFPage page, float x)
page
- The page this action should jump to.x
- if the page is too wide to fit in the windows, the X position on the new
page to scroll to.public static PDFAction goToFitRectangle(PDFPage page, float x1, float y1, float x2, float y2)
page
- the page this action should jump tox1
- the left edge of the visible rectangley1
- the bottom edge of the visible rectanglex2
- the right edge of the visible rectangley2
- the top edge of the visible rectanglepublic static PDFAction goToURL(URL url)
public static PDFAction goToURL(URL url, boolean isImageMap)
PDFAnnotation
, the annotation rectangle is treated
as a Server-Side ImageMap. So for example, if the user clicks 20 points
from the left and 30 points from the top of the link rectangle, the
URL that is loaded is http://www.url.com/?20,30
.
public static PDFAction goToURL(URI uri, boolean isImageMap)
goToURL(URL, boolean)
except it takes a java.net.URI
public static PDFAction goToRemote(String filename, int pagenumber, float x, float y, float zoom)
goTo(org.faceless.pdf2.PDFPage)
, but returns a new PDFAction which moves to a page in another
PDF. The PDF must be saved on the same filesystem as this one, as it's referenced by filename.
filename
- the name of the PDF to openpagenumber
- which page to go to - the first page is 0, the second 1 and so onx
- the X position on the new page to scroll to, or Float.NaN
to keep the X position unchanged.y
- the Y position on the new page to scroll to, or Float.NaN
to keep the Y position unchanged.zoom
- The zoom level. A value of 0 or Float.NaN
leaves the zoom unchanged, 1 sets the zoom to 100%, 2 to 200% and so on.public static PDFAction goToRemote(String filename, int pagenumber, float x, float y, float zoom, String newwindow)
goTo(org.faceless.pdf2.PDFPage)
, but returns a new PDFAction which moves to a page in another
PDF. The PDF must be saved on the same filesystem as this one, as it's referenced by filename.
This method allows you to specify whether the new document is to be opened in a new window -
the "newwindow" parameter may be "true" or "false" to force this - any other value
(including null) will use the default setting of the opening application.
filename
- the name of the PDF to openpagenumber
- which page to go to - the first page is 0, the second 1 and so onx
- the X position on the new page to scroll to, or Float.NaN
to keep the X position unchanged.y
- the Y position on the new page to scroll to, or Float.NaN
to keep the Y position unchanged.zoom
- The zoom level. A value of 0 or Float.NaN
leaves the zoom unchanged, 1 sets the zoom to 100%, 2 to 200% and so on.newwindow
- whether to open the document in a new window - either "true" or "false" to force this setting, or any other value to use the application defaultpublic static PDFAction goToFitRemoteRectangle(String filename, int pagenumber, float left, float bottom, float width, float height)
goToFitRectangle(org.faceless.pdf2.PDFPage, float, float, float, float)
, but returns a new PDFAction which moves to a page in another
PDF. The PDF must be saved on the same filesystem as this one, as it's referenced by filename.
filename
- the name of the PDF to openpagenumber
- which page to go to - values must be >= 1left
- the left edge of the visible rectanglebottom
- the bottom edge of the visible rectanglewidth
- the width of the visible rectangleheight
- the height of the visible rectanglepublic static PDFAction launch(String filename, String newwindow)
goToRemote()
), or to open an application.
filename
- the path name of the document or application to load.newwindow
- whether to open the document in a new window - either "true"
or "false" to force this setting, or any other value to use the application
default. Note this is only used when opening PDf documents - it's ignored for applications.public static PDFAction playSound(PDFSound s)
PDFSound
when activated.
This simpler of the two playSound methods plays the sound once at full
volume and with mixing turned off. See the PDFSound
class
for more information on limitations with sound in PDF documents.
PDFSound
public static PDFAction playSound(PDFSound sound, int volume, boolean repeat, boolean mix)
PDFSound
when activated.
sound
- the PDFSound
to play.volume
- the volume of the sound, from 0 (off) to 100 (maximum)repeat
- whether to play the sound continuously or just oncemix
- whether to mix the sound in with any other playing samples, or replace thempublic static PDFAction named(String name)
Return a new PDFAction which runs the named action. Named actions are PDF viewer dependent, so should be used with care. The following actions are among those known to work in Acrobat 3 and 4 readers, and loosely correspond to the equivalent actions available from the menus in Acrobat.
public static PDFAction showWidget(WidgetAnnotation annot)
WidgetAnnotation
visible on screen.
annot
- the annotation to modifyhideWidget(org.faceless.pdf2.WidgetAnnotation)
public static PDFAction hideWidget(WidgetAnnotation annot)
WidgetAnnotation
.
annot
- the annotation to modifyshowWidget(org.faceless.pdf2.WidgetAnnotation)
public static PDFAction formSubmit(String url, int method)
Event.MOUSEUP
event for a FormButton
somewhere in the form, so the form can be submitted.
The method parameter can be one of the various METHOD
values, although please note that many of these values are only implemented in
Acrobat 5.0 or later.
url
- the URL to submit the form tomethod
- the method to use when submitting the formForm
public static PDFAction formReset()
PDFAction
which resets the documents AcroForm,
setting every field to its default values.
Form
public static PDFAction formImportData(String file)
PDFAction
which imports a Forms Data Format (FDF)
file into the document AcroForm, setting some or all of the forms values.
file
- the name of the file containing the FDF. The file is relative to
the location of the current documentForm
public static PDFAction formJavaScript(String javascript)
Return a new PDFAction
which executes a JavaScript action.
This is generally used with AcroForms, although in theory it doesn't
have to be. It's generally better design to create functions in the
document-wide JavaScript (as set by PDF.setJavaScript(java.lang.String)
) and just
use these actions to call those methods.
javascript
- the JavaScript action to performPDF.setJavaScript(java.lang.String)
,
PDF.getJavaScript()
,
Form
public void setNext(PDFAction action)
setNext
method allows you to create "chains" of actions
which are executed whenever the first entry in the chain is run. This
allows more complicated processing - for example, clicking on a button
could play a sound and then jump to a specific page.
Avoiding infinite action loops is the responsibility of the programmer.
action
- the action to execute after the current one, or
null
to clear it.public PDFAction getNext()
null
if no further actions are defined.
public String getType()
Return the type of action. Can be "Named:value" (where "value" is the named action that's performed), "URL", "Sound", "GoTo", "GoToFitRectangle", "GoToFit", "GoToFitHeight", "GoToFitWidth", "GoToDPart" "ShowWidget", "HideWidget", "FormReset", "FormImportData", "FormSubmit", "FormJavaScript" or one of another type of action supported by the PDF specification but not by this library.
Note since 1.1.23 the URL value no longer includes the URL being referenced - use
the getURL()
method to retrieve that value
public PDFPage getPage()
public PDFSound getSound()
public WidgetAnnotation getAnnotation()
hideWidget(org.faceless.pdf2.WidgetAnnotation)
and showWidget(org.faceless.pdf2.WidgetAnnotation)
actions,
return the annotation being toggled shown or hidden.
public String getJavaScript()
JavaScript
type annotations, return the JavaScript
that is being executed. For other annotations, return null
.
public String getURL()
null
public int getFormSubmitMethod()
METHOD
parameters
defined in this class. For other action types the return is -1
formSubmit
actionpublic Collection getFormSubmitFields()
null
if this action is not a form-submit action or is
not part of a PDF. Despite the name this also applies to fields that
are to be reset by the form-reset action.
public int getFormSubmitFlags()
formSubmit
actionpublic float[] getGoToCoordinates()
Return the co-ordinates of a GoTo action. Some "GoTo" actions take
one or more coordinates which determine which section of the specified
page should be displayed. Examples of this are the
goToFitRectangle
method, which takes four parameters,
and the goToFitWidth
method, which takes one. These
coordinates can be read by calling this method, which returns an array
of floats, the length of which varies depending on the type of GoTo
action.
Specifically, "GoToFitWidth" and "GoToFitHeight" methods
return an array of one float, "GoToFitRectangle" will return four and
"GoTo" will return three. For this last one, the first number represents
the "X" coordinate, the second the "Y" and the third the zoom level, but
it's important to remember that any one of these may be unspecified -
in this case the value is set to Float.NaN
.
public int getRemotePageNumber()
goToRemote(java.lang.String, int, float, float, float)
and goToFitRemoteRectangle(java.lang.String, int, float, float, float, float)
actions, return the page number
that this action refers to, starting at 1. A value of zero is returned if this action
is not a remote action or the remote action doesn't reference a page
public String getRemoteFilename()
goToRemote(java.lang.String, int, float, float, float)
and goToFitRemoteRectangle(java.lang.String, int, float, float, float, float)
actions, return the file name
that this action refers to. For other types of action this method returns null.
public String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |