/var/www/greso.tech/server/nsm/node_modules/pdf-lib/es/core/acroform
NameSizeModeActions
flags.d.ts57800644editdlrm
flags.d.ts.map7730644editdlrm
flags.js73610644editdlrm
flags.js.map18920644editdlrm
index.d.ts9030644editdlrm
index.d.ts.map8870644editdlrm
index.js9010644editdlrm
index.js.map8820644editdlrm
PDFAcroButton.d.ts10340644editdlrm
PDFAcroButton.d.ts.map7150644editdlrm
PDFAcroButton.js38760644editdlrm
PDFAcroButton.js.map31440644editdlrm
PDFAcroCheckBox.d.ts5730644editdlrm
PDFAcroCheckBox.d.ts.map4780644editdlrm
PDFAcroCheckBox.js18640644editdlrm
PDFAcroCheckBox.js.map16440644editdlrm
PDFAcroChoice.d.ts8640644editdlrm
PDFAcroChoice.d.ts.map7720644editdlrm
PDFAcroChoice.js53040644editdlrm
PDFAcroChoice.js.map47300644editdlrm
PDFAcroComboBox.d.ts4310644editdlrm
PDFAcroComboBox.d.ts.map3710644editdlrm
PDFAcroComboBox.js8360644editdlrm
PDFAcroComboBox.js.map6670644editdlrm
PDFAcroField.d.ts15220644editdlrm
PDFAcroField.d.ts.map12960644editdlrm
PDFAcroField.js58170644editdlrm
PDFAcroField.js.map50190644editdlrm
PDFAcroForm.d.ts7370644editdlrm
PDFAcroForm.d.ts.map6230644editdlrm
PDFAcroForm.js29900644editdlrm
PDFAcroForm.js.map28590644editdlrm
PDFAcroListBox.d.ts4260644editdlrm
PDFAcroListBox.d.ts.map3680644editdlrm
PDFAcroListBox.js7440644editdlrm
PDFAcroListBox.js.map6010644editdlrm
PDFAcroNonTerminal.d.ts5650644editdlrm
PDFAcroNonTerminal.d.ts.map4260644editdlrm
PDFAcroNonTerminal.js12270644editdlrm
PDFAcroNonTerminal.js.map10480644editdlrm
PDFAcroPushButton.d.ts4410644editdlrm
PDFAcroPushButton.d.ts.map3780644editdlrm
PDFAcroPushButton.js8620644editdlrm
PDFAcroPushButton.js.map6770644editdlrm
PDFAcroRadioButton.d.ts5790644editdlrm
PDFAcroRadioButton.d.ts.map4820644editdlrm
PDFAcroRadioButton.js20840644editdlrm
PDFAcroRadioButton.js.map19200644editdlrm
PDFAcroSignature.d.ts3400644editdlrm
PDFAcroSignature.d.ts.map3160644editdlrm
PDFAcroSignature.js5330644editdlrm
PDFAcroSignature.js.map3630644editdlrm
PDFAcroTerminal.d.ts6560644editdlrm
PDFAcroTerminal.d.ts.map4860644editdlrm
PDFAcroTerminal.js27510644editdlrm
PDFAcroTerminal.js.map21540644editdlrm
PDFAcroText.d.ts9570644editdlrm
PDFAcroText.d.ts.map7400644editdlrm
PDFAcroText.js27200644editdlrm
PDFAcroText.js.map20680644editdlrm
utils.d.ts3960644editdlrm
utils.d.ts.map3380644editdlrm
utils.js52020644editdlrm
utils.js.map43030644editdlrm
Edit: /var/www/greso.tech/server/nsm/node_modules/pdf-lib/es/core/acroform/PDFAcroChoice.js (5304B)
import { __extends } from "tslib"; import PDFAcroTerminal from "./PDFAcroTerminal"; import PDFHexString from "../objects/PDFHexString"; import PDFString from "../objects/PDFString"; import PDFArray from "../objects/PDFArray"; import PDFName from "../objects/PDFName"; import { AcroChoiceFlags } from "./flags"; import { InvalidAcroFieldValueError, MultiSelectValueError, } from "../errors"; var PDFAcroChoice = /** @class */ (function (_super) { __extends(PDFAcroChoice, _super); function PDFAcroChoice() { return _super !== null && _super.apply(this, arguments) || this; } PDFAcroChoice.prototype.setValues = function (values) { if (this.hasFlag(AcroChoiceFlags.Combo) && !this.hasFlag(AcroChoiceFlags.Edit) && !this.valuesAreValid(values)) { throw new InvalidAcroFieldValueError(); } if (values.length === 0) { this.dict.delete(PDFName.of('V')); } if (values.length === 1) { this.dict.set(PDFName.of('V'), values[0]); } if (values.length > 1) { if (!this.hasFlag(AcroChoiceFlags.MultiSelect)) { throw new MultiSelectValueError(); } this.dict.set(PDFName.of('V'), this.dict.context.obj(values)); } this.updateSelectedIndices(values); }; PDFAcroChoice.prototype.valuesAreValid = function (values) { var options = this.getOptions(); var _loop_1 = function (idx, len) { var val = values[idx].decodeText(); if (!options.find(function (o) { return val === (o.display || o.value).decodeText(); })) { return { value: false }; } }; for (var idx = 0, len = values.length; idx < len; idx++) { var state_1 = _loop_1(idx, len); if (typeof state_1 === "object") return state_1.value; } return true; }; PDFAcroChoice.prototype.updateSelectedIndices = function (values) { if (values.length > 1) { var indices = new Array(values.length); var options = this.getOptions(); var _loop_2 = function (idx, len) { var val = values[idx].decodeText(); indices[idx] = options.findIndex(function (o) { return val === (o.display || o.value).decodeText(); }); }; for (var idx = 0, len = values.length; idx < len; idx++) { _loop_2(idx, len); } this.dict.set(PDFName.of('I'), this.dict.context.obj(indices.sort())); } else { this.dict.delete(PDFName.of('I')); } }; PDFAcroChoice.prototype.getValues = function () { var v = this.V(); if (v instanceof PDFString || v instanceof PDFHexString) return [v]; if (v instanceof PDFArray) { var values = []; for (var idx = 0, len = v.size(); idx < len; idx++) { var value = v.lookup(idx); if (value instanceof PDFString || value instanceof PDFHexString) { values.push(value); } } return values; } return []; }; PDFAcroChoice.prototype.Opt = function () { return this.dict.lookupMaybe(PDFName.of('Opt'), PDFString, PDFHexString, PDFArray); }; PDFAcroChoice.prototype.setOptions = function (options) { var newOpt = new Array(options.length); for (var idx = 0, len = options.length; idx < len; idx++) { var _a = options[idx], value = _a.value, display = _a.display; newOpt[idx] = this.dict.context.obj([value, display || value]); } this.dict.set(PDFName.of('Opt'), this.dict.context.obj(newOpt)); }; PDFAcroChoice.prototype.getOptions = function () { var Opt = this.Opt(); // Not supposed to happen - Opt _should_ always be `PDFArray | undefined` if (Opt instanceof PDFString || Opt instanceof PDFHexString) { return [{ value: Opt, display: Opt }]; } if (Opt instanceof PDFArray) { var res = []; for (var idx = 0, len = Opt.size(); idx < len; idx++) { var item = Opt.lookup(idx); // If `item` is a string, use that as both the export and text value if (item instanceof PDFString || item instanceof PDFHexString) { res.push({ value: item, display: item }); } // If `item` is an array of one, treat it the same as just a string, // if it's an array of two then `item[0]` is the export value and // `item[1]` is the text value if (item instanceof PDFArray) { if (item.size() > 0) { var first = item.lookup(0, PDFString, PDFHexString); var second = item.lookupMaybe(1, PDFString, PDFHexString); res.push({ value: first, display: second || first }); } } } return res; } return []; }; return PDFAcroChoice; }(PDFAcroTerminal)); export default PDFAcroChoice; //# sourceMappingURL=PDFAcroChoice.js.map