|
@@ -0,0 +1,189 @@
|
|
|
+/**
|
|
|
+ * Represents a document.
|
|
|
+ * @memberof Core
|
|
|
+ * @extends Core.EventHandler
|
|
|
+ */
|
|
|
+class Document extends EventHandler {
|
|
|
+ /**
|
|
|
+ * Constructs a new empty Document, representing a document with individual pages (canvases) that can be displayed on screen and printed.
|
|
|
+ * @param {string} id - Unique string identifier for the document
|
|
|
+ * @param {string} type - The type of document that should be instantiated. Values are 'xod' for XOD documents, 'pdf' for PDF, JPG or PNG documents, 'office' for MS Office documents and 'webviewerServer' for WebViewer Server documents
|
|
|
+ */
|
|
|
+ constructor(id, type) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * An enum representing the toggleable text styles in Office Editor.
|
|
|
+ * @property {string} BOLD - 'bold'
|
|
|
+ * @property {string} ITALIC - 'italic'
|
|
|
+ * @property {string} UNDERLINE - 'underline'
|
|
|
+ */
|
|
|
+ static get OfficeEditorToggleableStyles() {
|
|
|
+ return {
|
|
|
+ BOLD: 'bold',
|
|
|
+ ITALIC: 'italic',
|
|
|
+ UNDERLINE: 'underline'
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Register new document type with Document class
|
|
|
+ * @param {string} type - Name of the new document type
|
|
|
+ * @param {any} source - Class of the new document
|
|
|
+ * @param {Array.<string>} exposedFuncs - An array containing strings of the function names to expose on the document object
|
|
|
+ */
|
|
|
+ static registerDocumentType(type, source, exposedFuncs) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Cancels the loadCanvasAsync call corresponding to the passed in id
|
|
|
+ * @param {number} id - The id returned from the loadCanvasAsync call that will be cancelled.
|
|
|
+ */
|
|
|
+ cancelLoadCanvas(id) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Cancels the request made for thumbnail with the specified request Id
|
|
|
+ * @param {number} requestId - The id returned from loadThumbnailAsync
|
|
|
+ */
|
|
|
+ cancelLoadThumbnail(requestId) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * [PDF Document only] Extract the given pages from the document. Note that this method will need to wait for the entire file to be downloaded before the change is applied.
|
|
|
+ * @param {Array.<string>} pageArray - an array of the page numbers to extract
|
|
|
+ * @param {string} [xfdfString] - Optional XFDF string to merge into the document before extracting
|
|
|
+ * @returns {Promise.<any>} a promise that resolves on completion
|
|
|
+ */
|
|
|
+ extractPages(pageArray, xfdfString) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Gets the XFDF data for the document's internal annotations.
|
|
|
+ * @returns {Promise.<Core.Document.XFDFInfo>} A promise that resolves to an object with an xfdfString property and a pages property where pages is the array of page numbers that annotations were extracted from
|
|
|
+ */
|
|
|
+ extractXFDF() {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns an array containing the bookmarks in the document.
|
|
|
+ * @returns {Promise.<Array.<Core.Bookmark>>} A promise resolving to an array containing the bookmarks in the current document.
|
|
|
+ */
|
|
|
+ getBookmarks() {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * [PDF/Office Document only] Asynchronously saves the document and provides the result as an ArrayBuffer. To include annotations in the saved document, please provide an object with the xfdfString property.
|
|
|
+ * @param {Object} [options] - An optional object containing save options and parameters.
|
|
|
+ * @param {string} [options.xfdfString] - An xfdf string containing annotation data to be used when saving. This will usually be retrieved by calling exportAnnotations on a Core.AnnotationManager object.
|
|
|
+ * @param {boolean} [options.flatten] - A flag that is only useful when the xfdfString option is used. If true all the annotations in the saved document will be flattened.
|
|
|
+ * @param {boolean} [options.finishedWithDocument] - A flag specifying that the document data may be discarded by the worker after use. Only use this when completely finished with document processing. When handling larger documents this can be useful to avoid memory exhaustion as only one copy of the document needs to be kept.
|
|
|
+ * @param {boolean} [options.printDocument] - If true the saved document data will have an open action specifying that it should be printed. This is mostly only used to trigger print actions in the browser's PDF Viewer.
|
|
|
+ * @param {string} [options.downloadType] - The file type to download as, where the default is the source type. PDF and image files can only be downloaded as PDFs, but office files can be downloaded as "pdf" or as "office" if you want to get the original file without annotations.
|
|
|
+ * @param {number} [options.flags] - The flags with which to save the document. Possible values include Core.SaveOptions.REMOVE_UNUSED (remove unused objects during save) and Core.SaveOptions.LINEARIZED (optimize the document for fast web view and remove unused objects). The default value is Core.SaveOptions.REMOVE_UNUSED.
|
|
|
+ * @param {string} [options.password] - A string representing a password. If a non-empty password is used, the PDF document will be encrypted.
|
|
|
+ * @param {number} [options.encryptionAlgorithmType] - The encryption algorithm identifier. The default value is set to Use Crypt filters with 256-bit AES (Advanced Encryption Standard) algorithm: 4. 40-bit RC4 algorithm: 1, 128-bit RC4 algorithm: 2, Use Crypt filters with 128-bit AES (Advanced Encryption Standard) algorithm: 3, Use Crypt filters with 256-bit AES (Advanced Encryption Standard) algorithm: 4.
|
|
|
+ * @param {boolean} [options.includeAnnotations] - If false, all annotations will be removed from PDF document.
|
|
|
+ * @returns {Promise.<ArrayBuffer>} a promise that resolves to an array buffer containing PDF document bytes.
|
|
|
+ */
|
|
|
+ getFileData(options) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Get the document filename used for downloading.
|
|
|
+ * @returns {string} filename of the document.
|
|
|
+ */
|
|
|
+ getFilename() {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns the number of pages in a document.
|
|
|
+ * @returns {number} The number of the pages in the current document.
|
|
|
+ */
|
|
|
+ getPageCount() {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns an object with the original x and y coordinates converted to PDF coordinates for the page.
|
|
|
+ * @param {number} pageNumber - The page number that the coordinates are on
|
|
|
+ * @param {number} x - The x coordinate
|
|
|
+ * @param {number} y - The y coordinate
|
|
|
+ * @returns {object} An object with the x and y PDF coordinates
|
|
|
+ */
|
|
|
+ getPDFCoordinates(pageNumber, x, y) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns the PDFNet.PDFDoc object associated with the document. Note that the full API is required to be enabled and WebViewer Server cannot be enabled.
|
|
|
+ * @returns {Promise.<Core.PDFNet.PDFDoc>} A promise that resolves to the PDFDoc object.
|
|
|
+ */
|
|
|
+ getPDFDoc() {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * It returns the text that is within the Rect on the given page
|
|
|
+ * @param {number} pageNumber - The page number that the rect is on
|
|
|
+ * @param {Core.Math.Rect} rect - A Rect with x1,y1 representing the top-left and x2,y2 representing the bottom-right
|
|
|
+ * @returns {Promise.<string>} A promise that resolves to the extracted text
|
|
|
+ */
|
|
|
+ getTextByPageAndRect(pageNumber, rect) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * [PDF Document only] Inserts blank pages before the given list of pages. Both width and height are in units of PDF points.
|
|
|
+ * @param {Array.<number>} insertBeforeThesePages - array of page numbers before which to insert blanks
|
|
|
+ * @param {number} width - width of the blank pages to insert. By default the width is 612 PDF points.
|
|
|
+ * @param {number} height - height of the blank pages to insert. By default the height is 792 PDF points.
|
|
|
+ * @returns {Promise.<object>} a promise that resolves to an object with info for any pages inserted
|
|
|
+ */
|
|
|
+ insertBlankPages(insertBeforeThesePages, width, height) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * [PDF Document only] Inserts a set of pages from the provided Document before a given page number. Note that this method will need to wait for the entire file to be downloaded before the change is applied.
|
|
|
+ * @param {Core.Document} sourceDocument - other document from which to take pages (cannot be the same document)
|
|
|
+ * @param {Array.<number>} [pageArray] - An optional array of page numbers to extract from the given document. If not passed in, will insert all pages.
|
|
|
+ * @param {number} [insertBeforeThisPage] - An optional page number before which to insert the pages. If not passed in, will append to the end.
|
|
|
+ * @returns {Promise.<object>} a promise that resolves to an object describing the updated state of the pages in the document
|
|
|
+ */
|
|
|
+ insertPages(sourceDocument, pageArray, insertBeforeThisPage) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Gets all the text on the requested page.
|
|
|
+ * @param {number} pageNumber - The page number that the text is on.
|
|
|
+ * @returns {Promise.<string>} A promise that resolves with the page's text.
|
|
|
+ */
|
|
|
+ loadPageText(pageNumber) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * [PDF Document only] Merge a file into the currently opened document
|
|
|
+ * @param {string|File|ArrayBuffer|Blob} source - Source parameter, path/url to document or File.
|
|
|
+ * @param {number} position - Optional position for where to merge the document, default to end of file if nothing entered
|
|
|
+ * @returns {Promise.<any>} a promise that resolves on completion
|
|
|
+ */
|
|
|
+ mergeDocument(source, position) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * [PDF Document only] Moves the pages given in an array so they appear in sequence before a given page number. Note that this method will need to wait for the entire file to be downloaded before the change is applied.
|
|
|
+ * @param {Array.<number>} pageArray - the page numbers to move
|
|
|
+ * @param {number} insertBeforeThisPage - page number before which to insert the other pages
|
|
|
+ */
|
|
|
+ movePages(pageArray, insertBeforeThisPage) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Refresh the text data stored by the viewer. Useful if the text content of the document has changed, e.g. after a redaction.
|
|
|
+ */
|
|
|
+ refreshTextData() {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * [PDF Document only] Removes the given page numbers. Note that this method will need to wait for the entire file to be downloaded before the change is applied.
|
|
|
+ * @param {Array.<number>} pageArray - the page numbers to remove
|
|
|
+ * @returns {Promise.<object>} a promise that resolves to an object describing the updated state of the pages in the document
|
|
|
+ */
|
|
|
+ removePages(pageArray) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * [PDF Document only] Adds the given rotation to the given pages. Note that this method will need to wait for the entire file to be downloaded before the change is applied.
|
|
|
+ * @param {Array.<number>} pageArray - an array of the numbers of pages to rotate
|
|
|
+ * @param {Core.PageRotation} rotation - the page rotation to add
|
|
|
+ * @returns {Promise.<object>} a promise that resolves to an object describing the updated state of the pages in the document
|
|
|
+ */
|
|
|
+ rotatePages(pageArray, rotation) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Set the document filename used for downloading.
|
|
|
+ * @param {string} filename - Filename of the document.
|
|
|
+ */
|
|
|
+ setFilename(filename) {}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @typedef {object} Core.Document.OfficeEditorTextStyle
|
|
|
+ * @property {boolean} paragraphTextStyle -
|
|
|
+ */
|
|
|
+}
|