|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--java.applet.Applet | +--com.adobe.acrobat.Viewer
Viewer
is the primary exported class for the Acrobat Viewer. It contains
interfaces for running the Viewer as an Application
, an Applet
,
or a Bean
.
Only the classes and methods at this level of the class hierarchy (that is: com.adobe.acrobat.*
)
are guaranteed to be present without obfuscating name changes.
Here is a code fragment that creates a viewer and adds it to a frame.
Frame frame = new Frame("Test Viewer"); frame.setLayout(new BorderLayout()); Viewer viewer = new Viewer(); frame.add(viewer, BorderLayout.CENTER); viewer.activate(); frame.setSize(400, 500); frame.show();
Copyright (c) 1999, Adobe Systems Inc., All Rights Reserved.
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT,
TOP_ALIGNMENT |
Constructor Summary |
Viewer() Construct a Viewer
object. |
Viewer(boolean useCache)
Construct a Viewer
object, and optionally disables the use of the Font cache. |
Viewer(java.lang.String[] disallowedCommands)
Construct a Viewer
object, where the given commands are removed from the UI of the viewer (from toolbar,
menubar, and popup menus). |
Method Summary | |
void |
activate() Creates Layout of the Viewer
component and prepares it for display. |
void |
activateWithoutBars()
Creates Layout of the Viewer
component without a toolbar and without a status bar, and prepares it for display. |
void |
deactivate() The deactivate method should be called after the Viewer is no longer needed. |
void |
destroy() The destroy method overrides the Applet destroy method and is called by the browser before the applet is
destroyed. |
static boolean |
enabledDebug() Internal method to check for debugging enabled. |
void |
execMenuItem(java.lang.String viewerCommand)
Executes a Viewer
command. |
java.lang.String |
getAppletInfo() Returns a localized string containing version and copyright information about the this Applet . |
java.net.URL |
getCodeBase() Gets the base URL . |
com.adobe.acrobat.gui.AcroViewContext |
getContext() This is an internal method. |
int |
getCurrentPage() Get the page number of the currently displayed page. |
java.lang.String |
getDocumentURL() Returns the full URL
of the document. |
java.awt.Frame |
getFrame() This is an internal method. |
int |
getPageCount() Get the total number of pages in the current document. |
java.lang.String[][] |
getParameterInfo() Returns information about the parameters than are understood by this applet. |
java.util.Properties |
getProperties() get all Viewer properties |
java.lang.String |
getProperty(java.lang.String key)
get a Viewer property |
PDFBookmark |
getRootBookmark() Gets the root bookmark associated with this document. |
java.lang.String |
getTextForPage(int pageNumber)
Get all of the text on a page. |
void |
gotoNamedDest(java.lang.String dest)
go to a PDF named destination |
void |
init() Called by the browser or applet viewer to inform this applet that it has been loaded into the system. |
static void |
main(java.lang.String[] args)
Application startup code. |
Viewer |
openNewWindow() Opens a new window on the current document. |
void |
printAll() Print all pages of the document. |
void |
printPages(int start,
int end) Print a selected page range from the document |
static void |
registerViewerWindow(java.awt.Frame f)
Register an active window with the Viewer . |
void |
renderingDone() Completion callback method that is called when a page is fully rendered. |
void |
renderPage(int pageNumber)
Completely render the page with the given page number. |
void |
setDocumentByteArray(byte[] bytes)
Open a document from an array of byte s in memory. |
void |
setDocumentByteArraySource(ByteArraySource bas) Open a document from a ByteArraySource . |
void |
setDocumentInputStream(java.io.InputStream stm)
Open a document from an InputStream . |
void |
setDocumentURL(java.lang.String docURL)
Open a document from a URL . |
static void |
setEnableDebug(boolean debug)
turn on certain debugging functions in the Viewer. |
void |
setProperty(java.lang.String key,
java.lang.String value) Set a Viewer property. |
void |
setRenderingObserver(RenderingObserver ro) Sets a rendering observer whose renderingDone method gets called after a page has been completely rendered with the renderPage method. |
static void |
unregisterViewerWindow(java.awt.Frame f)
Unregister an active window with the Viewer. |
void |
zoomTo(double zoomLevel)
Zoom the current page to the the given zoom level in percentages. |
Methods inherited from class java.applet.Applet |
getAppletContext, getAudioClip, getAudioClip, getDocumentBase, getImage,
getImage, getLocale, getParameter, isActive, newAudioClip, play, play, resize, resize,
setStub, showStatus, start, stop |
Methods inherited from class java.awt.Panel |
addNotify |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, countComponents,
deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY,
getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets,
getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate,
isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents,
paramString, preferredSize, print, printComponents, processContainerEvent, processEvent,
remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout,
update, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addInputMethodListener,
addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener,
addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains,
contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable,
enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds,
getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics,
getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests,
getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize,
getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus,
hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable,
isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list,
location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp,
move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll,
processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent,
processMouseEvent, processMouseMotionEvent, remove, removeComponentListener,
removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener,
removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener,
repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds,
setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground,
setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show,
size, toString, transferFocus |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Viewer() throws java.lang.Exception
Viewer
object. This Viewer
needs to be activated
before you can show it.Viewer
cannot be constructed.activate()
, activateWithoutBars()
public Viewer(boolean useCache) throws java.lang.Exception
Viewer
object, and optionally disables the use of the Font
cache. This Viewer
needs to be activated before you can show it.useCache
- false
to disable use of the Font cache (desirable
for devices that have no file system).Viewer
cannot be constructed.activate()
, activateWithoutBars()
public Viewer(java.lang.String[] disallowedCommands) throws java.lang.Exception
Viewer
object, where the given commands are removed from the UI
of the viewer (from toolbar, menubar, and popup menus). For example, here is how you can
create a viewer with the Open_K
and OpenURL_K
commands removed:
String[] dis = {ViewerCommand.Open_K, ViewerCommand.OpenURL_K};
Viewer viewer = new Viewer(dis);
disallowedCommands
- an array of viewer command names.Viewer
cannot be constructed.activate()
, activateWithoutBars()
, ViewerCommand
Method Detail |
public PDFBookmark getRootBookmark() throws java.lang.Exception
PDFBookmark
treepublic java.net.URL getCodeBase()
URL
. This is the URL
of the Applet
itself. If invoked as a Bean, then this is the file URL
of the current
working directory.
URL
of this Applet
or Bean
public static void registerViewerWindow(java.awt.Frame f)
Viewer
. The Viewer
exits
when the total number of registered active windows goes to zero. This is an internal method. Do not call it directly.
public static void unregisterViewerWindow(java.awt.Frame f)
Viewer
exits when the
total number of registered active windows goes to zero. This is an internal method. Do not call it directly.
public void destroy()
Applet
destroy method and is called by the
browser before the applet is destroyed. This method will save your preferences file. The
default implementation simply calls deactivate
deactivate()
public void deactivate()
Viewer
is no longer
needed. Part of this method includes saving your preferences file.public void activate() throws java.lang.Exception
Viewer
component and prepares it for display. This
method should be called after the constructor and before the parent panel is shown.activateWithoutBars()
public void activateWithoutBars() throws java.lang.Exception
Viewer
component without a toolbar and without a
status bar, and prepares it for display. This method should be called after the
constructor and before the parent panel is shown.activate()
public com.adobe.acrobat.gui.AcroViewContext getContext()
public static void main(java.lang.String[] args)
-d
- means start with debug support (requires Debug classes)-u
- url of a pdf file to open-r
- full-path of a directory to ready resources from (if omitted the
Resources directory relative to the location of the Viewer class is used).public static void setEnableDebug(boolean debug)
-d
(debug) flag Applets use the DEBUG
propertydebug
- true
to turn on debug functionspublic static boolean enabledDebug()
true
if debugging is enabled.public void init()
public java.awt.Frame getFrame()
public void execMenuItem(java.lang.String viewerCommand) throws java.lang.Exception
Viewer
command. The command is passed by name.viewerCommand
- a valid ViewerCommand
name.ViewerCommand
public Viewer openNewWindow() throws java.lang.Exception
Viewer/code> object.
public void zoomTo(double zoomLevel) throws java.lang.Exception
zoomLevel
- the factor to zoom to, e.g., to zoom to 200%
, pass
the value of 2.0
, or to set the zoom to 50%
, pass the value of 0.5
.public java.lang.String[][] getParameterInfo()
public java.lang.String getAppletInfo()
Applet
.public void setDocumentURL(java.lang.String docURL) throws java.lang.Exception
URL
.docURL
- a URL
, which may be relative to the document base.URL
cannot be opened.public java.lang.String getDocumentURL() throws java.lang.Exception
URL
of the document. If the document is not sourced from a
URL
, returns ""
.URL
URL
cannot be obtained.public void setDocumentByteArray(byte[] bytes) throws java.lang.Exception
byte
s in memory.bytes
- a complete PDF file. The byte array should be no longer than
the file, so the EOF can be found.public void setDocumentByteArraySource(ByteArraySource bas) throws java.lang.Exception
ByteArraySource
.bas
- the ByteArraySource
from which to get the ByteArray
whose contents will be displayed.public void setDocumentInputStream(java.io.InputStream stm) throws java.lang.Exception
InputStream
.stm
- a java.io.InputStream
public void renderPage(int pageNumber) throws java.lang.Exception
pageNumber
- Must be a number between 0 and getPageCount() - 1
,
inclusive.Here is an example using this method to automatically render all pages in the current opened document.
for (int i = 1; i
getPageCount()
public void renderingDone()
public void setRenderingObserver(RenderingObserver ro)
ro
- The RenderingObserver, registers a observer whose renderingDone method
gets called. To unregister, call this method and pass null.renderPage(int)
public int getCurrentPage() throws java.lang.Exception
SinglePage
public int getPageCount() throws java.lang.Exception
public void gotoNamedDest(java.lang.String dest) throws java.lang.Exception
dest
- a String
with the name of the destinationpublic java.lang.String getTextForPage(int pageNumber) throws java.lang.Exception
pageNumber
- Must be a number between 0 and getPageCount() - 1
,
inclusive.String
containing all the text in Unicodepublic void printAll() throws java.lang.Exception
printPages(int, int)
public void printPages(int start, int end) throws java.lang.Exception
start
- the starting page number (pages are numbered from 0)end
- the ending page numberpublic void setProperty(java.lang.String key, java.lang.String value) throws java.lang.Exception
Applet
/Bean
. The properties that may be set
are: The following properties can be set before the viewer is displayed.
The following properties may be changed at any time
These are printing defaults. They are global to all instances of the applet
key
- property key stringvalue
- property value stringpublic java.lang.String getProperty(java.lang.String key) throws java.lang.Exception
key
- name of the propertysetProperty(java.lang.String,
java.lang.String)
public java.util.Properties getProperties() throws java.lang.Exception
Properties
table
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |