Document builder features
In document builder mode, you can manipulate documents, perform multiple actions on pages, and use HTML and JavaScript APIs to configure more actions.
Opening or creating a document
In document builder mode, you can perform actions on an existing, already open document, or a new blank document.
You can create an empty document, to which you add pages. To create a docbuilder file, the viewer
must be in document builder mode and you must either set the filename parameter to
'about:blank', or you must call the JavaScript API method openFile(String filename, int page) with openFile('about:blank',
0).
If the viewer is not in the document builder mode, the viewer acts as if no document is open. If
you do not provide the filename parameter in document builder mode, it means that
no document is open, rather than a new document being open.
When you add pages to an empty documents, a new document can be built, but you cannot switch to annotation or redaction mode.
If a document that is opened in document builder mode has security restrictions that preclude user modification, then the commit process fails. You can know whether a document can be built or not by opening the document and calling the following JavaScript API method:
ViewONE.isDocumentBuildable()
This call returns a Boolean value which indicates whether the document is able to be modified in Document Builder Mode. For more information about the commit process, see Building the document.
Page selection
When the Thumbnails view is visible, you can select pages and perform different types of actions on these pages.
- Single selection
-
When you select a single page by clicking on the thumbnail or viewing the page in the main view, you can apply actions to the current selected page, such as actions cutting, copying, and rotating. If you add or paste a page, the new page is inserted after the current selected page.
- Multi-selection
-
When the Thumbnails view is present, you can select multiple pages at the same time:
- Hold SHIFT and select a thumbnail to select all pages between the originally selected page and the newly selected page.
- Hold CTRL and select a thumbnail to add the newly selected page to the current selection.
When you have selected multiple pages at the same time, actions such as cut, copy, or rotate apply to all the pages selected. When you add or paste a page, it is inserted after the last selected page in the range.
- Caret Selection
-
In the previous cases, inserting a page (by adding or pasting) occurs after the current or last selected page in a selection. To insert a page before the currently selected page, you can use caret selection. When the Thumbnails view is in a vertical alignment, you can select a caret by clicking the space above the current thumbnail. The current thumbnail is still the same page as you can view in the main view, but a horizontal pipe is displayed between the current and previous thumbnail. This indicates that when you insert a page, it is inserted between those two pages.
When a caret is selected all other options other than insertion are disabled.
- Selection by using JavaScript
-
You can use the JavaScript API setPageSelection method to create a page selection without using the user interface. With this method, you can select the pages that are specified by the attribute
PageSelectionand you can set the active page (the page visible in the main view) with theactivePageattribute.When you create or modify a selection by using any of the previous selection option, the event
Page Selection Updated(event ID: 87) is fired. This event contains a JSON payload, which details the pages that are included in the selection and whether the caret is selected.For example, if you selected pages 1, 3, and 10 in the viewer, event 87 would contain the following JSON payload:{"selectedPages":[{"page":{"pageNumber":1, "pipe":false}},{"page":{"pageNumber":3, "pipe":false}},{"page":{"pageNumber":10, "pipe":false}}]}Another example, if you selected the caret before page 1 in the viewer, event 87 would contain the following JSON payload:{"selectedPages":[{"page":{"pageNumber":1, "pipe":true}}]}If you added a page with this selection, the new page would be number 1, and if the caret was
false, it would be page number 2.
Page actions
In document builder edit mode, whenever a document builder action is performed that results in a
change to the document structure, the event Document Changed (event ID: 84) is
fired. This event includes a JSON payload that contains the actions that caused that particular
change in the document. For example, movePage(1, 5) causes a Document
Changed event with a JSON payload that contains two actions: A "remove pages" action for
page 1 and a "copy pages" action for page 1 to move to position 5.
The following actions result in an event 84 to be fired:
- Add
-
To add a page to a new or existing document, use the clipboard or the JavaScript API addDocumentPage.
When a page is added to the document, the
Page Addedevent (event ID: 81) is fired. - Delete
-
To delete a single page, select your page and click Cut, or use the JavaScript API deleteDocumentPage.
To delete multiple pages, use multi-selection to select your pages and click Cut, or use the JavaScript API deleteDocumentPages method.
- Move
-
To move a page, use the Cut and Paste options, or use the JavaScript API movePage.
- Cut, Copy & Paste
-
Use the Cut, Copy, and Paste options in the top toolbar. Those options are available across viewers, which means that two viewers can be open in a single browser window and both display separate documents. In this case, you can cut and copy pages from one document to the other.
- Rotate
-
To rotate a page, select your page and click Rotate, or use the JavaScript API rotateClockwise or rotateCounterclockwise().
Any rotations that you apply to a page in the current document are applied to the built document.
Additional configurations
You can configure the document builder mode further with HTML and JavaScript APIs.
- Set output mime type
-
Use the following HTML parameter to set the output type of the document that is generated for the document builder. It takes a mime type as the value
application/pdf. For any other values, the document builder defaults to generating PDF documents.<param name=”documentBuilderOutputMimeType” value=”application/pdf” /> - Switch edit modes
-
See the setEditModeToolbarVisible() method to set whether you can switch between edit modes by using the toolbar.
- Get the action used to add content to the clipboard
-
The method getClipboardContentActionType(int pageNumber) returns whether it was a cut or a copy action that created the document content used to copy pages in document builder mode. The
pageNumberparameter specifies the page in the document content to retrieve the action for. If the page data is present in the document content, the stringcutorcopyis returned, otherwise an empty string is returned. - Retrieve the current mode state
-
The method getModeState() retrieves the state of the current mode. This feature is supported only for document builder mode. When you call this method, a JSON payload is returned, which represents the current state of the recipe constructed from the actions that were performed on the loaded document.
- Clear clipboard content
-
The method clearClipboardContent() clears any content on the clipboard.