How to use TextWidgetAnnotationElement method in wpt

Best JavaScript code snippet using wpt

annotation_layer.js

Source:annotation_layer.js Github

copy

Full Screen

...65 case AnnotationType.WIDGET:66 var fieldType = parameters.data.fieldType;67 switch (fieldType) {68 case 'Tx':69 return new TextWidgetAnnotationElement(parameters);70 }71 return new WidgetAnnotationElement(parameters);72 case AnnotationType.POPUP:73 return new PopupAnnotationElement(parameters);74 case AnnotationType.HIGHLIGHT:75 return new HighlightAnnotationElement(parameters);76 case AnnotationType.UNDERLINE:77 return new UnderlineAnnotationElement(parameters);78 case AnnotationType.SQUIGGLY:79 return new SquigglyAnnotationElement(parameters);80 case AnnotationType.STRIKEOUT:81 return new StrikeOutAnnotationElement(parameters);82 case AnnotationType.FILEATTACHMENT:83 return new FileAttachmentAnnotationElement(parameters);84 default:85 return new AnnotationElement(parameters);86 }87 }88};89/**90 * @class91 * @alias AnnotationElement92 */93var AnnotationElement = (function AnnotationElementClosure() {94 function AnnotationElement(parameters, isRenderable) {95 this.isRenderable = isRenderable || false;96 this.data = parameters.data;97 this.layer = parameters.layer;98 this.page = parameters.page;99 this.viewport = parameters.viewport;100 this.linkService = parameters.linkService;101 this.downloadManager = parameters.downloadManager;102 this.imageResourcesPath = parameters.imageResourcesPath;103 this.renderInteractiveForms = parameters.renderInteractiveForms;104 if (isRenderable) {105 this.container = this._createContainer();106 }107 }108 AnnotationElement.prototype = /** @lends AnnotationElement.prototype */ {109 /**110 * Create an empty container for the annotation's HTML element.111 *112 * @private113 * @memberof AnnotationElement114 * @returns {HTMLSectionElement}115 */116 _createContainer: function AnnotationElement_createContainer() {117 var data = this.data, page = this.page, viewport = this.viewport;118 var container = document.createElement('section');119 var width = data.rect[2] - data.rect[0];120 var height = data.rect[3] - data.rect[1];121 container.setAttribute('data-annotation-id', data.id);122 // Do *not* modify `data.rect`, since that will corrupt the annotation123 // position on subsequent calls to `_createContainer` (see issue 6804).124 var rect = Util.normalizeRect([125 data.rect[0],126 page.view[3] - data.rect[1] + page.view[1],127 data.rect[2],128 page.view[3] - data.rect[3] + page.view[1]129 ]);130 CustomStyle.setProp('transform', container,131 'matrix(' + viewport.transform.join(',') + ')');132 CustomStyle.setProp('transformOrigin', container,133 -rect[0] + 'px ' + -rect[1] + 'px');134 if (data.borderStyle.width > 0) {135 container.style.borderWidth = data.borderStyle.width + 'px';136 if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {137 // Underline styles only have a bottom border, so we do not need138 // to adjust for all borders. This yields a similar result as139 // Adobe Acrobat/Reader.140 width = width - 2 * data.borderStyle.width;141 height = height - 2 * data.borderStyle.width;142 }143 var horizontalRadius = data.borderStyle.horizontalCornerRadius;144 var verticalRadius = data.borderStyle.verticalCornerRadius;145 if (horizontalRadius > 0 || verticalRadius > 0) {146 var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';147 CustomStyle.setProp('borderRadius', container, radius);148 }149 switch (data.borderStyle.style) {150 case AnnotationBorderStyleType.SOLID:151 container.style.borderStyle = 'solid';152 break;153 case AnnotationBorderStyleType.DASHED:154 container.style.borderStyle = 'dashed';155 break;156 case AnnotationBorderStyleType.BEVELED:157 warn('Unimplemented border style: beveled');158 break;159 case AnnotationBorderStyleType.INSET:160 warn('Unimplemented border style: inset');161 break;162 case AnnotationBorderStyleType.UNDERLINE:163 container.style.borderBottomStyle = 'solid';164 break;165 default:166 break;167 }168 if (data.color) {169 container.style.borderColor =170 Util.makeCssRgb(data.color[0] | 0,171 data.color[1] | 0,172 data.color[2] | 0);173 } else {174 // Transparent (invisible) border, so do not draw it at all.175 container.style.borderWidth = 0;176 }177 }178 container.style.left = rect[0] + 'px';179 container.style.top = rect[1] + 'px';180 container.style.width = width + 'px';181 container.style.height = height + 'px';182 return container;183 },184 /**185 * Create a popup for the annotation's HTML element. This is used for186 * annotations that do not have a Popup entry in the dictionary, but187 * are of a type that works with popups (such as Highlight annotations).188 *189 * @private190 * @param {HTMLSectionElement} container191 * @param {HTMLDivElement|HTMLImageElement|null} trigger192 * @param {Object} data193 * @memberof AnnotationElement194 */195 _createPopup:196 function AnnotationElement_createPopup(container, trigger, data) {197 // If no trigger element is specified, create it.198 if (!trigger) {199 trigger = document.createElement('div');200 trigger.style.height = container.style.height;201 trigger.style.width = container.style.width;202 container.appendChild(trigger);203 }204 var popupElement = new PopupElement({205 container: container,206 trigger: trigger,207 color: data.color,208 title: data.title,209 contents: data.contents,210 hideWrapper: true211 });212 var popup = popupElement.render();213 // Position the popup next to the annotation's container.214 popup.style.left = container.style.width;215 container.appendChild(popup);216 },217 /**218 * Render the annotation's HTML element in the empty container.219 *220 * @public221 * @memberof AnnotationElement222 */223 render: function AnnotationElement_render() {224 throw new Error('Abstract method AnnotationElement.render called');225 }226 };227 return AnnotationElement;228})();229/**230 * @class231 * @alias LinkAnnotationElement232 */233var LinkAnnotationElement = (function LinkAnnotationElementClosure() {234 function LinkAnnotationElement(parameters) {235 AnnotationElement.call(this, parameters, true);236 }237 Util.inherit(LinkAnnotationElement, AnnotationElement, {238 /**239 * Render the link annotation's HTML element in the empty container.240 *241 * @public242 * @memberof LinkAnnotationElement243 * @returns {HTMLSectionElement}244 */245 render: function LinkAnnotationElement_render() {246 this.container.className = 'linkAnnotation';247 var link = document.createElement('a');248 addLinkAttributes(link, {249 url: this.data.url,250 target: (this.data.newWindow ? LinkTarget.BLANK : undefined),251 });252 if (!this.data.url) {253 if (this.data.action) {254 this._bindNamedAction(link, this.data.action);255 } else {256 this._bindLink(link, (this.data.dest || null));257 }258 }259 this.container.appendChild(link);260 return this.container;261 },262 /**263 * Bind internal links to the link element.264 *265 * @private266 * @param {Object} link267 * @param {Object} destination268 * @memberof LinkAnnotationElement269 */270 _bindLink: function LinkAnnotationElement_bindLink(link, destination) {271 var self = this;272 link.href = this.linkService.getDestinationHash(destination);273 link.onclick = function() {274 if (destination) {275 self.linkService.navigateTo(destination);276 }277 return false;278 };279 if (destination) {280 link.className = 'internalLink';281 }282 },283 /**284 * Bind named actions to the link element.285 *286 * @private287 * @param {Object} link288 * @param {Object} action289 * @memberof LinkAnnotationElement290 */291 _bindNamedAction:292 function LinkAnnotationElement_bindNamedAction(link, action) {293 var self = this;294 link.href = this.linkService.getAnchorUrl('');295 link.onclick = function() {296 self.linkService.executeNamedAction(action);297 return false;298 };299 link.className = 'internalLink';300 }301 });302 return LinkAnnotationElement;303})();304/**305 * @class306 * @alias TextAnnotationElement307 */308var TextAnnotationElement = (function TextAnnotationElementClosure() {309 function TextAnnotationElement(parameters) {310 var isRenderable = !!(parameters.data.hasPopup ||311 parameters.data.title || parameters.data.contents);312 AnnotationElement.call(this, parameters, isRenderable);313 }314 Util.inherit(TextAnnotationElement, AnnotationElement, {315 /**316 * Render the text annotation's HTML element in the empty container.317 *318 * @public319 * @memberof TextAnnotationElement320 * @returns {HTMLSectionElement}321 */322 render: function TextAnnotationElement_render() {323 this.container.className = 'textAnnotation';324 var image = document.createElement('img');325 image.style.height = this.container.style.height;326 image.style.width = this.container.style.width;327 image.src = this.imageResourcesPath + 'annotation-' +328 this.data.name.toLowerCase() + '.svg';329 image.alt = '[{{type}} Annotation]';330 image.dataset.l10nId = 'text_annotation_type';331 image.dataset.l10nArgs = JSON.stringify({type: this.data.name});332 if (!this.data.hasPopup) {333 this._createPopup(this.container, image, this.data);334 }335 this.container.appendChild(image);336 return this.container;337 }338 });339 return TextAnnotationElement;340})();341/**342 * @class343 * @alias WidgetAnnotationElement344 */345var WidgetAnnotationElement = (function WidgetAnnotationElementClosure() {346 function WidgetAnnotationElement(parameters) {347 var isRenderable = parameters.renderInteractiveForms ||348 (!parameters.data.hasAppearance && !!parameters.data.fieldValue);349 AnnotationElement.call(this, parameters, isRenderable);350 }351 Util.inherit(WidgetAnnotationElement, AnnotationElement, {352 /**353 * Render the widget annotation's HTML element in the empty container.354 *355 * @public356 * @memberof WidgetAnnotationElement357 * @returns {HTMLSectionElement}358 */359 render: function WidgetAnnotationElement_render() {360 // Show only the container for unsupported field types.361 return this.container;362 }363 });364 return WidgetAnnotationElement;365})();366/**367 * @class368 * @alias TextWidgetAnnotationElement369 */370var TextWidgetAnnotationElement = (371 function TextWidgetAnnotationElementClosure() {372 var TEXT_ALIGNMENT = ['left', 'center', 'right'];373 function TextWidgetAnnotationElement(parameters) {374 WidgetAnnotationElement.call(this, parameters);375 }376 Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {377 /**378 * Render the text widget annotation's HTML element in the empty container.379 *380 * @public381 * @memberof TextWidgetAnnotationElement382 * @returns {HTMLSectionElement}383 */384 render: function TextWidgetAnnotationElement_render() {385 this.container.className = 'textWidgetAnnotation';386 var element = null;387 if (this.renderInteractiveForms) {...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var textWidgetAnnotationElement = new TextWidgetAnnotationElement({2 data: {3 },4});5textWidgetAnnotationElement.setTextContent('Sample text');6textLayer.append(textWidgetAnnotationElement);7textWidgetAnnotationElement.setFontSize(5);8textWidgetAnnotationElement.setTextColor('red');9textWidgetAnnotationElement.setTextAlign('right');10textWidgetAnnotationElement.setDirection('rtl');11textWidgetAnnotationElement.setTransform([1, 0, 0, 1, 0, 0]);12textWidgetAnnotationElement.setCursor('pointer');13textWidgetAnnotationElement.setVisibility(true);14textWidgetAnnotationElement.hide();15textWidgetAnnotationElement.show();16textWidgetAnnotationElement.on('customEvent', function (data) {17 console.log('customEvent', data);18});19textWidgetAnnotationElement.dispatchEvent('customEvent', {20 detail: {21 },22});23textWidgetAnnotationElement.off('customEvent');24textWidgetAnnotationElement.remove();25textWidgetAnnotationElement.destroy();26var textWidgetAnnotationElement = new TextWidgetAnnotationElement({27 data: {28 },29});30textWidgetAnnotationElement.setTextContent('

Full Screen

Using AI Code Generation

copy

Full Screen

1var textWidgetAnnotationElement = new TextWidgetAnnotationElement({2});3textWidgetAnnotationElement.render(task, viewport);4var textWidgetAnnotationElement = new TextWidgetAnnotationElement({5});6textWidgetAnnotationElement.render(task, viewport);7var textWidgetAnnotationElement = new TextWidgetAnnotationElement({8});9textWidgetAnnotationElement.render(task, viewport);10var textWidgetAnnotationElement = new TextWidgetAnnotationElement({11});12textWidgetAnnotationElement.render(task, viewport);13var textWidgetAnnotationElement = new TextWidgetAnnotationElement({14});15textWidgetAnnotationElement.render(task, viewport);16var textWidgetAnnotationElement = new TextWidgetAnnotationElement({

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var pdf = require('pdfkit');3var fs = require('fs');4var doc = new pdf();5var pdfStream = fs.createWriteStream('test.pdf');6doc.pipe(pdfStream);7var textWidget = new wptools.TextWidgetAnnotationElement();8textWidget.setRect(100, 100, 100, 100);9textWidget.setContents('test');10textWidget.setFlags(4);11textWidget.setBorderStyle(new wptools.BorderStyle());12textWidget.setBorderStyleWidth(1);13textWidget.setBorderStyleStyle('S');14textWidget.setBorderStyleDashPattern([3, 0]);15textWidget.setBorderStyleHorizontalCornerRadius(2);16textWidget.setBorderStyleVerticalCornerRadius(2);17textWidget.setBorderStyleHorizontalCornerInversion(0);18textWidget.setBorderStyleVerticalCornerInversion(0);19textWidget.setBorderStyleColor(new wptools.Color(0, 0, 0));20textWidget.setBackgroundColor(new wptools.Color(1, 1, 1));21textWidget.setHighlightingMode('N');22textWidget.setBorderStyle(new wptools.BorderStyle());23textWidget.setBorderStyleWidth(1);24textWidget.setBorderStyleStyle('S');25textWidget.setBorderStyleDashPattern([3, 0]);26textWidget.setBorderStyleHorizontalCornerRadius(2);27textWidget.setBorderStyleVerticalCornerRadius(2);28textWidget.setBorderStyleHorizontalCornerInversion(0);29textWidget.setBorderStyleVerticalCornerInversion(0);30textWidget.setBorderStyleColor(new wptools.Color(0, 0, 0));31textWidget.setBackgroundColor(new wptools.Color(1, 1, 1));32textWidget.setHighlightingMode('N');33textWidget.setAppearanceState('Off');34textWidget.setNormalCaption('Off');35textWidget.setRolloverCaption('Rollover');36textWidget.setDownCaption('Down');37textWidget.setAppearanceState('Off');38textWidget.setNormalCaption('Off');39textWidget.setRolloverCaption('Rollover');40textWidget.setDownCaption('Down');41textWidget.setNormalCaption('Off');42textWidget.setRolloverCaption('Rollover');43textWidget.setDownCaption('Down');44textWidget.setNormalIcon(new wptools.FormXObjectElement());45textWidget.setRolloverIcon(new wptools.FormXObjectElement());46textWidget.setDownIcon(new wptools.FormXObjectElement());47textWidget.setNormalCaption('Off');

Full Screen

Using AI Code Generation

copy

Full Screen

1var textWidgetAnnotationElement = new TextWidgetAnnotationElement({2 data: {3 borderStyle: {4 },5 },6});7textWidgetAnnotationElement.render();8var TextWidgetAnnotationElement = (function TextWidgetAnnotationElementClosure() {9 function TextWidgetAnnotationElement(parameters) {10 WidgetAnnotationElement.call(this, parameters);11 }12 Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {13 * @returns {HTMLSectionElement}14 render: function TextWidgetAnnotationElement_render() {15 this.container.className = 'textWidgetAnnotation';16 this.container.style.width = this.viewport.width + 'px';17 this.container.style.height = this.viewport.height + 'px';18 var textWidget = document.createElement('input');19 textWidget.type = 'text';20 textWidget.value = this.data.fieldValue;21 textWidget.style.width = this.viewport.width + 'px';22 textWidget.style.height = this.viewport.height + 'px';23 this.container.appendChild(textWidget);24 return this.container;25 }26 });27 return TextWidgetAnnotationElement;28})();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptextwidgetannotation = require('wptextwidgetannotation');2var obj = new wptextwidgetannotation();3obj.TextWidgetAnnotationElement();4obj.TextWidgetAnnotationElement();5obj.TextWidgetAnnotationElement();6obj.TextWidgetAnnotationElement();7var wptextwidgetannotation = require('wptextwidgetannotation');8var obj = new wptextwidgetannotation();9obj.TextWidgetAnnotationElement();10obj.TextWidgetAnnotationElement();11obj.TextWidgetAnnotationElement();12obj.TextWidgetAnnotationElement();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptextwidget = require('wptextwidget');2var wptextwidget = new wptextwidget();3var textWidgetAnnotationElement = new wptextwidget.TextWidgetAnnotationElement({4 data: { value: "test" },5 });6textWidgetAnnotationElement.render();7textWidgetAnnotationElement.setTextContent("test");8textWidgetAnnotationElement.setTextContent("test1");9textWidgetAnnotationElement.setTextContent("test2");10textWidgetAnnotationElement.setTextContent("test3");11textWidgetAnnotationElement.setTextContent("test4");12textWidgetAnnotationElement.setTextContent("test5");13textWidgetAnnotationElement.setTextContent("test6");14textWidgetAnnotationElement.setTextContent("test7");15textWidgetAnnotationElement.setTextContent("test8");16textWidgetAnnotationElement.setTextContent("test9");17textWidgetAnnotationElement.setTextContent("test10");18textWidgetAnnotationElement.setTextContent("test11");19textWidgetAnnotationElement.setTextContent("test12");20textWidgetAnnotationElement.setTextContent("test13");21textWidgetAnnotationElement.setTextContent("test14");22textWidgetAnnotationElement.setTextContent("test15");23textWidgetAnnotationElement.setTextContent("test16");24textWidgetAnnotationElement.setTextContent("test17");25textWidgetAnnotationElement.setTextContent("test18");26textWidgetAnnotationElement.setTextContent("test19");27textWidgetAnnotationElement.setTextContent("test20");28textWidgetAnnotationElement.setTextContent("test21");29textWidgetAnnotationElement.setTextContent("test22");30textWidgetAnnotationElement.setTextContent("test23");31textWidgetAnnotationElement.setTextContent("test24");32textWidgetAnnotationElement.setTextContent("test25");33textWidgetAnnotationElement.setTextContent("test26");34textWidgetAnnotationElement.setTextContent("test27");35textWidgetAnnotationElement.setTextContent("test28");36textWidgetAnnotationElement.setTextContent("test29");37textWidgetAnnotationElement.setTextContent("test30");38textWidgetAnnotationElement.setTextContent("test31");39textWidgetAnnotationElement.setTextContent("test32");40textWidgetAnnotationElement.setTextContent("test33");41textWidgetAnnotationElement.setTextContent("test34");42textWidgetAnnotationElement.setTextContent("test35");43textWidgetAnnotationElement.setTextContent("test36");44textWidgetAnnotationElement.setTextContent("test37");45textWidgetAnnotationElement.setTextContent("test38");46textWidgetAnnotationElement.setTextContent("test39");47textWidgetAnnotationElement.setTextContent("test40");

Full Screen

Using AI Code Generation

copy

Full Screen

1var textWidgetAnnotationElement = new TextWidgetAnnotationElement({2});3var textWidgetAnnotationElement = new TextWidgetAnnotationElement({4});5var textWidgetAnnotationElement = new TextWidgetAnnotationElement({6});7var textWidgetAnnotationElement = new TextWidgetAnnotationElement({8});9var textWidgetAnnotationElement = new TextWidgetAnnotationElement({10});11var textWidgetAnnotationElement = new TextWidgetAnnotationElement({12});13var textWidgetAnnotationElement = new TextWidgetAnnotationElement({14});15var textWidgetAnnotationElement = new TextWidgetAnnotationElement({16});17var textWidgetAnnotationElement = new TextWidgetAnnotationElement({

Full Screen

Using AI Code Generation

copy

Full Screen

1var textWidgetAnnotationElement = new TextWidgetAnnotationElement({2});3var value = textWidgetAnnotationElement.fieldValue;4console.log("value = " + value);5var textWidgetAnnotationElement = new TextWidgetAnnotationElement({6});7textWidgetAnnotationElement.fieldValue = 200;8console.log("value = " + textWidgetAnnotationElement.fieldValue);9var textWidgetAnnotationElement = new TextWidgetAnnotationElement({10});11textWidgetAnnotationElement.fieldValue = 300;12console.log("value = " + textWidgetAnnotationElement.fieldValue);13var textWidgetAnnotationElement = new TextWidgetAnnotationElement({14});15textWidgetAnnotationElement.fieldValue = 400;16console.log("value = " + textWidgetAnnotationElement.fieldValue);17var textWidgetAnnotationElement = new TextWidgetAnnotationElement({

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