/*
* Copyright (c) 1997-2026 IDRsolutions (https://www.idrsolutions.com)
*/
package org.jpedal.examples.viewer;
/**
* An enum containing all the possible commands you can use with viewer.executeCommand()
*/
public enum ViewerCommands {
/*
* This list should be identical to Commands.java
*/
/** Show the About dialog with the version details. Does nothing if arguments are passed. */
ABOUT(1),
/** Show a dialog to export a range of pages as images. Does nothing if arguments are passed. */
BITMAP(2),
/** Show a dialog to extract the images embedded in a range of pages. Does nothing if arguments are passed. */
IMAGES(3),
/** Show a dialog to extract the text from a range of pages. Does nothing if arguments are passed. */
TEXT(4),
/** Show a dialog to save the open file. Does nothing if arguments are passed. */
SAVE(5),
/** Show the print dialog for the open document. Does nothing if arguments are passed. */
PRINT(6),
/**
* Close the document and the Viewer, saving the Viewer settings and warning about unsaved forms first. The JVM
* exits if {@link Viewer#exitOnClose} is true. Does nothing if arguments are passed.
*/
EXIT(7),
/**
* Toggle auto scrolling, which scrolls the view when the mouse is dragged past its edge. Does nothing if arguments
* are passed.
*/
AUTOSCROLL(8),
/** Show the document properties dialog. Does nothing if arguments are passed. */
DOCINFO(9),
/**
* Open a file. With no arguments a file chooser is shown. Otherwise, args are a File or String path, optionally
* followed by a String named destination to go to; an InputStream, optionally followed by a String file name; or a
* byte[] followed by a String file name. The file name's extension decides whether it is opened as a PDF or an
* image.
*/
OPENFILE(10),
/** Go to the page of a bookmark. The arg is the String bookmark title and must be passed. */
BOOKMARK(11),
/**
* Search the document. With no arguments the search window is shown, filled in with any highlighted text. Otherwise,
* args are the String search term, optionally followed by all three of an Integer of
* {@link org.jpedal.grouping.SearchType} flags, a Boolean for whether the term holds several words to search for
* separately, and a Boolean for whether to search only the current page. If all 3 optional values aren't present only the first is used.
*/
FIND(12),
/**
* Let the user drag an area of the page to extract as an image. Only works in single page view. Returns a Boolean
* that is true while waiting for the user to drag the area.
*/
SNAPSHOT(13),
/** Open a PDF from a URL. With no arguments a dialog asks for the URL. Otherwise, the arg is the String URL. */
OPENURL(14),
/** Open the IDRsolutions website in the default browser. Does nothing if arguments are passed. */
VISITWEBSITE(15),
/** Open the previous document in the recent documents list. Does nothing if arguments are passed. */
PREVIOUSDOCUMENT(16),
/** Open the next document in the recent documents list. Does nothing if arguments are passed. */
NEXTDOCUMENT(17),
/**
* Show the previous search result, wrapping round to the last result. Returns {@link Commands#SEARCH_RETURNED_TO_START},
* {@link Commands#SEARCH_NOT_FOUND}, {@link Commands#FIRST_DOCUMENT_SEARCH_RESULT_NOW_SHOWN} or null. Does nothing if arguments are
* passed.
*/
PREVIOUSRESULT(18),
/**
* Show the next search result, wrapping round to the first result. Returns {@link Commands#SEARCH_RETURNED_TO_START},
* {@link Commands#SEARCH_NOT_FOUND}, {@link Commands#FIRST_DOCUMENT_SEARCH_RESULT_NOW_SHOWN} or null. Does nothing if arguments are
* passed.
*/
NEXTRESULT(19),
/** Show the Tip of the Day dialog. Does nothing if arguments are passed. */
TIP(20),
/** Show the preferences dialog. Does nothing if arguments are passed. */
PREFERENCES(24),
/** Copy the highlighted text to the clipboard. Arguments are ignored. */
COPY(25),
/** Highlight all the text on the current page. Only works in single page view. Arguments are ignored. */
SELECTALL(26),
/** Clear all highlighted text and images. Only works in single page view. Arguments are ignored. */
DESELECTALL(27),
/**
* Show or hide part of the Viewer's GUI. Args are the String property name of the component and a Boolean for
* whether to show it. Does nothing unless exactly 2 arguments are passed.
*/
UPDATEGUILAYOUT(28),
/**
* Toggle the mouse between selecting text and panning the page. Not available in facing or page flow view. Does
* nothing if arguments are passed.
*/
MOUSEMODE(29),
/** Set the mouse to pan the page. Does nothing if arguments are passed. */
PANMODE(30),
/** Set the mouse to select text. Does nothing if arguments are passed. */
TEXTSELECT(31),
/**
* Toggle whether the first page is shown on its own in facing views, and save the setting. Does nothing if
* arguments are passed.
*/
SEPARATECOVER(32),
/** Show a dialog to extract the highlighted text. Does nothing if arguments are passed. */
EXTRACTTEXT(33),
/** Show a preview of the selected area as an image, which can be copied or saved. Arguments are ignored. */
EXTRACTASIMAGE(34),
/** Rotate the display 90 degrees anticlockwise. Arguments are ignored. */
ROTATELEFT(35),
/** Rotate the display 90 degrees clockwise. Arguments are ignored. */
ROTATERIGHT(36),
/**
* Open the current file in the operating system's default application. Optionally the arg is a String path of a
* different file to open.
*/
OPENINSYSTEMDEFAULT(37),
/** No longer handled: does nothing. There is no matching constant in Commands. */
XREF(38),
/** No longer handled: does nothing. There is no matching constant in Commands. */
OBJECTS(39),
/** Show the dialog to digitally sign the open file. Does nothing if arguments are passed. */
SIGN(40),
/** No longer handled: does nothing. There is no matching constant in Commands. */
XREFSTREAM(41),
/** Go to the first page. Does nothing if arguments are passed. */
FIRSTPAGE(50),
/** Go back 10 pages, stopping at the first page. Does nothing if arguments are passed. */
FBACKPAGE(51),
/** Go back 1 page. Optionally the arg is the number of pages to go back, as a String. */
BACKPAGE(52),
/** Go forward 1 page. Optionally the arg is the number of pages to go forward, as a String. */
FORWARDPAGE(53),
/** Go forward 10 pages, stopping at the last page. Does nothing if arguments are passed. */
FFORWARDPAGE(54),
/** Go to the last page. Does nothing if arguments are passed. */
LASTPAGE(55),
/**
* Go to a page. With no arguments a dialog asks for the page number. Otherwise the arg is the page number as a
* String.
*/
GOTO(56),
/** Show one page at a time and set the mouse to select text. Does nothing if arguments are passed. */
SINGLE(57),
/**
* Show the pages in a continuous vertical column and set the mouse to pan. Does nothing if arguments are passed.
*/
CONTINUOUS(58),
/**
* Show the pages in a continuous column of facing pairs, fit to the page, and set the mouse to pan. Does nothing if
* arguments are passed.
*/
CONTINUOUS_FACING(59),
/**
* Show the pages as facing pairs, fit to the page, and set the mouse to pan. Does nothing if arguments are passed.
*/
FACING(60),
/** Show the pages in the page flow view, which needs JavaFX. Does nothing if arguments are passed. */
PAGEFLOW(61),
/** Toggle full screen mode, if supported. Does nothing if arguments are passed. */
FULLSCREEN(62),
/** Zoom in to the next preset scaling, up to 1000%. Does nothing if arguments are passed. */
ZOOMIN(63),
/** Zoom out to the next preset scaling, down to 25%. Does nothing if arguments are passed. */
ZOOMOUT(64),
/** Show a PDF portfolio's files as a detailed list. Arguments are ignored. */
PORTFOLIO_DETAIL(65),
/** Show a PDF portfolio's files as tiles. Arguments are ignored. */
PORTFOLIO_TILES(66),
/**
* Rotate the display. With no arguments the rotation selected in the toolbar is applied. Otherwise, the arg is the
* rotation in degrees as a String: 0, 90, 180 or 270.
*/
ROTATION(251),
/**
* Set the scaling. With no arguments the scaling selected in the toolbar is applied. Otherwise, the arg is the
* scaling as a percentage number or one of the toolbar's text options, such as "Fit Width".
*/
SCALING(252),
/**
* Identifies the whole Swing menu bar, for showing, hiding, enabling or disabling it. Running it as a command does
* nothing.
*/
CURRENTMENU(300),
/**
* Identifies the Content menu in the Swing menu bar, for showing, hiding, enabling or disabling it. Running it as a
* command does nothing.
*/
CONTENTMENU(304),
/** Not used by the Viewer. Running it as a command does nothing. */
PDFMENU(306),
/**
* Identifies the Export menu in the Swing menu bar, for showing, hiding, enabling or disabling it. Running it as a
* command does nothing.
*/
EXPORTMENU(307),
/** Not used by the Viewer. Running it as a command does nothing. */
WINDOWMENU(308),
/**
* Identifies the Page Layout menu in the Swing menu bar, for showing, hiding, enabling or disabling it. Running it
* as a command does nothing.
*/
PAGELAYOUTMENU(309),
/**
* Identifies the Edit menu in the Swing menu bar, for showing, hiding, enabling or disabling it. Running it as a
* command does nothing.
*/
EDITMENU(310),
/**
* Identifies the Go To menu in the Swing menu bar, for showing, hiding, enabling or disabling it. Running it as a
* command does nothing.
*/
GOTOMENU(311),
/**
* Identifies the View menu in the Swing menu bar, for showing, hiding, enabling or disabling it. Running it as a
* command does nothing.
*/
VIEWMENU(312),
/**
* Identifies the Open menu in the Swing menu bar, for showing, hiding, enabling or disabling it. Running it as a
* command does nothing.
*/
OPENMENU(316),
/**
* Identifies the File menu in the Swing menu bar, for showing, hiding, enabling or disabling it. Running it as a
* command does nothing.
*/
FILEMENU(317),
/** Not used by the Viewer. The Help menu is identified by {@link #HELP}. Running it as a command does nothing. */
HELPFORUM(318),
/**
* Identifies the Portfolio menu, which is only shown for PDF portfolios, in the Swing menu bar, for showing,
* hiding, enabling or disabling it. Running it as a command does nothing.
*/
PORTFOLIOMENU(319),
/**
* Identifies the Tools menu in the Swing menu bar, for showing, hiding, enabling or disabling it. Running it as a
* command does nothing.
*/
TOOLSMENU(320),
/**
* Show a dialog to save the document after annotations have been added. If no annotation has been added, no file is
* written. Does nothing if arguments are passed.
*/
SAVEFORM(500),
/**
* Clear the current text highlights, then highlight areas on a page. Args are an int[][] of {x, y, width, height}
* rectangles in PDF coordinates, the Integer page, and an optional Boolean, default true, where true highlights the
* rectangles and false highlights whole lines from the top left to the bottom right. With no arguments the
* highlights are only cleared.
*/
HIGHLIGHT(600),
/**
* Scroll an area of a page into view. Args are an int[] {x, y, width, height} rectangle and an optional Integer
* page, default the current page. Does nothing with no arguments.
*/
SCROLL(601),
/**
* Add a view to the history used by {@link #FORWARD} and {@link #BACK}. Args are the Integer page, the Rectangle
* location and the Integer scaling type.
*/
ADDVIEW(700),
/** Go forward to the next view in the history added by {@link #ADDVIEW}. Arguments are ignored. */
FORWARD(701),
/** Go back to the previous view in the history added by {@link #ADDVIEW}. Arguments are ignored. */
BACK(702),
/* Part of the Value enum */
//PAGECOUNT(703),
//CURRENTPAGE(704),
//GETOUTLINEPANEL(705),
//GETTHUMBNAILPANEL(706),
//GETPAGECOUNTER(707),
/**
* Return the text grouping object for a page, decoding the page in the background if it is not the page being
* displayed. The arg is the Integer page. Returns null with no arguments or if an error occurs.
*/
PAGEGROUPING(708),
/** Set the page background colour and repaint. The arg is the colour as an Integer RGB value. */
SETPAGECOLOR(709),
/** Set the colour shown for pages that have not been drawn yet. The arg is the colour as an Integer RGB value. */
SETUNDRAWNPAGECOLOR(710),
/**
* Set the colour all text is drawn in, without repainting. The arg is the colour as an Integer RGB value.
* {@link #SETTEXTCOLOR} does the same and repaints.
*/
REPLACETEXTCOLOR(711),
/** Set the colour all text is drawn in and repaint. The arg is the colour as an Integer RGB value. */
SETTEXTCOLOR(712),
/**
* Set whether shapes and line art are recoloured along with the text when a text colour is set, then repaint. The
* arg is a Boolean.
*/
CHANGELINEART(713),
/**
* Set the background colour of the display area around the pages. The arg is the colour as an Integer RGB value.
*/
SETDISPLAYBACKGROUND(714),
/**
* Set the threshold that decides which text is recoloured when a text colour is set. The arg is the threshold as an
* Integer.
*/
SETREPLACEMENTCOLORTHRESHOLD(715),
/** Set whether lines thinner than 1 pixel are widened so they stay visible, then repaint. The arg is a Boolean. */
SETENHANCEFRACTIONALLINES(717),
/** Set whether all shapes are drawn with a 1 pixel stroke after scaling, then repaint. The arg is a Boolean. */
SETHIDELINEWEIGHTS(718),
/** Set whether interactive form fields are highlighted, then repaint. The arg is a Boolean. */
SETHIGHLIGHTFORMFIELDS(719),
/** Open the JPedal documentation in the default browser. Does nothing if arguments are passed. */
HELP(998),
/** Open the JPedal pricing page in the default browser. Does nothing if arguments are passed. */
BUY(999),
/**
* Debug command that resets the Viewer's internal viewport scale and offsets. Does nothing if arguments are passed.
* @hidden
*/
RESET(1_002),
/**
* Debug command that turns on hardware acceleration for screen rendering and repaints. Does nothing if arguments
* are passed.
* @hidden
*/
ACCELERATIONON(1_003),
/**
* Debug command that turns off hardware acceleration for screen rendering and repaints. Does nothing if arguments
* are passed.
* @hidden
*/
ACCELERATIONOFF(1_004),
/**
* Debug command that prints the names of all form fields to standard out. Does nothing if arguments are passed.
* @hidden
*/
SHOWFORMNAMES(1_006),
/**
* Debug command that makes the Viewer delete its properties file when its window is closed. Does nothing if
* arguments are passed.
* @hidden
*/
DELETEPROPERTIESONEXIT(1_007),
/**
* Debug command that toggles whether the mouse cursor is always shown. Does nothing if arguments are passed.
* @hidden
*/
ALWAYSSHOWMOUSE(1_008),
/**
* Debug command that calls {@link System#gc()}. Does nothing if arguments are passed.
* @hidden
*/
TRIGGERGC(1_009),
/** Remove the version number from the window title. Arguments are ignored. */
HIDEVERSIONNUMBER(720),
/** Show the version number in the window title. Arguments are ignored. */
SHOWVERSIONNUMBER(721),
/**
* Show a dialog to insert blank pages of a chosen size, then save the document (asking whether to overwrite the
* open file) and reopen it. Does nothing if arguments are passed.
*/
ADDPAGE(1_101),
/**
* Show a dialog to choose pages and an image, then let the user drag the area to place it in, then save the
* document (asking whether to overwrite the open file) and reopen it. Does nothing if arguments are passed.
*/
ADDIMAGE(1_102),
/**
* Show a dialog to copy a page to another position, then save the document (asking whether to overwrite the open
* file) and reopen it. Does nothing if arguments are passed.
*/
COPYPAGE(1_103),
/**
* Show a dialog to crop pages, then save the document (asking whether to overwrite the open file) and reopen it.
* Does nothing if arguments are passed.
*/
CROPPAGE(1_104),
/**
* Show a dialog to embed a file in the document as an attachment, then save the document (asking whether to
* overwrite the open file) and reopen it. Does nothing if arguments are passed.
*/
EMBEDFILE(1_105),
/**
* Show a dialog to choose pages to keep, removing all the others, then save the document (asking whether to
* overwrite the open file) and reopen it. Does nothing if arguments are passed.
*/
ISOLATEPAGE(1_106),
/**
* Show a dialog to combine several pages onto each page in a grid of rows and columns, then save the document
* (asking whether to overwrite the open file) and reopen it. Does nothing if arguments are passed.
*/
NUP(1_107),
/**
* Show a dialog to remove pages, then save the document (asking whether to overwrite the open file) and reopen it.
* Does nothing if arguments are passed.
*/
REMOVEPAGE(1_108),
/**
* Show a dialog to rotate pages, then save the document (asking whether to overwrite the open file) and reopen it.
* Does nothing if arguments are passed.
*/
ROTATEPAGE(1_109),
/**
* Show a dialog to scale pages, then save the document (asking whether to overwrite the open file) and reopen it.
* Does nothing if arguments are passed.
*/
SCALEPAGE(1_110),
/**
* Show a dialog to edit the document information, which is written to both the Info dictionary and the XMP
* metadata, then save the document (asking whether to overwrite the open file) and reopen it. Does nothing if
* arguments are passed.
*/
SETDOCUMENTINFO(1_112),
/**
* Show a dialog to set the page, page layout and page mode the document opens with, then save the document (asking
* whether to overwrite the open file) and reopen it. Does nothing if arguments are passed.
*/
SETINITIALVIEW(1_113),
/**
* Remove all bookmarks, then save the document (asking whether to overwrite the open file) and reopen it. Does
* nothing if arguments are passed.
*/
REMOVEBOOKMARKS(1_114),
/**
* Remove all embedded files, then save the document (asking whether to overwrite the open file) and reopen it. Does
* nothing if arguments are passed.
*/
REMOVEEMBEDDEDFILES(1_115),
/**
* Remove the initial view settings, then save the document (asking whether to overwrite the open file) and reopen
* it. Does nothing if arguments are passed.
*/
REMOVEINITIALVIEW(1_116),
/**
* Remove all JavaScript, then save the document (asking whether to overwrite the open file) and reopen it. Does
* nothing if arguments are passed.
*/
REMOVEJAVASCRIPT(1_117),
/**
* Remove all links, then save the document (asking whether to overwrite the open file) and reopen it. Does nothing
* if arguments are passed.
*/
REMOVELINKS(1_118),
/**
* Remove the document metadata, then save the document (asking whether to overwrite the open file) and reopen it.
* Does nothing if arguments are passed.
*/
REMOVEMETADATA(1_119),
/**
* Show a dialog to move a page to another position, then save the document (asking whether to overwrite the open
* file) and reopen it. Does nothing if arguments are passed.
*/
MOVEPAGE(1_120),
/**
* Show a dialog to choose pages to remove annotations from, then save the document (asking whether to overwrite the
* open file) and reopen it. Does nothing if arguments are passed.
*/
REMOVEANNOTATIONS(1_121),
/**
* Reverse the page order, then save the document (asking whether to overwrite the open file) and reopen it. Does
* nothing if arguments are passed.
*/
REVERSEPAGES(1_122),
/**
* Show a dialog to choose pages, then let the user drag the area of text to redact, then save the document (asking
* whether to overwrite the open file) and reopen it. Does nothing if arguments are passed.
*/
REDACT(1_123),
/**
* Downsample all images using the default settings, then save the document (asking whether to overwrite the open
* file) and reopen it. Does nothing if arguments are passed.
*/
DOWNSAMPLEIMAGES(1_124),
/**
* Flatten all layers, removing hidden layers and making visible layers permanent, then save the document (asking
* whether to overwrite the open file) and reopen it. Does nothing if arguments are passed.
*/
FLATTENLAYERS(1_125),
/**
* Optimise image colour palettes to fit an indexed colour space, losslessly reducing image size, then save the
* document (asking whether to overwrite the open file) and reopen it. Does nothing if arguments are passed.
*/
OPTIMIZECOLORPALETTE(1_126),
/**
* Remove blank pages, then save the document (asking whether to overwrite the open file) and reopen it. Does
* nothing if arguments are passed.
*/
REMOVEBLANKPAGES(1_127),
/**
* Remove all digital signatures, then save the document (asking whether to overwrite the open file) and reopen it.
* Does nothing if arguments are passed.
*/
REMOVEDIGITALSIGNATURES(1_128);
final int commandID;
ViewerCommands(final int commandID) {
this.commandID = commandID;
}
/**
* Returns the command with the given ID, which is the value of the matching constant in {@link Commands}.
*
* @param id the command ID
* @return the matching command, or null if no command has that ID
*/
public static ViewerCommands createFromID(final int id) {
for (final ViewerCommands value : values()) {
if (value.commandID == id) {
return value;
}
}
return null;
}
}
|