How to use FreeTextAnnotationElement method in wpt

Best JavaScript code snippet using wpt

annotation_layer.js

Source:annotation_layer.js Github

copy

Full Screen

...70 return new WidgetAnnotationElement(parameters);71 case _util.AnnotationType.POPUP:72 return new PopupAnnotationElement(parameters);73 case _util.AnnotationType.FREETEXT:74 return new FreeTextAnnotationElement(parameters);75 case _util.AnnotationType.LINE:76 return new LineAnnotationElement(parameters);77 case _util.AnnotationType.SQUARE:78 return new SquareAnnotationElement(parameters);79 case _util.AnnotationType.CIRCLE:80 return new CircleAnnotationElement(parameters);81 case _util.AnnotationType.POLYLINE:82 return new PolylineAnnotationElement(parameters);83 case _util.AnnotationType.CARET:84 return new CaretAnnotationElement(parameters);85 case _util.AnnotationType.INK:86 return new InkAnnotationElement(parameters);87 case _util.AnnotationType.POLYGON:88 return new PolygonAnnotationElement(parameters);89 case _util.AnnotationType.HIGHLIGHT:90 return new HighlightAnnotationElement(parameters);91 case _util.AnnotationType.UNDERLINE:92 return new UnderlineAnnotationElement(parameters);93 case _util.AnnotationType.SQUIGGLY:94 return new SquigglyAnnotationElement(parameters);95 case _util.AnnotationType.STRIKEOUT:96 return new StrikeOutAnnotationElement(parameters);97 case _util.AnnotationType.STAMP:98 return new StampAnnotationElement(parameters);99 case _util.AnnotationType.FILEATTACHMENT:100 return new FileAttachmentAnnotationElement(parameters);101 default:102 return new AnnotationElement(parameters);103 }104 }105 }]);106 return AnnotationElementFactory;107}();108var AnnotationElement =109/*#__PURE__*/110function () {111 function AnnotationElement(parameters) {112 var isRenderable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;113 var ignoreBorder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;114 _classCallCheck(this, AnnotationElement);115 this.isRenderable = isRenderable;116 this.data = parameters.data;117 this.layer = parameters.layer;118 this.page = parameters.page;119 this.viewport = parameters.viewport;120 this.linkService = parameters.linkService;121 this.downloadManager = parameters.downloadManager;122 this.imageResourcesPath = parameters.imageResourcesPath;123 this.renderInteractiveForms = parameters.renderInteractiveForms;124 this.svgFactory = parameters.svgFactory;125 if (isRenderable) {126 this.container = this._createContainer(ignoreBorder);127 }128 }129 _createClass(AnnotationElement, [{130 key: "_createContainer",131 value: function _createContainer() {132 var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;133 var data = this.data,134 page = this.page,135 viewport = this.viewport;136 var container = document.createElement('section');137 var width = data.rect[2] - data.rect[0];138 var height = data.rect[3] - data.rect[1];139 container.setAttribute('data-annotation-id', data.id);140 var rect = _util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);141 container.style.transform = 'matrix(' + viewport.transform.join(',') + ')';142 container.style.transformOrigin = -rect[0] + 'px ' + -rect[1] + 'px';143 if (!ignoreBorder && data.borderStyle.width > 0) {144 container.style.borderWidth = data.borderStyle.width + 'px';145 if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {146 width = width - 2 * data.borderStyle.width;147 height = height - 2 * data.borderStyle.width;148 }149 var horizontalRadius = data.borderStyle.horizontalCornerRadius;150 var verticalRadius = data.borderStyle.verticalCornerRadius;151 if (horizontalRadius > 0 || verticalRadius > 0) {152 var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';153 container.style.borderRadius = radius;154 }155 switch (data.borderStyle.style) {156 case _util.AnnotationBorderStyleType.SOLID:157 container.style.borderStyle = 'solid';158 break;159 case _util.AnnotationBorderStyleType.DASHED:160 container.style.borderStyle = 'dashed';161 break;162 case _util.AnnotationBorderStyleType.BEVELED:163 (0, _util.warn)('Unimplemented border style: beveled');164 break;165 case _util.AnnotationBorderStyleType.INSET:166 (0, _util.warn)('Unimplemented border style: inset');167 break;168 case _util.AnnotationBorderStyleType.UNDERLINE:169 container.style.borderBottomStyle = 'solid';170 break;171 default:172 break;173 }174 if (data.color) {175 container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);176 } else {177 container.style.borderWidth = 0;178 }179 }180 container.style.left = rect[0] + 'px';181 container.style.top = rect[1] + 'px';182 container.style.width = width + 'px';183 container.style.height = height + 'px';184 return container;185 }186 }, {187 key: "_createPopup",188 value: function _createPopup(container, trigger, data) {189 if (!trigger) {190 trigger = document.createElement('div');191 trigger.style.height = container.style.height;192 trigger.style.width = container.style.width;193 container.appendChild(trigger);194 }195 var popupElement = new PopupElement({196 container: container,197 trigger: trigger,198 color: data.color,199 title: data.title,200 modificationDate: data.modificationDate,201 contents: data.contents,202 hideWrapper: true203 });204 var popup = popupElement.render();205 popup.style.left = container.style.width;206 container.appendChild(popup);207 }208 }, {209 key: "render",210 value: function render() {211 (0, _util.unreachable)('Abstract method `AnnotationElement.render` called');212 }213 }]);214 return AnnotationElement;215}();216var LinkAnnotationElement =217/*#__PURE__*/218function (_AnnotationElement) {219 _inherits(LinkAnnotationElement, _AnnotationElement);220 function LinkAnnotationElement(parameters) {221 _classCallCheck(this, LinkAnnotationElement);222 var isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);223 return _possibleConstructorReturn(this, _getPrototypeOf(LinkAnnotationElement).call(this, parameters, isRenderable));224 }225 _createClass(LinkAnnotationElement, [{226 key: "render",227 value: function render() {228 this.container.className = 'linkAnnotation';229 var data = this.data,230 linkService = this.linkService;231 var link = document.createElement('a');232 (0, _display_utils.addLinkAttributes)(link, {233 url: data.url,234 target: data.newWindow ? _display_utils.LinkTarget.BLANK : linkService.externalLinkTarget,235 rel: linkService.externalLinkRel236 });237 if (!data.url) {238 if (data.action) {239 this._bindNamedAction(link, data.action);240 } else {241 this._bindLink(link, data.dest);242 }243 }244 this.container.appendChild(link);245 return this.container;246 }247 }, {248 key: "_bindLink",249 value: function _bindLink(link, destination) {250 var _this = this;251 link.href = this.linkService.getDestinationHash(destination);252 link.onclick = function () {253 if (destination) {254 _this.linkService.navigateTo(destination);255 }256 return false;257 };258 if (destination) {259 link.className = 'internalLink';260 }261 }262 }, {263 key: "_bindNamedAction",264 value: function _bindNamedAction(link, action) {265 var _this2 = this;266 link.href = this.linkService.getAnchorUrl('');267 link.onclick = function () {268 _this2.linkService.executeNamedAction(action);269 return false;270 };271 link.className = 'internalLink';272 }273 }]);274 return LinkAnnotationElement;275}(AnnotationElement);276var TextAnnotationElement =277/*#__PURE__*/278function (_AnnotationElement2) {279 _inherits(TextAnnotationElement, _AnnotationElement2);280 function TextAnnotationElement(parameters) {281 _classCallCheck(this, TextAnnotationElement);282 var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);283 return _possibleConstructorReturn(this, _getPrototypeOf(TextAnnotationElement).call(this, parameters, isRenderable));284 }285 _createClass(TextAnnotationElement, [{286 key: "render",287 value: function render() {288 this.container.className = 'textAnnotation';289 var image = document.createElement('img');290 image.style.height = this.container.style.height;291 image.style.width = this.container.style.width;292 image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';293 image.alt = '[{{type}} Annotation]';294 image.dataset.l10nId = 'text_annotation_type';295 image.dataset.l10nArgs = JSON.stringify({296 type: this.data.name297 });298 if (!this.data.hasPopup) {299 this._createPopup(this.container, image, this.data);300 }301 this.container.appendChild(image);302 return this.container;303 }304 }]);305 return TextAnnotationElement;306}(AnnotationElement);307var WidgetAnnotationElement =308/*#__PURE__*/309function (_AnnotationElement3) {310 _inherits(WidgetAnnotationElement, _AnnotationElement3);311 function WidgetAnnotationElement() {312 _classCallCheck(this, WidgetAnnotationElement);313 return _possibleConstructorReturn(this, _getPrototypeOf(WidgetAnnotationElement).apply(this, arguments));314 }315 _createClass(WidgetAnnotationElement, [{316 key: "render",317 value: function render() {318 return this.container;319 }320 }]);321 return WidgetAnnotationElement;322}(AnnotationElement);323var TextWidgetAnnotationElement =324/*#__PURE__*/325function (_WidgetAnnotationElem) {326 _inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem);327 function TextWidgetAnnotationElement(parameters) {328 _classCallCheck(this, TextWidgetAnnotationElement);329 var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;330 return _possibleConstructorReturn(this, _getPrototypeOf(TextWidgetAnnotationElement).call(this, parameters, isRenderable));331 }332 _createClass(TextWidgetAnnotationElement, [{333 key: "render",334 value: function render() {335 var TEXT_ALIGNMENT = ['left', 'center', 'right'];336 this.container.className = 'textWidgetAnnotation';337 var element = null;338 if (this.renderInteractiveForms) {339 if (this.data.multiLine) {340 element = document.createElement('textarea');341 element.textContent = this.data.fieldValue;342 } else {343 element = document.createElement('input');344 element.type = 'text';345 element.setAttribute('value', this.data.fieldValue);346 }347 element.disabled = this.data.readOnly;348 if (this.data.maxLen !== null) {349 element.maxLength = this.data.maxLen;350 }351 if (this.data.comb) {352 var fieldWidth = this.data.rect[2] - this.data.rect[0];353 var combWidth = fieldWidth / this.data.maxLen;354 element.classList.add('comb');355 element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';356 }357 } else {358 element = document.createElement('div');359 element.textContent = this.data.fieldValue;360 element.style.verticalAlign = 'middle';361 element.style.display = 'table-cell';362 var font = null;363 if (this.data.fontRefName && this.page.commonObjs.has(this.data.fontRefName)) {364 font = this.page.commonObjs.get(this.data.fontRefName);365 }366 this._setTextStyle(element, font);367 }368 if (this.data.textAlignment !== null) {369 element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];370 }371 this.container.appendChild(element);372 return this.container;373 }374 }, {375 key: "_setTextStyle",376 value: function _setTextStyle(element, font) {377 var style = element.style;378 style.fontSize = this.data.fontSize + 'px';379 style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';380 if (!font) {381 return;382 }383 style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';384 style.fontStyle = font.italic ? 'italic' : 'normal';385 var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';386 var fallbackName = font.fallbackName || 'Helvetica, sans-serif';387 style.fontFamily = fontFamily + fallbackName;388 }389 }]);390 return TextWidgetAnnotationElement;391}(WidgetAnnotationElement);392var CheckboxWidgetAnnotationElement =393/*#__PURE__*/394function (_WidgetAnnotationElem2) {395 _inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2);396 function CheckboxWidgetAnnotationElement(parameters) {397 _classCallCheck(this, CheckboxWidgetAnnotationElement);398 return _possibleConstructorReturn(this, _getPrototypeOf(CheckboxWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));399 }400 _createClass(CheckboxWidgetAnnotationElement, [{401 key: "render",402 value: function render() {403 this.container.className = 'buttonWidgetAnnotation checkBox';404 var element = document.createElement('input');405 element.disabled = this.data.readOnly;406 element.type = 'checkbox';407 if (this.data.fieldValue && this.data.fieldValue !== 'Off') {408 element.setAttribute('checked', true);409 }410 this.container.appendChild(element);411 return this.container;412 }413 }]);414 return CheckboxWidgetAnnotationElement;415}(WidgetAnnotationElement);416var RadioButtonWidgetAnnotationElement =417/*#__PURE__*/418function (_WidgetAnnotationElem3) {419 _inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3);420 function RadioButtonWidgetAnnotationElement(parameters) {421 _classCallCheck(this, RadioButtonWidgetAnnotationElement);422 return _possibleConstructorReturn(this, _getPrototypeOf(RadioButtonWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));423 }424 _createClass(RadioButtonWidgetAnnotationElement, [{425 key: "render",426 value: function render() {427 this.container.className = 'buttonWidgetAnnotation radioButton';428 var element = document.createElement('input');429 element.disabled = this.data.readOnly;430 element.type = 'radio';431 element.name = this.data.fieldName;432 if (this.data.fieldValue === this.data.buttonValue) {433 element.setAttribute('checked', true);434 }435 this.container.appendChild(element);436 return this.container;437 }438 }]);439 return RadioButtonWidgetAnnotationElement;440}(WidgetAnnotationElement);441var PushButtonWidgetAnnotationElement =442/*#__PURE__*/443function (_LinkAnnotationElemen) {444 _inherits(PushButtonWidgetAnnotationElement, _LinkAnnotationElemen);445 function PushButtonWidgetAnnotationElement() {446 _classCallCheck(this, PushButtonWidgetAnnotationElement);447 return _possibleConstructorReturn(this, _getPrototypeOf(PushButtonWidgetAnnotationElement).apply(this, arguments));448 }449 _createClass(PushButtonWidgetAnnotationElement, [{450 key: "render",451 value: function render() {452 var container = _get(_getPrototypeOf(PushButtonWidgetAnnotationElement.prototype), "render", this).call(this);453 container.className = 'buttonWidgetAnnotation pushButton';454 return container;455 }456 }]);457 return PushButtonWidgetAnnotationElement;458}(LinkAnnotationElement);459var ChoiceWidgetAnnotationElement =460/*#__PURE__*/461function (_WidgetAnnotationElem4) {462 _inherits(ChoiceWidgetAnnotationElement, _WidgetAnnotationElem4);463 function ChoiceWidgetAnnotationElement(parameters) {464 _classCallCheck(this, ChoiceWidgetAnnotationElement);465 return _possibleConstructorReturn(this, _getPrototypeOf(ChoiceWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));466 }467 _createClass(ChoiceWidgetAnnotationElement, [{468 key: "render",469 value: function render() {470 this.container.className = 'choiceWidgetAnnotation';471 var selectElement = document.createElement('select');472 selectElement.disabled = this.data.readOnly;473 if (!this.data.combo) {474 selectElement.size = this.data.options.length;475 if (this.data.multiSelect) {476 selectElement.multiple = true;477 }478 }479 for (var i = 0, ii = this.data.options.length; i < ii; i++) {480 var option = this.data.options[i];481 var optionElement = document.createElement('option');482 optionElement.textContent = option.displayValue;483 optionElement.value = option.exportValue;484 if (this.data.fieldValue.includes(option.displayValue)) {485 optionElement.setAttribute('selected', true);486 }487 selectElement.appendChild(optionElement);488 }489 this.container.appendChild(selectElement);490 return this.container;491 }492 }]);493 return ChoiceWidgetAnnotationElement;494}(WidgetAnnotationElement);495var PopupAnnotationElement =496/*#__PURE__*/497function (_AnnotationElement4) {498 _inherits(PopupAnnotationElement, _AnnotationElement4);499 function PopupAnnotationElement(parameters) {500 _classCallCheck(this, PopupAnnotationElement);501 var isRenderable = !!(parameters.data.title || parameters.data.contents);502 return _possibleConstructorReturn(this, _getPrototypeOf(PopupAnnotationElement).call(this, parameters, isRenderable));503 }504 _createClass(PopupAnnotationElement, [{505 key: "render",506 value: function render() {507 var IGNORE_TYPES = ['Line', 'Square', 'Circle', 'PolyLine', 'Polygon', 'Ink'];508 this.container.className = 'popupAnnotation';509 if (IGNORE_TYPES.includes(this.data.parentType)) {510 return this.container;511 }512 var selector = '[data-annotation-id="' + this.data.parentId + '"]';513 var parentElement = this.layer.querySelector(selector);514 if (!parentElement) {515 return this.container;516 }517 var popup = new PopupElement({518 container: this.container,519 trigger: parentElement,520 color: this.data.color,521 title: this.data.title,522 modificationDate: this.data.modificationDate,523 contents: this.data.contents524 });525 var parentLeft = parseFloat(parentElement.style.left);526 var parentWidth = parseFloat(parentElement.style.width);527 this.container.style.transformOrigin = -(parentLeft + parentWidth) + 'px -' + parentElement.style.top;528 this.container.style.left = parentLeft + parentWidth + 'px';529 this.container.appendChild(popup.render());530 return this.container;531 }532 }]);533 return PopupAnnotationElement;534}(AnnotationElement);535var PopupElement =536/*#__PURE__*/537function () {538 function PopupElement(parameters) {539 _classCallCheck(this, PopupElement);540 this.container = parameters.container;541 this.trigger = parameters.trigger;542 this.color = parameters.color;543 this.title = parameters.title;544 this.modificationDate = parameters.modificationDate;545 this.contents = parameters.contents;546 this.hideWrapper = parameters.hideWrapper || false;547 this.pinned = false;548 }549 _createClass(PopupElement, [{550 key: "render",551 value: function render() {552 var BACKGROUND_ENLIGHT = 0.7;553 var wrapper = document.createElement('div');554 wrapper.className = 'popupWrapper';555 this.hideElement = this.hideWrapper ? wrapper : this.container;556 this.hideElement.setAttribute('hidden', true);557 var popup = document.createElement('div');558 popup.className = 'popup';559 var color = this.color;560 if (color) {561 var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];562 var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];563 var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];564 popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);565 }566 var title = document.createElement('h1');567 title.textContent = this.title;568 popup.appendChild(title);569 var dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate);570 if (dateObject) {571 var modificationDate = document.createElement('span');572 modificationDate.textContent = '{{date}}, {{time}}';573 modificationDate.dataset.l10nId = 'annotation_date_string';574 modificationDate.dataset.l10nArgs = JSON.stringify({575 date: dateObject.toLocaleDateString(),576 time: dateObject.toLocaleTimeString()577 });578 popup.appendChild(modificationDate);579 }580 var contents = this._formatContents(this.contents);581 popup.appendChild(contents);582 this.trigger.addEventListener('click', this._toggle.bind(this));583 this.trigger.addEventListener('mouseover', this._show.bind(this, false));584 this.trigger.addEventListener('mouseout', this._hide.bind(this, false));585 popup.addEventListener('click', this._hide.bind(this, true));586 wrapper.appendChild(popup);587 return wrapper;588 }589 }, {590 key: "_formatContents",591 value: function _formatContents(contents) {592 var p = document.createElement('p');593 var lines = contents.split(/(?:\r\n?|\n)/);594 for (var i = 0, ii = lines.length; i < ii; ++i) {595 var line = lines[i];596 p.appendChild(document.createTextNode(line));597 if (i < ii - 1) {598 p.appendChild(document.createElement('br'));599 }600 }601 return p;602 }603 }, {604 key: "_toggle",605 value: function _toggle() {606 if (this.pinned) {607 this._hide(true);608 } else {609 this._show(true);610 }611 }612 }, {613 key: "_show",614 value: function _show() {615 var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;616 if (pin) {617 this.pinned = true;618 }619 if (this.hideElement.hasAttribute('hidden')) {620 this.hideElement.removeAttribute('hidden');621 this.container.style.zIndex += 1;622 }623 }624 }, {625 key: "_hide",626 value: function _hide() {627 var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;628 if (unpin) {629 this.pinned = false;630 }631 if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {632 this.hideElement.setAttribute('hidden', true);633 this.container.style.zIndex -= 1;634 }635 }636 }]);637 return PopupElement;638}();639var FreeTextAnnotationElement =640/*#__PURE__*/641function (_AnnotationElement5) {642 _inherits(FreeTextAnnotationElement, _AnnotationElement5);643 function FreeTextAnnotationElement(parameters) {644 _classCallCheck(this, FreeTextAnnotationElement);645 var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);646 return _possibleConstructorReturn(this, _getPrototypeOf(FreeTextAnnotationElement).call(this, parameters, isRenderable, true));647 }648 _createClass(FreeTextAnnotationElement, [{649 key: "render",650 value: function render() {651 this.container.className = 'freeTextAnnotation';652 if (!this.data.hasPopup) {653 this._createPopup(this.container, null, this.data);654 }655 return this.container;656 }657 }]);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptextannotation = require('wptextannotation');2var wptextannotationelement = require('wptextannotationelement');3var element = new wptextannotationelement.FreeTextAnnotationElement();4element.setText('Hello World');5element.setPageNumber(1);6element.setPoint(10, 10);7element.setOpacity(0.5);8element.setFontColor('#000000');9element.setFontSize(10);10element.setFillColor('#ffffff');11element.setBorderStyle(wptextannotationelement.TextAnnotationElement.BorderStyle.SOLID);12element.setLineWidth(2);13element.setBorderColor('#000000');14element.setSubject('Hello World');15element.setContents('Hello World');16element.setCreationDate(new Date());17element.setModifiedDate(new Date());18element.setIntent(wptextannotationelement.TextAnnotationElement.Intent.FREETEXT);19element.setIsOpen(true);20element.setIsLocked(false);21element.setIsInvisible(false);22element.setIsPrinted(true);23element.setIsReadOnly(false);24element.setIsToggleNoView(false);25var annotation = new wptextannotation.FreeTextAnnotation();26annotation.setElement(element);27var wptextannotation = require('wptextannotation');28var wptextannotationelement = require('wptextannotationelement');29var annotation = new wptextannotation.FreeTextAnnotation();30annotation.setText('Hello World');31annotation.setPageNumber(1);32annotation.setPoint(10, 10);33annotation.setOpacity(0.5);34annotation.setFontColor('#000000');35annotation.setFontSize(10);36annotation.setFillColor('#ffffff');37annotation.setBorderStyle(wptextannotationelement.TextAnnotationElement.BorderStyle.SOLID);38annotation.setLineWidth(2);39annotation.setBorderColor('#000000');40annotation.setSubject('Hello World');41annotation.setContents('Hello World');42annotation.setCreationDate(new Date());43annotation.setModifiedDate(new Date());44annotation.setIntent(wptextannotationelement.TextAnnotationElement.Intent.FREETEXT);45annotation.setIsOpen(true);46annotation.setIsLocked(false);47annotation.setIsInvisible(false);48annotation.setIsPrinted(true);49annotation.setIsReadOnly(false);50annotation.setIsToggleNoView(false);51var wptextannotation = require('wptextannotation');52var wptextannotationelement = require('wptextannotationelement');53var element = new wptextannotationelement.HighlightAnnotationElement();54element.setText('Hello World

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptextannotation = require("wptextannotation");2var text = "This is a test";3var element = new wptextannotation.FreeTextAnnotationElement(text, 10, 10);4element.draw();5element.setText("This is a test2");6element.draw();7var wptextannotation = {};8wptextannotation.FreeTextAnnotationElement = function (text, x, y) {9 this.text = text;10 this.x = x;11 this.y = y;12 this.setText = function (text) {13 this.text = text;14 };15 this.draw = function () {16 console.log(this.text);17 };18};19module.exports = wptextannotation;20var wptextannotation = {};21wptextannotation.FreeTextAnnotationElement = function (text, x, y) {22 this.text = text;23 this.x = x;24 this.y = y;25 this.setText = function (text) {26 this.text = text;27 };

Full Screen

Using AI Code Generation

copy

Full Screen

1var FreeTextAnnotationElement = require('wptextannotation.js');2var FreeTextAnnotation = new FreeTextAnnotationElement();3FreeTextAnnotation.setText('Hello World');4var text = FreeTextAnnotation.getText();5FreeTextAnnotation.setFontSize(20);6FreeTextAnnotation.setFontName('Helvetica');7FreeTextAnnotation.setFontColor('#000000');8FreeTextAnnotation.setOpacity(1);9FreeTextAnnotation.setBackgroundColor('#ffffff');10FreeTextAnnotation.setBorderColor('#000000');11FreeTextAnnotation.setBorderWidth(1);12FreeTextAnnotation.setBorderStyle('solid');13FreeTextAnnotation.setBorderDashArray('3,3');14FreeTextAnnotation.setBorderCornerRadius(0);15FreeTextAnnotation.setBorderOpacity(1);16FreeTextAnnotation.setPadding(5);17FreeTextAnnotation.setHorizontalAlignment('left');18FreeTextAnnotation.setVerticalAlignment('top');19FreeTextAnnotation.setVisibility(true);20FreeTextAnnotation.setIntent('FreeText');21FreeTextAnnotation.setLocked(true);22FreeTextAnnotation.setLockedContents(true);23FreeTextAnnotation.setPrint(true);24FreeTextAnnotation.setNoZoom(true);25FreeTextAnnotation.setNoRotate(true);26FreeTextAnnotation.setNoView(true);27FreeTextAnnotation.setReadOnly(true);28FreeTextAnnotation.setNoView(true);29FreeTextAnnotation.setInvisible(true);30FreeTextAnnotation.setHidden(true);31FreeTextAnnotation.setToggleNoView(true);32FreeTextAnnotation.setRichText(true);33FreeTextAnnotation.setFont('Helvetica');34FreeTextAnnotation.setFontStyle('normal');35FreeTextAnnotation.setFontWeight('normal');

Full Screen

Using AI Code Generation

copy

Full Screen

1var annotationElement = new FreeTextAnnotationElement();2annotationElement.setContents("Test Annotation");3annotationElement.setRect(50, 50, 100, 100);4annotationElement.setAuthor("Test User");5annotationElement.setColor("#FF0000");6annotationElement.setFlags(AnnotationFlag.HIDDEN);7annotationElement.setOpacity(0.5);8annotationElement.setContents("Test Annotation");9annotationElement.setCreationDate(new Date());10annotationElement.setModificationDate(new Date());11annotationElement.setSubject("Test Subject");12annotationElement.setTitle("Test Title");13annotationElement.setCustomData({14});15var annotations = doc.getAnnotations();16annotations.push(annotationElement);17doc.save("test.pdf");18PDFNet.PDFDoc.createFromFilePath(inputUrl).then(function (doc) {19 var annots = doc.getPage(1).getAnnotations();20 var annot = annots.get(0);21 console.log(annot.getContents());22 console.log(annot.getRect());23 console.log(annot.getAuthor());24 console.log(annot.getColor());25 console.log(annot.getFlags());26 console.log(annot.getOpacity());27 console.log(annot.getContents());28 console.log(annot.getCreationDate());29 console.log(annot.getModificationDate());30 console.log(annot.getSubject());31 console.log(annot.getTitle());32 console.log(annot.getCustomData());33 doc.saveMemoryBuffer(PDFNet.SDFDoc.SaveOptions.e_linearized);34}).catch(function (error) {35 console.log(error);36});37var annotationElement = new LineAnnotationElement();38annotationElement.setStartPoint(50, 50);39annotationElement.setEndPoint(100, 100);40annotationElement.setContents("Test Annotation");41annotationElement.setRect(50, 50, 100, 100);42annotationElement.setAuthor("Test User");43annotationElement.setColor("#FF0000");44annotationElement.setFlags(AnnotationFlag.HIDDEN);45annotationElement.setOpacity(0.5);46annotationElement.setContents("Test Annotation");47annotationElement.setCreationDate(new Date());48annotationElement.setModificationDate(new

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptextannotation = require('wptextannotation');2var wptextannotation = new wptextannotation();3var pdfDoc = new PDFDocument();4pdfDoc.pipe(fs.createWriteStream('output.pdf'));5pdfDoc.text('Hello World');6wptextannotation.FreeTextAnnotationElement(pdfDoc, "Hello World", 50, 50, "Hello World", 10, 10, 10, 10, 10, 10, 10);7pdfDoc.end();

Full Screen

Using AI Code Generation

copy

Full Screen

1var textAnnotationElement = new FreeTextAnnotationElement();2var textAnnotation = textAnnotationElement.createTextAnnotation();3textAnnotation.setText("hello");4textAnnotation.setColor("red");5textAnnotation.setOpacity(1);6textAnnotation.setFontFamily("Arial");7textAnnotation.setFontSize(12);8textAnnotation.setFontStyle("bold");9textAnnotation.setLineSpacing(1);10textAnnotation.setLineHeight(1);11textAnnotation.setLineWeight(1);12textAnnotation.setLineAlignment("center");13textAnnotation.setLineIndentation(1);14textAnnotation.setLineLeadingOffset(1);15textAnnotation.setLineStartOffset(1);16textAnnotation.setLineEndOffset(1);17textAnnotation.setLineStartLength(1);18textAnnotation.setLineEndLength(1);19textAnnotation.setLineCapStyle("butt");20textAnnotation.setLineJoinStyle("miter");21textAnnotation.setLineDashPattern([1,2,3]);22textAnnotation.setLineIntent("inline");23textAnnotation.setLinePosition("inline");24textAnnotation.setLineRotation(1);25textAnnotation.setLineXScale(1);26textAnnotation.setLineOblique(1);27textAnnotation.setLineSkew(1);28textAnnotation.setLineFillType("solid");29textAnnotation.setLineFillOpacity(1);30textAnnotation.setLineFillColor("red");31textAnnotation.setLineFillGradient([1,2,3]);32textAnnotation.setLineFillTint(1);33textAnnotation.setLineFillShading("axial");34textAnnotation.setLineFillNoise(1);35textAnnotation.setLineFillOverprint(false);36textAnnotation.setLineFillOverprintGap(false);37textAnnotation.setLineStrokeType("solid");38textAnnotation.setLineStrokeOpacity(1);39textAnnotation.setLineStrokeColor("red");40textAnnotation.setLineStrokeGradient([1,2,3]);41textAnnotation.setLineStrokeTint(1);42textAnnotation.setLineStrokeShading("axial");43textAnnotation.setLineStrokeNoise(1);44textAnnotation.setLineStrokeOverprint(false);45textAnnotation.setLineStrokeOverprintGap(false);46textAnnotation.setLineStrokeWidth(1);47textAnnotation.setLineMiterLimit(1);48textAnnotation.setLineDashOffset(1);49textAnnotation.setLineEndStyle("butt");50textAnnotation.setLineCornerStyle("miter");51textAnnotation.setLineStartArrow("none");52textAnnotation.setLineEndArrow("none");53textAnnotation.setLineStartArrowLength(1);54textAnnotation.setLineEndArrowLength(1);

Full Screen

Using AI Code Generation

copy

Full Screen

1var element = new FreeTextAnnotationElement();2element.setText("FreeTextAnnotationElement");3element.setFontSize(14);4element.setColor(255, 0, 0, 0);5element.setTextAlignment(AnnotationElement.e_textAlign.center);6element.setRect(0, 0, 100, 100);7element.setBorderColor(0, 0, 255, 0);8element.setBorderWidth(2);9element.setBackgroundColor(0, 255, 0, 0);10element.draw();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { PDFDocument } = require('pdf-lib');2const { FreeTextAnnotationElement } = require('./wptextannotation');3const main = async () => {4 const pdfDoc = await PDFDocument.create();5 const page = pdfDoc.addPage();6 const { width, height } = page.getSize();7 const textElement = new FreeTextAnnotationElement({8 });9 textElement.draw(page);10 const pdfBytes = await pdfDoc.save();11 await pdfDoc.saveAsBase64({ dataUri: true }).then(base64 => {12 console.log(base64);13 });14};15main();

Full Screen

Using AI Code Generation

copy

Full Screen

1var doc = app.activeDocument;2var page = doc.pages.add();3var textFrame = page.textFrames.add();4textFrame.geometricBounds = [100, 100, 200, 200];5textFrame.contents = "This is a sample text frame";6var annotation = textFrame.createFreeTextAnnotation();7annotation.contents = "This is a free text annotation";8annotation.geometricBounds = [100, 100, 200, 200];9var annotation = page.getFreeTextAnnotation();10annotation.contents = "This is a free text annotation";11annotation.geometricBounds = [100, 100, 200, 200];12var annotation = page.createFreeTextAnnotation();13annotation.contents = "This is a free text annotation";14annotation.geometricBounds = [100, 100, 200, 200];15var annotation = page.createFreeTextAnnotation();16annotation.contents = "This is a free text annotation";17annotation.geometricBounds = [100, 100, 200, 200];18var annotation = page.createFreeTextAnnotation();19annotation.contents = "This is a free text annotation";20annotation.geometricBounds = [100, 100, 200, 200];21var annotation = page.createFreeTextAnnotation();22annotation.contents = "This is a free text annotation";

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful