UNPKG

@softvision/webpdf-wsclient-typescript

Version:

A simplified and optimized API client library for the webPDF server

214 lines 10.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Annotation = void 0; const index_1 = require("./../index"); class Annotation { constructor(data) { this.appearance = index_1.Appearance.fromJson(data === null || data === void 0 ? void 0 : data.appearance); this.border = index_1.MetadataBorderStyle.fromJson(data === null || data === void 0 ? void 0 : data.border); let colorDefault = "#4800FF"; this.color = typeof (data === null || data === void 0 ? void 0 : data.color) !== "undefined" ? data === null || data === void 0 ? void 0 : data.color : colorDefault; let contentsDefault = ""; this.contents = typeof (data === null || data === void 0 ? void 0 : data.contents) !== "undefined" ? data === null || data === void 0 ? void 0 : data.contents : contentsDefault; this.drawStyle = index_1.DrawStyle.fromJson(data === null || data === void 0 ? void 0 : data.drawStyle); this.field = index_1.FieldAnnotation.fromJson(data === null || data === void 0 ? void 0 : data.field); let hiddenDefault = false; this.hidden = typeof (data === null || data === void 0 ? void 0 : data.hidden) !== "undefined" ? data === null || data === void 0 ? void 0 : data.hidden : hiddenDefault; let iconNameDefault = ""; this.iconName = typeof (data === null || data === void 0 ? void 0 : data.iconName) !== "undefined" ? data === null || data === void 0 ? void 0 : data.iconName : iconNameDefault; let invisibleDefault = false; this.invisible = typeof (data === null || data === void 0 ? void 0 : data.invisible) !== "undefined" ? data === null || data === void 0 ? void 0 : data.invisible : invisibleDefault; this.line = index_1.Line.fromJson(data === null || data === void 0 ? void 0 : data.line); let lockedDefault = true; this.locked = typeof (data === null || data === void 0 ? void 0 : data.locked) !== "undefined" ? data === null || data === void 0 ? void 0 : data.locked : lockedDefault; this.markup = index_1.Markup.fromJson(data === null || data === void 0 ? void 0 : data.markup); let nameDefault = ""; this.name = typeof (data === null || data === void 0 ? void 0 : data.name) !== "undefined" ? data === null || data === void 0 ? void 0 : data.name : nameDefault; let objectKeyDefault = ""; this.objectKey = typeof (data === null || data === void 0 ? void 0 : data.objectKey) !== "undefined" ? data === null || data === void 0 ? void 0 : data.objectKey : objectKeyDefault; let pageDefault = 0; this.page = typeof (data === null || data === void 0 ? void 0 : data.page) !== "undefined" ? data === null || data === void 0 ? void 0 : data.page : pageDefault; this.popup = index_1.Popup.fromJson(data === null || data === void 0 ? void 0 : data.popup); this.positions = (data.positions || []).map(index_1.Positions.fromJson); let printableDefault = false; this.printable = typeof (data === null || data === void 0 ? void 0 : data.printable) !== "undefined" ? data === null || data === void 0 ? void 0 : data.printable : printableDefault; let rotatableDefault = true; this.rotatable = typeof (data === null || data === void 0 ? void 0 : data.rotatable) !== "undefined" ? data === null || data === void 0 ? void 0 : data.rotatable : rotatableDefault; let rotationDefault = 0; this.rotation = typeof (data === null || data === void 0 ? void 0 : data.rotation) !== "undefined" ? data === null || data === void 0 ? void 0 : data.rotation : rotationDefault; let subTypeDefault = ""; this.subType = typeof (data === null || data === void 0 ? void 0 : data.subType) !== "undefined" ? data === null || data === void 0 ? void 0 : data.subType : subTypeDefault; let viewableDefault = true; this.viewable = typeof (data === null || data === void 0 ? void 0 : data.viewable) !== "undefined" ? data === null || data === void 0 ? void 0 : data.viewable : viewableDefault; let writableDefault = true; this.writable = typeof (data === null || data === void 0 ? void 0 : data.writable) !== "undefined" ? data === null || data === void 0 ? void 0 : data.writable : writableDefault; let zoomableDefault = true; this.zoomable = typeof (data === null || data === void 0 ? void 0 : data.zoomable) !== "undefined" ? data === null || data === void 0 ? void 0 : data.zoomable : zoomableDefault; } static getAppearanceDescription() { return ""; } static getBorderDescription() { return ""; } static getColorDefault() { return "#4800FF"; } static getColorDescription() { return "The main color of visible annotations. The color will be specified as a hexadecimal RGB value with a number sign before it."; } static getContentsDefault() { return ""; } static getContentsDescription() { return "The annotation's textual contents or (should an annotation of this type not have such contents) it's description."; } static getDrawStyleDescription() { return ""; } static getFieldDescription() { return ""; } static getHiddenDefault() { return false; } static getHiddenDescription() { return "If this value is set to true, the annotation will not be shown on the page and will not be printed either."; } static getIconNameDefault() { return ""; } static getIconNameDescription() { return "If the annotation selects an icon (Text annotations), this is the name of that icon."; } static getInvisibleDefault() { return false; } static getInvisibleDescription() { return "If this value is set to true, the annotation will be visible on the page only when printed, and provided it is a PDF standard annotation."; } static getLineDescription() { return ""; } static getLockedDefault() { return true; } static getLockedDescription() { return "If this value is set to true, the annotation will be locked so that no changes can be made to it."; } static getMarkupDescription() { return ""; } static getNameDefault() { return ""; } static getNameDescription() { return "The annotation's name.\n\n**Important:** This name is optional and in the best case unique in the annotation's page context only. Don't use the name to select an annotation, always prefer selecting objects by object ID, when possible."; } static getObjectKeyDefault() { return ""; } static getObjectKeyDescription() { return "The object ID of the annotation. **Info:** A PDF object ID consists of two numbers, where the first number selects the object's number and the second the \"generation\" of the object. The object ID shall always be unique within the context of the document and can be used to select a specific object."; } static getPageDefault() { return 0; } static getPageDescription() { return "The number of the page the annotation is placed on."; } static getPageMin() { return 0; } static getPopupDescription() { return ""; } static getPositionsDefault() { return []; } static getPositionsDescription() { return ""; } static getPrintableDefault() { return false; } static getPrintableDescription() { return "If this value is set to true, the annotation will be included when the page is printed out."; } static getRotatableDefault() { return true; } static getRotatableDescription() { return "If this value is set to true, the annotation shall be rotatable according to the displayed page rotation."; } static getRotationDefault() { return 0; } static getRotationDescription() { return "The annotation's rotation."; } static getSubTypeDefault() { return ""; } static getSubTypeDescription() { return "The type of an annotation is always \"Annot\", this is the sub type of the annotation determining the actual behavior and function of the annotation. (i.e. Text, Link, Widget etc.)"; } static getViewableDefault() { return true; } static getViewableDescription() { return "If this value is set to true, the annotation will be shown on the document's page."; } static getWritableDefault() { return true; } static getWritableDescription() { return "If this value is set to true, it will be possible to change the annotation's contents later on."; } static getZoomableDefault() { return true; } static getZoomableDescription() { return "If this value is set to true, the annotation will adjust its own zoom factor as required for the page in order to always be clearly readable \/ recognizable."; } static fromJson(data) { if (data === undefined || data === null) { return data; } return new Annotation(data); } toJson() { var _a, _b, _c, _d, _e, _f, _g, _h; return { 'appearance': (_a = this.appearance) === null || _a === void 0 ? void 0 : _a.toJson(), 'border': (_b = this.border) === null || _b === void 0 ? void 0 : _b.toJson(), 'color': this.color, 'contents': this.contents, 'drawStyle': (_c = this.drawStyle) === null || _c === void 0 ? void 0 : _c.toJson(), 'field': (_d = this.field) === null || _d === void 0 ? void 0 : _d.toJson(), 'hidden': this.hidden, 'iconName': this.iconName, 'invisible': this.invisible, 'line': (_e = this.line) === null || _e === void 0 ? void 0 : _e.toJson(), 'locked': this.locked, 'markup': (_f = this.markup) === null || _f === void 0 ? void 0 : _f.toJson(), 'name': this.name, 'objectKey': this.objectKey, 'page': this.page, 'popup': (_g = this.popup) === null || _g === void 0 ? void 0 : _g.toJson(), 'positions': (_h = this.positions) === null || _h === void 0 ? void 0 : _h.map((data) => data.toJson()), 'printable': this.printable, 'rotatable': this.rotatable, 'rotation': this.rotation, 'subType': this.subType, 'viewable': this.viewable, 'writable': this.writable, 'zoomable': this.zoomable, }; } clone() { return Annotation.fromJson(this.toJson()); } } exports.Annotation = Annotation; //# sourceMappingURL=Annotation.js.map