Package org.faceless.pdf2.viewer2
Class DocumentPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.faceless.pdf2.viewer2.DocumentPanel
-
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
public class DocumentPanel extends JPanel
A
DocumentPanel
is the basic component that displays a PDF, and may be instantiated on it's own or as part of aPDFViewer
. It contains aDocumentViewport
and optionally one or moreSidePanel
objects on the left, and may processPDFAction
s on the PDF. See the viewer tutorial for more detail on how to use this class and the "viewer" package.The following initialization parameters may be specifieddefaultViewport The class name of the default viewport to use if not specified in the PDF. May be SinglePageDocumentViewport
,MultiPageDocumentVieport
or a fully-qualified class name of anotherDocumentViewport
defaultPageMode The default "page mode" of the PDF if not set. This may take one of the values for the "pagemode" PDF option
, and would typically be "UseThumbs" or "UseOutlines".ignoreDocumentPageMode true
orfalse
(the default) - whether to ignore the "pagemode"PDF option
in the PDF when choosing which SidePanel t open by default.ignoreDocumentTitle true
orfalse
(the default) - whether to ignore the "displaydoctitle"PDF option
in the PDF when choosing the text to use for the window title.defaultZoom The default zoom level of the PDF, if not set by a PDF open action. This may be the value "fit", "fitwidth", "fitheight" or a number between 12.5 and 6400 to set the zoom level. useNamedSidePanels true
orfalse
(the default) - whether to show names on the side panel tabs rather than icons.sidePanelSize The default (and minimum) width of the side panels displayed in this DocumentPanel. The default is 120 mouseWheelUnit The number of pixels to adjust the viewport's scrollbar by when using the mouse wheel. The default is 16. smoothScrollTime When smoothly scrolling a viewport's scrollbars, the number of ms to animate the scroll over. The default is 500, set to zero to disable. smoothScrollDistance When smoothly scrolling a viewport's scrollbars, the maximum number of pixels to try to animate. The default is 500, set to zero to disable. earlyClose When closing a DocumentPanel or changing the PDF it contains, the old PDF object remains open and will naturally have its PDF.close()
method called during garbage collection. This can lead to problems on Windows platforms; As the PDF may retain a reference to the file it was read from, this prevents the file being deleted untilclose
is called. TheearlyClose
parameter can be set to close the PDF file immediately the PDF is removed from the DocumentPanel or the panel closed; this will free any resources held by the PDF, and so invalidate any reference to those resources (which may be held elsewhere - for example, if the PDF had its pages moved to another document). So use with caution - by default this value is not set, but set to any non-null value to enable.noDirtyDocuments Set this value to non-null to disable the dirty
flag on documents. If disabled, no prompt will appear when trying to close a document that has been modified.noDirtyInTitle Set this value to non-null to disable the "*" in the window title when the PDF is flagged as dirty. noProgressInTitle Set this value to non-null to disable the load-progress indicator in the window title when the PDF is linearized and only partially loaded. respectSignatureCertification If true, any restrictions found on a certified
signature in the PDF will be honoured - for example, if the PDF being displayed hasnochanges
set then no changes will be allowed to the PDF through the viewerviewportBorderColor Can be set to the Color to draw the border around the pages in the viewport, specified as a hex value. The default value is "666666", which is a dark gray. If the specified value has 8 digits, the first two hex digits are used as the alpha value. A value of "none" or "transparent" will not draw the border. viewportShadowColor Can be set to the Color to draw the shadow below the pages in the viewport, specified as a hex value. The default value is "80666666", which is a translucent dark gray. If the specified value has 8 digits, the first two hex digits are used as the alpha value. A value of "none" or "transparent" will not draw the shadow. viewportMargin If set, this is the margin to place around the outside of all the pages displayed in the viewport, in pixels. The default value is 4. viewportGap If set, this is the gap to place between multiple pages displayed in the viewport, in pixels (if applicable to the type of viewport in use). The default value is 10. printDialog This can be set to native
to always use the native print dialog,java
to always use the Java dialog, orauto
to choose depending on which print options are set. The native dialog does not allow options (such as number of copies, duplex printing) to be initialized, and some PDFs can specify defaults for these with thesetOption
mechanism. And the alternative java dialog may miss some advanced options, such as options for stapling the printed document. So a value ofauto
will use the native dialog unless the PDF (or the call toprint
specifies initial value for some of these options.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.8
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Constructor Summary
Constructors Constructor Description DocumentPanel()
Create a new DocumentPanel
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addActionHandler(ActionHandler actionhandler)
Add aActionHandler
to thisDocumentPanel
.void
addAnnotationComponentFactory(AnnotationComponentFactory annotationfactory)
Add aAnnotationComponentFactory
to thisDocumentPanel
.void
addDocumentPanelListener(DocumentPanelListener listener)
Add aDocumentPanelListener
to this DocumentPanelvoid
addSidePanel(SidePanel panel)
Add the specified sidepanel to the DocumentPanelvoid
addSidePanelFactory(SidePanelFactory panelfactory)
Add aSidePanelFactory
to thisDocumentPanel
.void
addUndoableEditListener(UndoableEditListener l)
Add anUndoableEditListener
to this DocumentPanelvoid
fireUndoableEditEvent(UndoableEditEvent e)
Fire anUndoableEditEvent
on this DocumentPanel.void
focus()
Make this DocumentPanel the active one in any parent PDFViewerList<PDFParser>
getAllParsers()
Return a read-only list of all PDFParser objects used in this DocumentPanel.List<PDF>
getAllPDFs()
Return a read-only list of all PDF objects used in this DocumentPanel.File
getAssociatedFile()
Get the associated File from this DocumentPanel.boolean
getAssociatedFileEnablesSave()
Return true if the associated file was loaded as an "import".DocumentPanelListener[]
getDocumentPanelListeners()
Return a list of all theDocumentPanelListener
objects registered on this DocumentPanel, or an empty array if there are noneJSManager
getJSManager()
Return the JSManager object for this DocumentPanel.LinearizedSupport
getLinearizedSupport()
Return the LinearizedSupport object for this DocumentPanelint
getNumberOfPages()
Return the number of pages being displayed by theDocumentPanel
.PDFPage
getPage()
Return the PDFPage currently being displayed by theDocumentViewport
.PDFPage
getPage(int i)
Return the specified page being displayed by theDocumentPanel
.PageExtractor
getPageExtractor(PDFPage page)
Return the PageExtractor used for the specified page.List<String>
getPageLabels()
Return the list of PageLabels to use for all the pages in this DocumentPanel.int
getPageNumber()
Return the pagenumber of the currently displayed page starting at 0, or -1 if no page is being displayed.int
getPageNumber(PDFPage page)
Return the index (from 0) of the specified page in this DocumentPanel's pagelist, or -1 if it doesn't exist..PDFParser
getParser()
Get the PDFParser being used to parse this PDF.PDFParser
getParser(PDFPage page)
Return the PDFParser used for the specified page.PDF
getPDF()
Return the PDF currently being displayed by thisDocumentPanel
SidePanel
getSelectedSidePanel()
Return the currently selectedSidePanel
, ornull
if no panels are displayed.Collection<SidePanel>
getSidePanels()
Return a read-only collection containing theSidePanel
objects in use by thisDocumentPanel
.PDFViewer
getViewer()
Return thePDFViewer
that contains this DocumentPanel.DocumentViewport
getViewport()
Return theDocumentViewport
contained by this DocumentPanelString
getWindowTitle()
Get the base title of the window containing this DocumentPanel, which does not include any "*" or loading progress details.float
getZoom()
Return the current zoom level.boolean
hasPermission(String permission)
Indicates whether the specified type of action is allowed for this DocumentPanel.boolean
isDirty()
Return the value of the dirty flag, as set bysetDirty(boolean)
void
print(PrintService service, PrintRequestAttributeSet fatts)
Display a Print dialog for printing this document, or if aPrintService
is specified, print directly to that service without displaying a dialog.void
raiseDocumentPanelEvent(DocumentPanelEvent event)
Raise aDocumentPanelEvent
on the DocumentPanel.void
redraw(Object o)
Deprecated.DocumentPanel.redraw() is no longer required as this object now listens toPropertyChangeEvents
fired by the PDF.void
removeDocumentPanelListener(DocumentPanelListener listener)
Remove aDocumentPanelListener
from this DocumentPanelvoid
removeSidePanel(SidePanel panel)
Remove the specified SidePanel from the DocumentPanel.void
removeUndoableEditListener(UndoableEditListener l)
Remove anUndoableEditListener
from this DocumentPanelboolean
runAction(PDFAction action)
Run the specified action on the PDF.ScheduledFuture<?>
schedule(Runnable r, long delay)
Schedule a timer task to run which is related to this DocmentPanel.void
setAssociatedFile(File file)
Set the associated File on this DocumentPanel.void
setAssociatedFile(File file, boolean enableSave)
Set the associated File on this DocumentPanel.void
setDirty(boolean dirty)
Set the document as being "dirty", ie that it has been modified since loading.void
setJSManager(JSManager jsmanager)
Set the JSManager object for this DocumentPanel.void
setPage(PDFPage page)
Set the page to display in theDocumentViewport
.void
setPage(PDFPage page, float x, float y, float zoom)
Set the page to display in theDocumentViewport
.void
setPageNumber(int i)
Set the page being displayed.void
setPDF(PDF pdf)
Set the PDF to be displayed by thisDocumentPanel
.void
setPDF(PDFParser parser, PDFPage page)
Set the PDF to be displayed by thisDocumentPanel
, and specify the initial page to display and the exactPDFParser
to use.void
setPDF(PDF pdf, PDFPage page)
Set the PDF to be displayed by thisDocumentPanel
, and specify the initial page to display.void
setPermission(String permission, boolean enable)
Sets whether the specified permission is allowed on this DocumentPanel.void
setSelectedSidePanel(SidePanel panel)
Set the currently displayedSidePanel
.void
setSidePanelSize(int threshold, int preferred)
Control the size of the leftmost pane.void
setSignaturePermissionRestrictions(FormSignature sig)
Limit the permissions that can beset
on this PDF to ensure they don't conflict with thecertification
of this signature.void
setViewport(DocumentViewport viewport)
Set theDocumentViewport
used by this DocumentPanel.void
setWindowTitle(String title)
Set the base title of the window containing this DocumentPanelvoid
setZoom(float zoom)
Set the current zoom level-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Method Detail
-
setViewport
public void setViewport(DocumentViewport viewport)
Set theDocumentViewport
used by this DocumentPanel.- Parameters:
viewport
- the Viewport
-
getViewport
public DocumentViewport getViewport()
Return theDocumentViewport
contained by this DocumentPanel
-
getJSManager
public JSManager getJSManager()
Return the JSManager object for this DocumentPanel.- Since:
- 2.9
-
setJSManager
public void setJSManager(JSManager jsmanager)
Set the JSManager object for this DocumentPanel. This method should only be called if multiple DocumentPanel object are used in the same non-PDFViewer container.- Since:
- 2.9
-
getViewer
public PDFViewer getViewer()
Return thePDFViewer
that contains this DocumentPanel. Note a DocumentPanel does not have to be contained inside a PDFViewer, in which case this method will returnnull
.
-
setSidePanelSize
public void setSidePanelSize(int threshold, int preferred)
Control the size of the leftmost pane. The two values specify the threshold below which the pane is considered to be closed, and the default size of the pane when it's opened.- Parameters:
threshold
- the minimum size, below which the panel is assumed to be closedpreferred
- the default size of the leftmost pane when opened
-
addSidePanelFactory
public void addSidePanelFactory(SidePanelFactory panelfactory)
Add aSidePanelFactory
to thisDocumentPanel
. When a PDF is set, the panels that are appropriate for that PDF will be created from this list of factories.- Parameters:
panelfactory
- the factory
-
addAnnotationComponentFactory
public void addAnnotationComponentFactory(AnnotationComponentFactory annotationfactory)
Add aAnnotationComponentFactory
to thisDocumentPanel
. Any PDF's displayed by this panel will have annotations created by these factories.- Parameters:
annotationfactory
- the factory
-
addActionHandler
public void addActionHandler(ActionHandler actionhandler)
Add aActionHandler
to thisDocumentPanel
. Any actions passed torunAction(org.faceless.pdf2.PDFAction)
will by handled by this list of handlers.- Parameters:
actionhandler
- the handler
-
runAction
public boolean runAction(PDFAction action)
Run the specified action on the PDF. Actions are handled byActionHandler
s, which should be registered with this class via theaddActionHandler()
method.- Parameters:
action
- the PDFAction to run.- Returns:
- true if the action was recognised and run successfully, false otherwise.
-
addDocumentPanelListener
public void addDocumentPanelListener(DocumentPanelListener listener)
Add aDocumentPanelListener
to this DocumentPanel- Parameters:
listener
- the listener
-
removeDocumentPanelListener
public void removeDocumentPanelListener(DocumentPanelListener listener)
Remove aDocumentPanelListener
from this DocumentPanel- Parameters:
listener
- the listener
-
getDocumentPanelListeners
public DocumentPanelListener[] getDocumentPanelListeners()
Return a list of all theDocumentPanelListener
objects registered on this DocumentPanel, or an empty array if there are none- Returns:
- the list of listeners
- Since:
- 2.13.1
-
raiseDocumentPanelEvent
public void raiseDocumentPanelEvent(DocumentPanelEvent event)
Raise aDocumentPanelEvent
on the DocumentPanel. In general this shouldn't be called unless you're extending one of the code classes, i.e. by writing your ownDocumentViewport
.- Since:
- 2.11.25
-
getSidePanels
public Collection<SidePanel> getSidePanels()
Return a read-only collection containing theSidePanel
objects in use by thisDocumentPanel
.- Since:
- 2.10.3 (prior to this release a Map was returned instead)
-
removeSidePanel
public void removeSidePanel(SidePanel panel)
Remove the specified SidePanel from the DocumentPanel.- Since:
- 2.10.3
-
addSidePanel
public void addSidePanel(SidePanel panel)
Add the specified sidepanel to the DocumentPanel- Since:
- 2.10.3
-
setSelectedSidePanel
public void setSelectedSidePanel(SidePanel panel)
Set the currently displayedSidePanel
. If the specified SidePanel is not in the list of SidePanels added to this DocumentPanel, this method does nothing.- Parameters:
panel
- the SidePanel to display, or null to display no SidePanel- Since:
- 2.10.3 (prior to this release the name of the panel was specified instead)
-
getSelectedSidePanel
public SidePanel getSelectedSidePanel()
Return the currently selectedSidePanel
, ornull
if no panels are displayed.- Since:
- 2.10.3 (prior to this release the name of the panel was returned instead)
-
setPDF
public void setPDF(PDF pdf)
Set the PDF to be displayed by thisDocumentPanel
. A value ofnull
will remove the current PDF from this object and free any resources that reference it - this should be done before this object is disposed of.- Parameters:
pdf
- the PDF, ornull
to remove the current PDF
-
setPDF
public void setPDF(PDF pdf, PDFPage page)
Set the PDF to be displayed by thisDocumentPanel
, and specify the initial page to display.- Parameters:
pdf
- the PDF, ornull
to remove the current PDFpage
- the initial page to display, ornull
to not display an initial page (exactly how this is handled depends on the Viewport). This will be ignored if the DocumentPanel is part of a PDFViewer and the PDF has an open action that sets the page.- Since:
- 2.11
-
setPDF
public void setPDF(PDFParser parser, PDFPage page)
Set the PDF to be displayed by thisDocumentPanel
, and specify the initial page to display and the exactPDFParser
to use.- Parameters:
parser
- the PDFParser to use to retrieve the PDF frompage
- the initial page to display, ornull
to not display an initial page (exactly how this is handled depends on the Viewport). This will be ignored if the DocumentPanel is part of a PDFViewer and the PDF has an open action that sets the page.- Since:
- 2.11.3
-
getParser
public PDFParser getParser()
Get the PDFParser being used to parse this PDF.
-
getAllParsers
public List<PDFParser> getAllParsers()
Return a read-only list of all PDFParser objects used in this DocumentPanel. Typically this will be a list of one item, the value returned fromgetParser()
- Since:
- 2.26
-
getAllPDFs
public List<PDF> getAllPDFs()
Return a read-only list of all PDF objects used in this DocumentPanel. Typically this will be a list of one item, the value returned fromgetPDF()
- Since:
- 2.26
-
getPDF
public PDF getPDF()
Return the PDF currently being displayed by thisDocumentPanel
-
getPage
public PDFPage getPage()
Return the PDFPage currently being displayed by theDocumentViewport
. If no PDF is set or the first page is still being rendered, this method will returnnull
.
-
getNumberOfPages
public int getNumberOfPages()
Return the number of pages being displayed by theDocumentPanel
. The same asgetPDF().getNumberOfPages()
- Since:
- 2.26
-
getPage
public PDFPage getPage(int i)
Return the specified page being displayed by theDocumentPanel
. The same asgetPDF().getPage(i)
- Parameters:
i
- the page index, from 0..getNumberOfPages()- Since:
- 2.26
-
getPageNumber
public int getPageNumber(PDFPage page)
Return the index (from 0) of the specified page in this DocumentPanel's pagelist, or -1 if it doesn't exist..- Parameters:
page
- the page- Since:
- 2.26
-
getParser
public PDFParser getParser(PDFPage page)
Return the PDFParser used for the specified page. The same asgetParser()
- Since:
- 2.26
-
getPageExtractor
public PageExtractor getPageExtractor(PDFPage page)
Return the PageExtractor used for the specified page.- Since:
- 2.26
-
getPageLabels
public List<String> getPageLabels()
Return the list of PageLabels to use for all the pages in this DocumentPanel.- Returns:
- a list of Strings to use as pagelabels. The list is getNumberOfPages() long
- Since:
- 2.26
-
getLinearizedSupport
public LinearizedSupport getLinearizedSupport()
Return the LinearizedSupport object for this DocumentPanel- Since:
- 2.14.1
-
setPageNumber
public void setPageNumber(int i)
Set the page being displayed. A shortcut forsetPage(getPDF().getPage(i))
.
-
getPageNumber
public int getPageNumber()
Return the pagenumber of the currently displayed page starting at 0, or -1 if no page is being displayed.
-
getZoom
public float getZoom()
Return the current zoom level. A value of 1 means the document is being displayed at it's actual size, 0.5 means 50% and so on.
-
setZoom
public void setZoom(float zoom)
Set the current zoom level- Parameters:
zoom
- the zoom level
-
setPage
public void setPage(PDFPage page)
Set the page to display in theDocumentViewport
. The page is displayed at it's top-left and at the current zoom level.- Parameters:
page
- the page
-
setPage
public void setPage(PDFPage page, float x, float y, float zoom)
Set the page to display in theDocumentViewport
. The page is displayed at the co-ordinates supplied and at the specified zoom level.- Parameters:
page
- the pagex
- the left-most position of the page to display, in units relative toPagePanel.getFullPageView(org.faceless.pdf2.PDFPage)
y
- the top-most position of the page to display, in units relative toPagePanel.getFullPageView(org.faceless.pdf2.PDFPage)
zoom
- the zoom level
-
redraw
@Deprecated public void redraw(Object o)
Deprecated.DocumentPanel.redraw() is no longer required as this object now listens toPropertyChangeEvents
fired by the PDF. This method is not called anywhere and is a no-opRedraw the specified object. param o the Object that has been altered - typically aPDFPage
orPDFAnnotation
-
setDirty
public void setDirty(boolean dirty)
Set the document as being "dirty", ie that it has been modified since loading. The propertynoDirtyDocuments
can be set to prevent this value from being set.- Since:
- 2.11.19
-
getWindowTitle
public String getWindowTitle()
Get the base title of the window containing this DocumentPanel, which does not include any "*" or loading progress details.- Since:
- 2.15.4
-
setWindowTitle
public void setWindowTitle(String title)
Set the base title of the window containing this DocumentPanel- Parameters:
title
- the new title.- Since:
- 2.15.4
-
isDirty
public boolean isDirty()
Return the value of the dirty flag, as set bysetDirty(boolean)
- Since:
- 2.11.19
-
addUndoableEditListener
public void addUndoableEditListener(UndoableEditListener l)
Add anUndoableEditListener
to this DocumentPanel- Since:
- 2.11.19
-
removeUndoableEditListener
public void removeUndoableEditListener(UndoableEditListener l)
Remove anUndoableEditListener
from this DocumentPanel- Since:
- 2.11.19
-
fireUndoableEditEvent
public void fireUndoableEditEvent(UndoableEditEvent e)
Fire anUndoableEditEvent
on this DocumentPanel. As a special hack, passingnew UndoableEditEvent(documentPanel, Undo.DISCARD)
to this method will truncate the list of events- Since:
- 2.11.19
-
print
public void print(PrintService service, PrintRequestAttributeSet fatts) throws PrintException, PrinterException
Display a Print dialog for printing this document, or if aPrintService
is specified, print directly to that service without displaying a dialog.- Parameters:
fservice
- the PrintService to print to. If this value isnull
a dialog will be displayed allowing the selection of a service.fatts
- the print attributes - may be set to an AttributeSet to control the printing, ornull
to use the default.- Throws:
PrintException
PrinterException
-
hasPermission
public boolean hasPermission(String permission)
Indicates whether the specified type of action is allowed for this DocumentPanel. A permission is allowed by default, but may be denied permanently by the Document'sEncryptionHandler
, or temporarily by a call tosetPermission(java.lang.String, boolean)
. The currently used list of permissions includes:- The document may be printed.
- Extract
- Text may be extracted from the document.
- Assemble
- The pages in the document may be added, removed, rotated or reordered.
- Annotate
- Annotations may be added, removed, moved around, or edited.
- FormFill
- Form fields may be filled in and the form submitted.
- PageEdit
- The page content may be edited, ie the page may be cropped or redacted
- Save
- The document may be saved.
-
setPermission
public void setPermission(String permission, boolean enable)
Sets whether the specified permission is allowed on this DocumentPanel.- Parameters:
permission
- the permissionenable
- true to allow the action, false otherwise- Since:
- 2.13
- See Also:
hasPermission(java.lang.String)
,setSignaturePermissionRestrictions(org.faceless.pdf2.FormSignature)
-
setSignaturePermissionRestrictions
public void setSignaturePermissionRestrictions(FormSignature sig)
Limit the permissions that can beset
on this PDF to ensure they don't conflict with thecertification
of this signature. This can be used to ensure that modifications to a PDF don't invalidate an existing digital siganture that disallows them. By default this is not the case, but setting therespectSignatureCertification
initialization-parameter will ensure those restrictions are respected. This method can be called withnull
to make the setting of permissions unrestricted.- Since:
- 2.13
- See Also:
hasPermission(java.lang.String)
,FormSignature.getCertificationType()
-
setAssociatedFile
public void setAssociatedFile(File file, boolean enableSave)
Set the associated File on this DocumentPanel. The file is the filename which the PDF is assumed to have originated - typically it is set automatically, but if the PDF was loaded into the viewer manually this method may be called later to update the filename- Parameters:
file
- the fileenableSave
- if true, the file was loaded from this source, and the "Save" option should enabled. If false, the file serves as an initial filename only (for instance, if the file was loaded from a URL, or a bitmap image).- Since:
- 2.24.3
-
setAssociatedFile
public void setAssociatedFile(File file)
Set the associated File on this DocumentPanel. CallssetAssociatedFile(file, true)
- Parameters:
file
- the file- Since:
- 2.18.1
-
getAssociatedFile
public File getAssociatedFile()
Get the associated File from this DocumentPanel. This is typically set automatically if the PDF was loaded via anImporter
, but may not be set if thePDFViewer.loadPDF(java.io.File)
method was used instead. ThesetAssociatedFile(java.io.File, boolean)
method can be called to set it in that case.- Returns:
- file the file associated with this DocumentPanel, which may be null if it hasn't been set.
- Since:
- 2.18.1
-
getAssociatedFileEnablesSave
public boolean getAssociatedFileEnablesSave()
Return true if the associated file was loaded as an "import".- Since:
- 2.24.3
-
schedule
public ScheduledFuture<?> schedule(Runnable r, long delay)
Schedule a timer task to run which is related to this DocmentPanel. The advantage of using this method over a standalone own timer is that all these tasks will be automatically cancelled when the DocumentPanel pdf is changed.- Parameters:
r
- the runnable task to rundelay
- the delay in ms from now to run the task- Returns:
- a ScheduledFuture which can be used to cancel the task
- Since:
- 2.20.4
-
focus
public void focus()
Make this DocumentPanel the active one in any parent PDFViewer- Since:
- 2.26
-
-