first commit

This commit is contained in:
Ale
2025-05-13 12:01:17 +02:00
commit d7881a4461
4852 changed files with 537159 additions and 0 deletions

84
node_modules/pdf-lib/es/core/PDFContext.d.ts generated vendored Normal file
View File

@@ -0,0 +1,84 @@
import PDFHeader from "./document/PDFHeader";
import PDFArray from "./objects/PDFArray";
import PDFBool from "./objects/PDFBool";
import PDFDict from "./objects/PDFDict";
import PDFHexString from "./objects/PDFHexString";
import PDFName from "./objects/PDFName";
import PDFNull from "./objects/PDFNull";
import PDFNumber from "./objects/PDFNumber";
import PDFObject from "./objects/PDFObject";
import PDFRawStream from "./objects/PDFRawStream";
import PDFRef from "./objects/PDFRef";
import PDFStream from "./objects/PDFStream";
import PDFString from "./objects/PDFString";
import PDFOperator from "./operators/PDFOperator";
import PDFContentStream from "./structures/PDFContentStream";
import { SimpleRNG } from "../utils/rng";
declare type LookupKey = PDFRef | PDFObject | undefined;
interface LiteralObject {
[name: string]: Literal | PDFObject;
}
interface LiteralArray {
[index: number]: Literal | PDFObject;
}
declare type Literal = LiteralObject | LiteralArray | string | number | boolean | null | undefined;
declare class PDFContext {
static create: () => PDFContext;
largestObjectNumber: number;
header: PDFHeader;
trailerInfo: {
Root?: PDFObject;
Encrypt?: PDFObject;
Info?: PDFObject;
ID?: PDFObject;
};
rng: SimpleRNG;
private readonly indirectObjects;
private pushGraphicsStateContentStreamRef?;
private popGraphicsStateContentStreamRef?;
private constructor();
assign(ref: PDFRef, object: PDFObject): void;
nextRef(): PDFRef;
register(object: PDFObject): PDFRef;
delete(ref: PDFRef): boolean;
lookupMaybe(ref: LookupKey, type: typeof PDFArray): PDFArray | undefined;
lookupMaybe(ref: LookupKey, type: typeof PDFBool): PDFBool | undefined;
lookupMaybe(ref: LookupKey, type: typeof PDFDict): PDFDict | undefined;
lookupMaybe(ref: LookupKey, type: typeof PDFHexString): PDFHexString | undefined;
lookupMaybe(ref: LookupKey, type: typeof PDFName): PDFName | undefined;
lookupMaybe(ref: LookupKey, type: typeof PDFNull): typeof PDFNull | undefined;
lookupMaybe(ref: LookupKey, type: typeof PDFNumber): PDFNumber | undefined;
lookupMaybe(ref: LookupKey, type: typeof PDFStream): PDFStream | undefined;
lookupMaybe(ref: LookupKey, type: typeof PDFRef): PDFRef | undefined;
lookupMaybe(ref: LookupKey, type: typeof PDFString): PDFString | undefined;
lookupMaybe(ref: LookupKey, type1: typeof PDFString, type2: typeof PDFHexString): PDFString | PDFHexString | undefined;
lookup(ref: LookupKey): PDFObject | undefined;
lookup(ref: LookupKey, type: typeof PDFArray): PDFArray;
lookup(ref: LookupKey, type: typeof PDFBool): PDFBool;
lookup(ref: LookupKey, type: typeof PDFDict): PDFDict;
lookup(ref: LookupKey, type: typeof PDFHexString): PDFHexString;
lookup(ref: LookupKey, type: typeof PDFName): PDFName;
lookup(ref: LookupKey, type: typeof PDFNull): typeof PDFNull;
lookup(ref: LookupKey, type: typeof PDFNumber): PDFNumber;
lookup(ref: LookupKey, type: typeof PDFStream): PDFStream;
lookup(ref: LookupKey, type: typeof PDFRef): PDFRef;
lookup(ref: LookupKey, type: typeof PDFString): PDFString;
lookup(ref: LookupKey, type1: typeof PDFString, type2: typeof PDFHexString): PDFString | PDFHexString;
getObjectRef(pdfObject: PDFObject): PDFRef | undefined;
enumerateIndirectObjects(): [PDFRef, PDFObject][];
obj(literal: null | undefined): typeof PDFNull;
obj(literal: string): PDFName;
obj(literal: number): PDFNumber;
obj(literal: boolean): PDFBool;
obj(literal: LiteralObject): PDFDict;
obj(literal: LiteralArray): PDFArray;
stream(contents: string | Uint8Array, dict?: LiteralObject): PDFRawStream;
flateStream(contents: string | Uint8Array, dict?: LiteralObject): PDFRawStream;
contentStream(operators: PDFOperator[], dict?: LiteralObject): PDFContentStream;
formXObject(operators: PDFOperator[], dict?: LiteralObject): PDFContentStream;
getPushGraphicsStateContentStream(): PDFRef;
getPopGraphicsStateContentStream(): PDFRef;
addRandomSuffix(prefix: string, suffixLength?: number): string;
}
export default PDFContext;
//# sourceMappingURL=PDFContext.d.ts.map

1
node_modules/pdf-lib/es/core/PDFContext.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFContext.d.ts","sourceRoot":"","sources":["../../src/core/PDFContext.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,6BAAoC;AAEpD,OAAO,QAAQ,2BAAkC;AACjD,OAAO,OAAO,0BAAiC;AAC/C,OAAO,OAAO,0BAAiC;AAC/C,OAAO,YAAY,+BAAsC;AACzD,OAAO,OAAO,0BAAiC;AAC/C,OAAO,OAAO,0BAAiC;AAC/C,OAAO,SAAS,4BAAmC;AACnD,OAAO,SAAS,4BAAmC;AACnD,OAAO,YAAY,+BAAsC;AACzD,OAAO,MAAM,yBAAgC;AAC7C,OAAO,SAAS,4BAAmC;AACnD,OAAO,SAAS,4BAAmC;AACnD,OAAO,WAAW,gCAAuC;AAEzD,OAAO,gBAAgB,sCAA6C;AAEpE,OAAO,EAAE,SAAS,EAAE,qBAAsB;AAE1C,aAAK,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AAEhD,UAAU,aAAa;IACrB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CACrC;AAED,UAAU,YAAY;IACpB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CACtC;AAED,aAAK,OAAO,GACR,aAAa,GACb,YAAY,GACZ,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,CAAC;AAOd,cAAM,UAAU;IACd,MAAM,CAAC,MAAM,mBAA0B;IAEvC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,SAAS,CAAC;IAClB,WAAW,EAAE;QACX,IAAI,CAAC,EAAE,SAAS,CAAC;QACjB,OAAO,CAAC,EAAE,SAAS,CAAC;QACpB,IAAI,CAAC,EAAE,SAAS,CAAC;QACjB,EAAE,CAAC,EAAE,SAAS,CAAC;KAChB,CAAC;IACF,GAAG,EA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EAAE,SAAS,CAAC,EAAE;IAMjD,GAAG,CAAC,OAAO,EAAE,IAAI,GAAG,SAAS,GAAG,OAAO,OAAO;IAC9C,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAC7B,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;IAC/B,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAC9B,GAAG,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;IACpC,GAAG,CAAC,OAAO,EAAE,YAAY,GAAG,QAAQ;IA+BpC,MAAM,CACJ,QAAQ,EAAE,MAAM,GAAG,UAAU,EAC7B,IAAI,GAAE,aAAkB,GACvB,YAAY;IAIf,WAAW,CACT,QAAQ,EAAE,MAAM,GAAG,UAAU,EAC7B,IAAI,GAAE,aAAkB,GACvB,YAAY;IAOf,aAAa,CACX,SAAS,EAAE,WAAW,EAAE,EACxB,IAAI,GAAE,aAAkB,GACvB,gBAAgB;IAInB,WAAW,CACT,SAAS,EAAE,WAAW,EAAE,EACxB,IAAI,GAAE,aAAkB,GACvB,gBAAgB;IAgBnB,iCAAiC,IAAI,MAAM;IAiB3C,gCAAgC,IAAI,MAAM;IAW1C,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,SAAI,GAAG,MAAM;CAG1D;AAED,eAAe,UAAU,CAAC"}

199
node_modules/pdf-lib/es/core/PDFContext.js generated vendored Normal file
View File

@@ -0,0 +1,199 @@
import { __assign } from "tslib";
import pako from 'pako';
import PDFHeader from "./document/PDFHeader";
import { UnexpectedObjectTypeError } from "./errors";
import PDFArray from "./objects/PDFArray";
import PDFBool from "./objects/PDFBool";
import PDFDict from "./objects/PDFDict";
import PDFName from "./objects/PDFName";
import PDFNull from "./objects/PDFNull";
import PDFNumber from "./objects/PDFNumber";
import PDFObject from "./objects/PDFObject";
import PDFRawStream from "./objects/PDFRawStream";
import PDFRef from "./objects/PDFRef";
import PDFOperator from "./operators/PDFOperator";
import Ops from "./operators/PDFOperatorNames";
import PDFContentStream from "./structures/PDFContentStream";
import { typedArrayFor } from "../utils";
import { SimpleRNG } from "../utils/rng";
var byAscendingObjectNumber = function (_a, _b) {
var a = _a[0];
var b = _b[0];
return a.objectNumber - b.objectNumber;
};
var PDFContext = /** @class */ (function () {
function PDFContext() {
this.largestObjectNumber = 0;
this.header = PDFHeader.forVersion(1, 7);
this.trailerInfo = {};
this.indirectObjects = new Map();
this.rng = SimpleRNG.withSeed(1);
}
PDFContext.prototype.assign = function (ref, object) {
this.indirectObjects.set(ref, object);
if (ref.objectNumber > this.largestObjectNumber) {
this.largestObjectNumber = ref.objectNumber;
}
};
PDFContext.prototype.nextRef = function () {
this.largestObjectNumber += 1;
return PDFRef.of(this.largestObjectNumber);
};
PDFContext.prototype.register = function (object) {
var ref = this.nextRef();
this.assign(ref, object);
return ref;
};
PDFContext.prototype.delete = function (ref) {
return this.indirectObjects.delete(ref);
};
PDFContext.prototype.lookupMaybe = function (ref) {
var types = [];
for (var _i = 1; _i < arguments.length; _i++) {
types[_i - 1] = arguments[_i];
}
// TODO: `preservePDFNull` is for backwards compatibility. Should be
// removed in next breaking API change.
var preservePDFNull = types.includes(PDFNull);
var result = ref instanceof PDFRef ? this.indirectObjects.get(ref) : ref;
if (!result || (result === PDFNull && !preservePDFNull))
return undefined;
for (var idx = 0, len = types.length; idx < len; idx++) {
var type = types[idx];
if (type === PDFNull) {
if (result === PDFNull)
return result;
}
else {
if (result instanceof type)
return result;
}
}
throw new UnexpectedObjectTypeError(types, result);
};
PDFContext.prototype.lookup = function (ref) {
var types = [];
for (var _i = 1; _i < arguments.length; _i++) {
types[_i - 1] = arguments[_i];
}
var result = ref instanceof PDFRef ? this.indirectObjects.get(ref) : ref;
if (types.length === 0)
return result;
for (var idx = 0, len = types.length; idx < len; idx++) {
var type = types[idx];
if (type === PDFNull) {
if (result === PDFNull)
return result;
}
else {
if (result instanceof type)
return result;
}
}
throw new UnexpectedObjectTypeError(types, result);
};
PDFContext.prototype.getObjectRef = function (pdfObject) {
var entries = Array.from(this.indirectObjects.entries());
for (var idx = 0, len = entries.length; idx < len; idx++) {
var _a = entries[idx], ref = _a[0], object = _a[1];
if (object === pdfObject) {
return ref;
}
}
return undefined;
};
PDFContext.prototype.enumerateIndirectObjects = function () {
return Array.from(this.indirectObjects.entries()).sort(byAscendingObjectNumber);
};
PDFContext.prototype.obj = function (literal) {
if (literal instanceof PDFObject) {
return literal;
}
else if (literal === null || literal === undefined) {
return PDFNull;
}
else if (typeof literal === 'string') {
return PDFName.of(literal);
}
else if (typeof literal === 'number') {
return PDFNumber.of(literal);
}
else if (typeof literal === 'boolean') {
return literal ? PDFBool.True : PDFBool.False;
}
else if (Array.isArray(literal)) {
var array = PDFArray.withContext(this);
for (var idx = 0, len = literal.length; idx < len; idx++) {
array.push(this.obj(literal[idx]));
}
return array;
}
else {
var dict = PDFDict.withContext(this);
var keys = Object.keys(literal);
for (var idx = 0, len = keys.length; idx < len; idx++) {
var key = keys[idx];
var value = literal[key];
if (value !== undefined)
dict.set(PDFName.of(key), this.obj(value));
}
return dict;
}
};
PDFContext.prototype.stream = function (contents, dict) {
if (dict === void 0) { dict = {}; }
return PDFRawStream.of(this.obj(dict), typedArrayFor(contents));
};
PDFContext.prototype.flateStream = function (contents, dict) {
if (dict === void 0) { dict = {}; }
return this.stream(pako.deflate(typedArrayFor(contents)), __assign(__assign({}, dict), { Filter: 'FlateDecode' }));
};
PDFContext.prototype.contentStream = function (operators, dict) {
if (dict === void 0) { dict = {}; }
return PDFContentStream.of(this.obj(dict), operators);
};
PDFContext.prototype.formXObject = function (operators, dict) {
if (dict === void 0) { dict = {}; }
return this.contentStream(operators, __assign(__assign({ BBox: this.obj([0, 0, 0, 0]), Matrix: this.obj([1, 0, 0, 1, 0, 0]) }, dict), { Type: 'XObject', Subtype: 'Form' }));
};
/*
* Reference to PDFContentStream that contains a single PDFOperator: `q`.
* Used by [[PDFPageLeaf]] instances to ensure that when content streams are
* added to a modified PDF, they start in the default, unchanged graphics
* state.
*/
PDFContext.prototype.getPushGraphicsStateContentStream = function () {
if (this.pushGraphicsStateContentStreamRef) {
return this.pushGraphicsStateContentStreamRef;
}
var dict = this.obj({});
var op = PDFOperator.of(Ops.PushGraphicsState);
var stream = PDFContentStream.of(dict, [op]);
this.pushGraphicsStateContentStreamRef = this.register(stream);
return this.pushGraphicsStateContentStreamRef;
};
/*
* Reference to PDFContentStream that contains a single PDFOperator: `Q`.
* Used by [[PDFPageLeaf]] instances to ensure that when content streams are
* added to a modified PDF, they start in the default, unchanged graphics
* state.
*/
PDFContext.prototype.getPopGraphicsStateContentStream = function () {
if (this.popGraphicsStateContentStreamRef) {
return this.popGraphicsStateContentStreamRef;
}
var dict = this.obj({});
var op = PDFOperator.of(Ops.PopGraphicsState);
var stream = PDFContentStream.of(dict, [op]);
this.popGraphicsStateContentStreamRef = this.register(stream);
return this.popGraphicsStateContentStreamRef;
};
PDFContext.prototype.addRandomSuffix = function (prefix, suffixLength) {
if (suffixLength === void 0) { suffixLength = 4; }
return prefix + "-" + Math.floor(this.rng.nextInt() * Math.pow(10, suffixLength));
};
PDFContext.create = function () { return new PDFContext(); };
return PDFContext;
}());
export default PDFContext;
//# sourceMappingURL=PDFContext.js.map

1
node_modules/pdf-lib/es/core/PDFContext.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

38
node_modules/pdf-lib/es/core/PDFObjectCopier.d.ts generated vendored Normal file
View File

@@ -0,0 +1,38 @@
import PDFObject from "./objects/PDFObject";
import PDFContext from "./PDFContext";
/**
* PDFObjectCopier copies PDFObjects from a src context to a dest context.
* The primary use case for this is to copy pages between PDFs.
*
* _Copying_ an object with a PDFObjectCopier is different from _cloning_ an
* object with its [[PDFObject.clone]] method:
*
* ```
* const src: PDFContext = ...
* const dest: PDFContext = ...
* const originalObject: PDFObject = ...
* const copiedObject = PDFObjectCopier.for(src, dest).copy(originalObject);
* const clonedObject = originalObject.clone();
* ```
*
* Copying an object is equivalent to cloning it and then copying over any other
* objects that it references. Note that only dictionaries, arrays, and streams
* (or structures build from them) can contain indirect references to other
* objects. Copying a PDFObject that is not a dictionary, array, or stream is
* supported, but is equivalent to cloning it.
*/
declare class PDFObjectCopier {
static for: (src: PDFContext, dest: PDFContext) => PDFObjectCopier;
private readonly src;
private readonly dest;
private readonly traversedObjects;
private constructor();
copy: <T extends PDFObject>(object: T) => T;
private copyPDFPage;
private copyPDFDict;
private copyPDFArray;
private copyPDFStream;
private copyPDFIndirectObject;
}
export default PDFObjectCopier;
//# sourceMappingURL=PDFObjectCopier.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFObjectCopier.d.ts","sourceRoot":"","sources":["../../src/core/PDFObjectCopier.ts"],"names":[],"mappings":"AAGA,OAAO,SAAS,4BAAmC;AAGnD,OAAO,UAAU,qBAA4B;AAG7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,cAAM,eAAe;IACnB,MAAM,CAAC,GAAG,QAAS,UAAU,QAAQ,UAAU,qBACd;IAEjC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAa;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmC;IAEpE,OAAO;IAMP,IAAI,wCAOG;IAEP,OAAO,CAAC,WAAW,CAkBjB;IAEF,OAAO,CAAC,WAAW,CAgBjB;IAEF,OAAO,CAAC,YAAY,CAclB;IAEF,OAAO,CAAC,aAAa,CAenB;IAEF,OAAO,CAAC,qBAAqB,CAe3B;CACH;AAED,eAAe,eAAe,CAAC"}

116
node_modules/pdf-lib/es/core/PDFObjectCopier.js generated vendored Normal file
View File

@@ -0,0 +1,116 @@
import PDFArray from "./objects/PDFArray";
import PDFDict from "./objects/PDFDict";
import PDFName from "./objects/PDFName";
import PDFRef from "./objects/PDFRef";
import PDFStream from "./objects/PDFStream";
import PDFPageLeaf from "./structures/PDFPageLeaf";
/**
* PDFObjectCopier copies PDFObjects from a src context to a dest context.
* The primary use case for this is to copy pages between PDFs.
*
* _Copying_ an object with a PDFObjectCopier is different from _cloning_ an
* object with its [[PDFObject.clone]] method:
*
* ```
* const src: PDFContext = ...
* const dest: PDFContext = ...
* const originalObject: PDFObject = ...
* const copiedObject = PDFObjectCopier.for(src, dest).copy(originalObject);
* const clonedObject = originalObject.clone();
* ```
*
* Copying an object is equivalent to cloning it and then copying over any other
* objects that it references. Note that only dictionaries, arrays, and streams
* (or structures build from them) can contain indirect references to other
* objects. Copying a PDFObject that is not a dictionary, array, or stream is
* supported, but is equivalent to cloning it.
*/
var PDFObjectCopier = /** @class */ (function () {
function PDFObjectCopier(src, dest) {
var _this = this;
this.traversedObjects = new Map();
// prettier-ignore
this.copy = function (object) { return (object instanceof PDFPageLeaf ? _this.copyPDFPage(object)
: object instanceof PDFDict ? _this.copyPDFDict(object)
: object instanceof PDFArray ? _this.copyPDFArray(object)
: object instanceof PDFStream ? _this.copyPDFStream(object)
: object instanceof PDFRef ? _this.copyPDFIndirectObject(object)
: object.clone()); };
this.copyPDFPage = function (originalPage) {
var clonedPage = originalPage.clone();
// Move any entries that the originalPage is inheriting from its parent
// tree nodes directly into originalPage so they are preserved during
// the copy.
var InheritableEntries = PDFPageLeaf.InheritableEntries;
for (var idx = 0, len = InheritableEntries.length; idx < len; idx++) {
var key = PDFName.of(InheritableEntries[idx]);
var value = clonedPage.getInheritableAttribute(key);
if (!clonedPage.get(key) && value)
clonedPage.set(key, value);
}
// Remove the parent reference to prevent the whole donor document's page
// tree from being copied when we only need a single page.
clonedPage.delete(PDFName.of('Parent'));
return _this.copyPDFDict(clonedPage);
};
this.copyPDFDict = function (originalDict) {
if (_this.traversedObjects.has(originalDict)) {
return _this.traversedObjects.get(originalDict);
}
var clonedDict = originalDict.clone(_this.dest);
_this.traversedObjects.set(originalDict, clonedDict);
var entries = originalDict.entries();
for (var idx = 0, len = entries.length; idx < len; idx++) {
var _a = entries[idx], key = _a[0], value = _a[1];
clonedDict.set(key, _this.copy(value));
}
return clonedDict;
};
this.copyPDFArray = function (originalArray) {
if (_this.traversedObjects.has(originalArray)) {
return _this.traversedObjects.get(originalArray);
}
var clonedArray = originalArray.clone(_this.dest);
_this.traversedObjects.set(originalArray, clonedArray);
for (var idx = 0, len = originalArray.size(); idx < len; idx++) {
var value = originalArray.get(idx);
clonedArray.set(idx, _this.copy(value));
}
return clonedArray;
};
this.copyPDFStream = function (originalStream) {
if (_this.traversedObjects.has(originalStream)) {
return _this.traversedObjects.get(originalStream);
}
var clonedStream = originalStream.clone(_this.dest);
_this.traversedObjects.set(originalStream, clonedStream);
var entries = originalStream.dict.entries();
for (var idx = 0, len = entries.length; idx < len; idx++) {
var _a = entries[idx], key = _a[0], value = _a[1];
clonedStream.dict.set(key, _this.copy(value));
}
return clonedStream;
};
this.copyPDFIndirectObject = function (ref) {
var alreadyMapped = _this.traversedObjects.has(ref);
if (!alreadyMapped) {
var newRef = _this.dest.nextRef();
_this.traversedObjects.set(ref, newRef);
var dereferencedValue = _this.src.lookup(ref);
if (dereferencedValue) {
var cloned = _this.copy(dereferencedValue);
_this.dest.assign(newRef, cloned);
}
}
return _this.traversedObjects.get(ref);
};
this.src = src;
this.dest = dest;
}
PDFObjectCopier.for = function (src, dest) {
return new PDFObjectCopier(src, dest);
};
return PDFObjectCopier;
}());
export default PDFObjectCopier;
//# sourceMappingURL=PDFObjectCopier.js.map

1
node_modules/pdf-lib/es/core/PDFObjectCopier.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFObjectCopier.js","sourceRoot":"","sources":["../../src/core/PDFObjectCopier.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,2BAAkC;AACjD,OAAO,OAAO,0BAAiC;AAC/C,OAAO,OAAO,0BAAiC;AAE/C,OAAO,MAAM,yBAAgC;AAC7C,OAAO,SAAS,4BAAmC;AAEnD,OAAO,WAAW,iCAAwC;AAE1D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IAQE,yBAAoB,GAAe,EAAE,IAAgB;QAArD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I,CAAC,aAAa,EAAE;gBAClB,IAAM,MAAM,GAAG,KAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACnC,KAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;gBAEvC,IAAM,iBAAiB,GAAG,KAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC/C,IAAI,iBAAiB,EAAE;oBACrB,IAAM,MAAM,GAAG,KAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;oBAC5C,KAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;iBAClC;aACF;YAED,OAAO,KAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAW,CAAC;QAClD,CAAC,CAAC;QApGA,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAVM,mBAAG,GAAG,UAAC,GAAe,EAAE,IAAgB;QAC7C,OAAA,IAAI,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC;IAA9B,CAA8B,CAAC;IA4GnC,sBAAC;CAAA,AA9GD,IA8GC;AAED,eAAe,eAAe,CAAC"}

View File

@@ -0,0 +1,22 @@
import PDFObject from "../objects/PDFObject";
import PDFString from "../objects/PDFString";
import PDFHexString from "../objects/PDFHexString";
import PDFArray from "../objects/PDFArray";
import PDFName from "../objects/PDFName";
import PDFRef from "../objects/PDFRef";
import PDFAcroTerminal from "./PDFAcroTerminal";
declare class PDFAcroButton extends PDFAcroTerminal {
Opt(): PDFString | PDFHexString | PDFArray | undefined;
setOpt(opt: PDFObject[]): void;
getExportValues(): (PDFString | PDFHexString)[] | undefined;
removeExportValue(idx: number): void;
normalizeExportValues(): void;
/**
* Reuses existing opt if one exists with the same value (assuming
* `useExistingIdx` is `true`). Returns index of existing (or new) opt.
*/
addOpt(opt: PDFHexString | PDFString, useExistingOptIdx: boolean): number;
addWidgetWithOpt(widget: PDFRef, opt: PDFHexString | PDFString, useExistingOptIdx: boolean): PDFName;
}
export default PDFAcroButton;
//# sourceMappingURL=PDFAcroButton.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroButton.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroButton.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,6BAAmC;AACnD,OAAO,SAAS,6BAAmC;AACnD,OAAO,YAAY,gCAAsC;AACzD,OAAO,QAAQ,4BAAkC;AACjD,OAAO,OAAO,2BAAiC;AAC/C,OAAO,MAAM,0BAAgC;AAC7C,OAAO,eAAe,0BAA0C;AAGhE,cAAM,aAAc,SAAQ,eAAe;IACzC,GAAG,IAAI,SAAS,GAAG,YAAY,GAAG,QAAQ,GAAG,SAAS;IAStD,MAAM,CAAC,GAAG,EAAE,SAAS,EAAE;IAIvB,eAAe,IAAI,CAAC,SAAS,GAAG,YAAY,CAAC,EAAE,GAAG,SAAS;IAoB3D,iBAAiB,CAAC,GAAG,EAAE,MAAM;IAiB7B,qBAAqB;IAiBrB;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,YAAY,GAAG,SAAS,EAAE,iBAAiB,EAAE,OAAO,GAAG,MAAM;IAoBzE,gBAAgB,CACd,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,YAAY,GAAG,SAAS,EAC7B,iBAAiB,EAAE,OAAO;CAO7B;AAED,eAAe,aAAa,CAAC"}

94
node_modules/pdf-lib/es/core/acroform/PDFAcroButton.js generated vendored Normal file
View File

@@ -0,0 +1,94 @@
import { __extends } from "tslib";
import PDFString from "../objects/PDFString";
import PDFHexString from "../objects/PDFHexString";
import PDFArray from "../objects/PDFArray";
import PDFName from "../objects/PDFName";
import PDFAcroTerminal from "./PDFAcroTerminal";
import { IndexOutOfBoundsError } from "../errors";
var PDFAcroButton = /** @class */ (function (_super) {
__extends(PDFAcroButton, _super);
function PDFAcroButton() {
return _super !== null && _super.apply(this, arguments) || this;
}
PDFAcroButton.prototype.Opt = function () {
return this.dict.lookupMaybe(PDFName.of('Opt'), PDFString, PDFHexString, PDFArray);
};
PDFAcroButton.prototype.setOpt = function (opt) {
this.dict.set(PDFName.of('Opt'), this.dict.context.obj(opt));
};
PDFAcroButton.prototype.getExportValues = function () {
var opt = this.Opt();
if (!opt)
return undefined;
if (opt instanceof PDFString || opt instanceof PDFHexString) {
return [opt];
}
var values = [];
for (var idx = 0, len = opt.size(); idx < len; idx++) {
var value = opt.lookup(idx);
if (value instanceof PDFString || value instanceof PDFHexString) {
values.push(value);
}
}
return values;
};
PDFAcroButton.prototype.removeExportValue = function (idx) {
var opt = this.Opt();
if (!opt)
return;
if (opt instanceof PDFString || opt instanceof PDFHexString) {
if (idx !== 0)
throw new IndexOutOfBoundsError(idx, 0, 0);
this.setOpt([]);
}
else {
if (idx < 0 || idx > opt.size()) {
throw new IndexOutOfBoundsError(idx, 0, opt.size());
}
opt.remove(idx);
}
};
// Enforce use use of /Opt even if it isn't strictly necessary
PDFAcroButton.prototype.normalizeExportValues = function () {
var _a, _b, _c, _d;
var exportValues = (_a = this.getExportValues()) !== null && _a !== void 0 ? _a : [];
var Opt = [];
var widgets = this.getWidgets();
for (var idx = 0, len = widgets.length; idx < len; idx++) {
var widget = widgets[idx];
var exportVal = (_b = exportValues[idx]) !== null && _b !== void 0 ? _b : PDFHexString.fromText((_d = (_c = widget.getOnValue()) === null || _c === void 0 ? void 0 : _c.decodeText()) !== null && _d !== void 0 ? _d : '');
Opt.push(exportVal);
}
this.setOpt(Opt);
};
/**
* Reuses existing opt if one exists with the same value (assuming
* `useExistingIdx` is `true`). Returns index of existing (or new) opt.
*/
PDFAcroButton.prototype.addOpt = function (opt, useExistingOptIdx) {
var _a;
this.normalizeExportValues();
var optText = opt.decodeText();
var existingIdx;
if (useExistingOptIdx) {
var exportValues = (_a = this.getExportValues()) !== null && _a !== void 0 ? _a : [];
for (var idx = 0, len = exportValues.length; idx < len; idx++) {
var exportVal = exportValues[idx];
if (exportVal.decodeText() === optText)
existingIdx = idx;
}
}
var Opt = this.Opt();
Opt.push(opt);
return existingIdx !== null && existingIdx !== void 0 ? existingIdx : Opt.size() - 1;
};
PDFAcroButton.prototype.addWidgetWithOpt = function (widget, opt, useExistingOptIdx) {
var optIdx = this.addOpt(opt, useExistingOptIdx);
var apStateValue = PDFName.of(String(optIdx));
this.addWidget(widget);
return apStateValue;
};
return PDFAcroButton;
}(PDFAcroTerminal));
export default PDFAcroButton;
//# sourceMappingURL=PDFAcroButton.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroButton.js","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroButton.ts"],"names":[],"mappings":";AACA,OAAO,SAAS,6BAAmC;AACnD,OAAO,YAAY,gCAAsC;AACzD,OAAO,QAAQ,4BAAkC;AACjD,OAAO,OAAO,2BAAiC;AAE/C,OAAO,eAAe,0BAA0C;AAChE,OAAO,EAAE,qBAAqB,EAAE,kBAAwB;AAExD;IAA4B,iCAAe;IAA3C;;IAsGA,CAAC;IArGC,2BAAG,GAAH;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAC1B,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,EACjB,SAAS,EACT,YAAY,EACZ,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,8BAAM,GAAN,UAAO,GAAgB;QACrB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,uCAAe,GAAf;QACE,IAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,IAAI,CAAC,GAAG;YAAE,OAAO,SAAS,CAAC;QAE3B,IAAI,GAAG,YAAY,SAAS,IAAI,GAAG,YAAY,YAAY,EAAE;YAC3D,OAAO,C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GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;QACnD,IAAM,YAAY,GAAG,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QAChD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACvB,OAAO,YAAY,CAAC;IACtB,CAAC;IACH,oBAAC;AAAD,CAAC,AAtGD,CAA4B,eAAe,GAsG1C;AAED,eAAe,aAAa,CAAC"}

View File

@@ -0,0 +1,14 @@
import PDFContext from "../PDFContext";
import PDFRef from "../objects/PDFRef";
import PDFDict from "../objects/PDFDict";
import PDFName from "../objects/PDFName";
import PDFAcroButton from "./PDFAcroButton";
declare class PDFAcroCheckBox extends PDFAcroButton {
static fromDict: (dict: PDFDict, ref: PDFRef) => PDFAcroCheckBox;
static create: (context: PDFContext) => PDFAcroCheckBox;
setValue(value: PDFName): void;
getValue(): PDFName;
getOnValue(): PDFName | undefined;
}
export default PDFAcroCheckBox;
//# sourceMappingURL=PDFAcroCheckBox.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroCheckBox.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroCheckBox.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,sBAA4B;AAC7C,OAAO,MAAM,0BAAgC;AAC7C,OAAO,OAAO,2BAAiC;AAC/C,OAAO,OAAO,2BAAiC;AAC/C,OAAO,aAAa,wBAAwC;AAG5D,cAAM,eAAgB,SAAQ,aAAa;IACzC,MAAM,CAAC,QAAQ,SAAU,OAAO,OAAO,MAAM,qBACZ;IAEjC,MAAM,CAAC,MAAM,YAAa,UAAU,qBAOlC;IAEF,QAAQ,CAAC,KAAK,EAAE,OAAO;IAgBvB,QAAQ,IAAI,OAAO;IAMnB,UAAU,IAAI,OAAO,GAAG,SAAS;CAIlC;AAED,eAAe,eAAe,CAAC"}

View File

@@ -0,0 +1,48 @@
import { __extends } from "tslib";
import PDFName from "../objects/PDFName";
import PDFAcroButton from "./PDFAcroButton";
import { InvalidAcroFieldValueError } from "../errors";
var PDFAcroCheckBox = /** @class */ (function (_super) {
__extends(PDFAcroCheckBox, _super);
function PDFAcroCheckBox() {
return _super !== null && _super.apply(this, arguments) || this;
}
PDFAcroCheckBox.prototype.setValue = function (value) {
var _a;
var onValue = (_a = this.getOnValue()) !== null && _a !== void 0 ? _a : PDFName.of('Yes');
if (value !== onValue && value !== PDFName.of('Off')) {
throw new InvalidAcroFieldValueError();
}
this.dict.set(PDFName.of('V'), value);
var widgets = this.getWidgets();
for (var idx = 0, len = widgets.length; idx < len; idx++) {
var widget = widgets[idx];
var state = widget.getOnValue() === value ? value : PDFName.of('Off');
widget.setAppearanceState(state);
}
};
PDFAcroCheckBox.prototype.getValue = function () {
var v = this.V();
if (v instanceof PDFName)
return v;
return PDFName.of('Off');
};
PDFAcroCheckBox.prototype.getOnValue = function () {
var widget = this.getWidgets()[0];
return widget === null || widget === void 0 ? void 0 : widget.getOnValue();
};
PDFAcroCheckBox.fromDict = function (dict, ref) {
return new PDFAcroCheckBox(dict, ref);
};
PDFAcroCheckBox.create = function (context) {
var dict = context.obj({
FT: 'Btn',
Kids: [],
});
var ref = context.register(dict);
return new PDFAcroCheckBox(dict, ref);
};
return PDFAcroCheckBox;
}(PDFAcroButton));
export default PDFAcroCheckBox;
//# sourceMappingURL=PDFAcroCheckBox.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroCheckBox.js","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroCheckBox.ts"],"names":[],"mappings":";AAGA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,aAAa,wBAAwC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,kBAAwB;AAE7D;IAA8B,mCAAa;IAA3C;;IAuCA,CAAC;IA1BC,kCAAQ,GAAR,UAAS,KAAc;;QACrB,IAAM,OAAO,SAAG,IAAI,CAAC,UAAU,EAAE,mCAAI,OAAO,CAAC,EAAE,CAA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AC,GAAG,CAAC;YACvB,EAAE,EAAE,KAAK;YACT,IAAI,EAAE,EAAE;SACT,CAAC,CAAC;QACH,IAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACxC,CAAC,CAAC;IA4BJ,sBAAC;CAAA,AAvCD,CAA8B,aAAa,GAuC1C;AAED,eAAe,eAAe,CAAC"}

View File

@@ -0,0 +1,21 @@
import PDFAcroTerminal from "./PDFAcroTerminal";
import PDFHexString from "../objects/PDFHexString";
import PDFString from "../objects/PDFString";
import PDFArray from "../objects/PDFArray";
declare class PDFAcroChoice extends PDFAcroTerminal {
setValues(values: (PDFString | PDFHexString)[]): void;
valuesAreValid(values: (PDFString | PDFHexString)[]): boolean;
updateSelectedIndices(values: (PDFString | PDFHexString)[]): void;
getValues(): (PDFString | PDFHexString)[];
Opt(): PDFArray | PDFString | PDFHexString | undefined;
setOptions(options: {
value: PDFString | PDFHexString;
display?: PDFString | PDFHexString;
}[]): void;
getOptions(): {
value: PDFString | PDFHexString;
display: PDFString | PDFHexString;
}[];
}
export default PDFAcroChoice;
//# sourceMappingURL=PDFAcroChoice.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroChoice.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroChoice.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,0BAA0C;AAChE,OAAO,YAAY,gCAAsC;AACzD,OAAO,SAAS,6BAAmC;AACnD,OAAO,QAAQ,4BAAkC;AAQjD,cAAM,aAAc,SAAQ,eAAe;IACzC,SAAS,CAAC,MAAM,EAAE,CAAC,SAAS,GAAG,YAAY,CAAC,EAAE;IAyB9C,cAAc,CAAC,MAAM,EAAE,CAAC,SAAS,GAAG,YAAY,CAAC,EAAE,GAAG,OAAO;IAW7D,qBAAqB,CAAC,MAAM,EAAE,CAAC,SAAS,GAAG,YAAY,CAAC,EAAE;IAgB1D,SAAS,IAAI,CAAC,SAAS,GAAG,YAAY,CAAC,EAAE;IAqBzC,GAAG,IAAI,QAAQ,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS;IAStD,UAAU,CACR,OAAO,EAAE;QACP,KAAK,EAAE,SAAS,GAAG,YAAY,CAAC;QAChC,OAAO,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;KACpC,EAAE;IAUL,UAAU,IAAI;QACZ,KAAK,EAAE,SAAS,GAAG,YAAY,CAAC;QAChC,OAAO,EAAE,SAAS,GAAG,YAAY,CAAC;KACnC,EAAE;CAuCJ;AAED,eAAe,aAAa,CAAC"}

125
node_modules/pdf-lib/es/core/acroform/PDFAcroChoice.js generated vendored Normal file
View File

@@ -0,0 +1,125 @@
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

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroChoice.js","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroChoice.ts"],"names":[],"mappings":";AAAA,OAAO,eAAe,0BAA0C;AAChE,OAAO,YAAY,gCAAsC;AACzD,OAAO,SAAS,6BAAmC;AACnD,OAAO,QAAQ,4BAAkC;AACjD,OAAO,OAAO,2BAAiC;AAC/C,OAAO,EAAE,eAAe,EAAE,gBAAgC;AAC1D,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,GACtB,kBAAwB;AAEzB;IAA4B,iCAAe;IAA3C;;IA2IA,CAAC;IA1IC,iCAAS,GAAT,UAAU,MAAoC;QAC5C,IACE,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC;YACnC,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC;YACnC,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAC5B;YACA,MAAM,IAAI,0BAA0B,EAAE,CAAC;SACxC;QAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;SACnC;QACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3C;QACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACrB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IAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAE7B,oEAAoE;gBACpE,IAAI,IAAI,YAAY,SAAS,IAAI,IAAI,YAAY,YAAY,EAAE;oBAC7D,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;iBAC1C;gBAED,oEAAoE;gBACpE,iEAAiE;gBACjE,8BAA8B;gBAC9B,IAAI,IAAI,YAAY,QAAQ,EAAE;oBAC5B,IAAI,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE;wBACnB,IAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;wBACtD,IAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;wBAC5D,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC,CAAC;qBACtD;iBACF;aACF;YAED,OAAO,GAAG,CAAC;SACZ;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IACH,oBAAC;AAAD,CAAC,AA3ID,CAA4B,eAAe,GA2I1C;AAED,eAAe,aAAa,CAAC"}

View File

@@ -0,0 +1,10 @@
import PDFDict from "../objects/PDFDict";
import PDFAcroChoice from "./PDFAcroChoice";
import PDFContext from "../PDFContext";
import PDFRef from "../objects/PDFRef";
declare class PDFAcroComboBox extends PDFAcroChoice {
static fromDict: (dict: PDFDict, ref: PDFRef) => PDFAcroComboBox;
static create: (context: PDFContext) => PDFAcroComboBox;
}
export default PDFAcroComboBox;
//# sourceMappingURL=PDFAcroComboBox.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroComboBox.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroComboBox.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,aAAa,wBAAwC;AAC5D,OAAO,UAAU,sBAA4B;AAC7C,OAAO,MAAM,0BAAgC;AAG7C,cAAM,eAAgB,SAAQ,aAAa;IACzC,MAAM,CAAC,QAAQ,SAAU,OAAO,OAAO,MAAM,qBACZ;IAEjC,MAAM,CAAC,MAAM,YAAa,UAAU,qBAQlC;CACH;AAED,eAAe,eAAe,CAAC"}

View File

@@ -0,0 +1,24 @@
import { __extends } from "tslib";
import PDFAcroChoice from "./PDFAcroChoice";
import { AcroChoiceFlags } from "./flags";
var PDFAcroComboBox = /** @class */ (function (_super) {
__extends(PDFAcroComboBox, _super);
function PDFAcroComboBox() {
return _super !== null && _super.apply(this, arguments) || this;
}
PDFAcroComboBox.fromDict = function (dict, ref) {
return new PDFAcroComboBox(dict, ref);
};
PDFAcroComboBox.create = function (context) {
var dict = context.obj({
FT: 'Ch',
Ff: AcroChoiceFlags.Combo,
Kids: [],
});
var ref = context.register(dict);
return new PDFAcroComboBox(dict, ref);
};
return PDFAcroComboBox;
}(PDFAcroChoice));
export default PDFAcroComboBox;
//# sourceMappingURL=PDFAcroComboBox.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroComboBox.js","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroComboBox.ts"],"names":[],"mappings":";AACA,OAAO,aAAa,wBAAwC;AAG5D,OAAO,EAAE,eAAe,EAAE,gBAAgC;AAE1D;IAA8B,mCAAa;IAA3C;;IAaA,CAAC;IAZQ,wBAAQ,GAAG,UAAC,IAAa,EAAE,GAAW;QAC3C,OAAA,IAAI,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC;IAA9B,CAA8B,CAAC;IAE1B,sBAAM,GAAG,UAAC,OAAmB;QAClC,IAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;YACvB,EAAE,EAAE,IAAI;YACR,EAAE,EAAE,eAAe,CAAC,KAAK;YACzB,IAAI,EAAE,EAAE;SACT,CAAC,CAAC;QACH,IAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACxC,CAAC,CAAC;IACJ,sBAAC;CAAA,AAbD,CAA8B,aAAa,GAa1C;AAED,eAAe,eAAe,CAAC"}

View File

@@ -0,0 +1,37 @@
import PDFDict from "../objects/PDFDict";
import PDFString from "../objects/PDFString";
import PDFHexString from "../objects/PDFHexString";
import PDFName from "../objects/PDFName";
import PDFObject from "../objects/PDFObject";
import PDFNumber from "../objects/PDFNumber";
import PDFArray from "../objects/PDFArray";
import PDFRef from "../objects/PDFRef";
declare class PDFAcroField {
readonly dict: PDFDict;
readonly ref: PDFRef;
protected constructor(dict: PDFDict, ref: PDFRef);
T(): PDFString | PDFHexString | undefined;
Ff(): PDFNumber | undefined;
V(): PDFObject | undefined;
Kids(): PDFArray | undefined;
DA(): PDFString | PDFHexString | undefined;
setKids(kids: PDFObject[]): void;
getParent(): PDFAcroField | undefined;
setParent(parent: PDFRef | undefined): void;
getFullyQualifiedName(): string | undefined;
getPartialName(): string | undefined;
setPartialName(partialName: string | undefined): void;
setDefaultAppearance(appearance: string): void;
getDefaultAppearance(): string | undefined;
setFontSize(fontSize: number): void;
getFlags(): number;
setFlags(flags: number): void;
hasFlag(flag: number): boolean;
setFlag(flag: number): void;
clearFlag(flag: number): void;
setFlagTo(flag: number, enable: boolean): void;
getInheritableAttribute(name: PDFName): PDFObject | undefined;
ascend(visitor: (node: PDFAcroField) => any): void;
}
export default PDFAcroField;
//# sourceMappingURL=PDFAcroField.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroField.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroField.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,SAAS,6BAAmC;AACnD,OAAO,YAAY,gCAAsC;AACzD,OAAO,OAAO,2BA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AAY,KAAK,GAAG,GAAG,IAAI;CAKnD;AAED,eAAe,YAAY,CAAC"}

146
node_modules/pdf-lib/es/core/acroform/PDFAcroField.js generated vendored Normal file
View File

@@ -0,0 +1,146 @@
import PDFDict from "../objects/PDFDict";
import PDFString from "../objects/PDFString";
import PDFHexString from "../objects/PDFHexString";
import PDFName from "../objects/PDFName";
import PDFNumber from "../objects/PDFNumber";
import PDFArray from "../objects/PDFArray";
import PDFRef from "../objects/PDFRef";
import { findLastMatch } from "../../utils";
import { MissingDAEntryError, MissingTfOperatorError } from "../errors";
// Examples:
// `/Helv 12 Tf` -> ['Helv', '12']
// `/HeBo 8.00 Tf` -> ['HeBo', '8.00']
// `/HeBo Tf` -> ['HeBo', undefined]
var tfRegex = /\/([^\0\t\n\f\r\ ]+)[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]+Tf/;
var PDFAcroField = /** @class */ (function () {
function PDFAcroField(dict, ref) {
this.dict = dict;
this.ref = ref;
}
PDFAcroField.prototype.T = function () {
return this.dict.lookupMaybe(PDFName.of('T'), PDFString, PDFHexString);
};
PDFAcroField.prototype.Ff = function () {
var numberOrRef = this.getInheritableAttribute(PDFName.of('Ff'));
return this.dict.context.lookupMaybe(numberOrRef, PDFNumber);
};
PDFAcroField.prototype.V = function () {
var valueOrRef = this.getInheritableAttribute(PDFName.of('V'));
return this.dict.context.lookup(valueOrRef);
};
PDFAcroField.prototype.Kids = function () {
return this.dict.lookupMaybe(PDFName.of('Kids'), PDFArray);
};
// Parent(): PDFDict | undefined {
// return this.dict.lookupMaybe(PDFName.of('Parent'), PDFDict);
// }
PDFAcroField.prototype.DA = function () {
var da = this.dict.lookup(PDFName.of('DA'));
if (da instanceof PDFString || da instanceof PDFHexString)
return da;
return undefined;
};
PDFAcroField.prototype.setKids = function (kids) {
this.dict.set(PDFName.of('Kids'), this.dict.context.obj(kids));
};
PDFAcroField.prototype.getParent = function () {
// const parent = this.Parent();
// if (!parent) return undefined;
// return new PDFAcroField(parent);
var parentRef = this.dict.get(PDFName.of('Parent'));
if (parentRef instanceof PDFRef) {
var parent_1 = this.dict.lookup(PDFName.of('Parent'), PDFDict);
return new PDFAcroField(parent_1, parentRef);
}
return undefined;
};
PDFAcroField.prototype.setParent = function (parent) {
if (!parent)
this.dict.delete(PDFName.of('Parent'));
else
this.dict.set(PDFName.of('Parent'), parent);
};
PDFAcroField.prototype.getFullyQualifiedName = function () {
var parent = this.getParent();
if (!parent)
return this.getPartialName();
return parent.getFullyQualifiedName() + "." + this.getPartialName();
};
PDFAcroField.prototype.getPartialName = function () {
var _a;
return (_a = this.T()) === null || _a === void 0 ? void 0 : _a.decodeText();
};
PDFAcroField.prototype.setPartialName = function (partialName) {
if (!partialName)
this.dict.delete(PDFName.of('T'));
else
this.dict.set(PDFName.of('T'), PDFHexString.fromText(partialName));
};
PDFAcroField.prototype.setDefaultAppearance = function (appearance) {
this.dict.set(PDFName.of('DA'), PDFString.of(appearance));
};
PDFAcroField.prototype.getDefaultAppearance = function () {
var DA = this.DA();
if (DA instanceof PDFHexString) {
return DA.decodeText();
}
return DA === null || DA === void 0 ? void 0 : DA.asString();
};
PDFAcroField.prototype.setFontSize = function (fontSize) {
var _a;
var name = (_a = this.getFullyQualifiedName()) !== null && _a !== void 0 ? _a : '';
var da = this.getDefaultAppearance();
if (!da)
throw new MissingDAEntryError(name);
var daMatch = findLastMatch(da, tfRegex);
if (!daMatch.match)
throw new MissingTfOperatorError(name);
var daStart = da.slice(0, daMatch.pos - daMatch.match[0].length);
var daEnd = daMatch.pos <= da.length ? da.slice(daMatch.pos) : '';
var fontName = daMatch.match[1];
var modifiedDa = daStart + " /" + fontName + " " + fontSize + " Tf " + daEnd;
this.setDefaultAppearance(modifiedDa);
};
PDFAcroField.prototype.getFlags = function () {
var _a, _b;
return (_b = (_a = this.Ff()) === null || _a === void 0 ? void 0 : _a.asNumber()) !== null && _b !== void 0 ? _b : 0;
};
PDFAcroField.prototype.setFlags = function (flags) {
this.dict.set(PDFName.of('Ff'), PDFNumber.of(flags));
};
PDFAcroField.prototype.hasFlag = function (flag) {
var flags = this.getFlags();
return (flags & flag) !== 0;
};
PDFAcroField.prototype.setFlag = function (flag) {
var flags = this.getFlags();
this.setFlags(flags | flag);
};
PDFAcroField.prototype.clearFlag = function (flag) {
var flags = this.getFlags();
this.setFlags(flags & ~flag);
};
PDFAcroField.prototype.setFlagTo = function (flag, enable) {
if (enable)
this.setFlag(flag);
else
this.clearFlag(flag);
};
PDFAcroField.prototype.getInheritableAttribute = function (name) {
var attribute;
this.ascend(function (node) {
if (!attribute)
attribute = node.dict.get(name);
});
return attribute;
};
PDFAcroField.prototype.ascend = function (visitor) {
visitor(this);
var parent = this.getParent();
if (parent)
parent.ascend(visitor);
};
return PDFAcroField;
}());
export default PDFAcroField;
//# sourceMappingURL=PDFAcroField.js.map

File diff suppressed because one or more lines are too long

21
node_modules/pdf-lib/es/core/acroform/PDFAcroForm.d.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import PDFContext from "../PDFContext";
import PDFDict from "../objects/PDFDict";
import PDFArray from "../objects/PDFArray";
import PDFRef from "../objects/PDFRef";
import PDFAcroField from "./PDFAcroField";
declare class PDFAcroForm {
readonly dict: PDFDict;
static fromDict: (dict: PDFDict) => PDFAcroForm;
static create: (context: PDFContext) => PDFAcroForm;
private constructor();
Fields(): PDFArray | undefined;
getFields(): [PDFAcroField, PDFRef][];
getAllFields(): [PDFAcroField, PDFRef][];
addField(field: PDFRef): void;
removeField(field: PDFAcroField): void;
normalizedEntries(): {
Fields: PDFArray;
};
}
export default PDFAcroForm;
//# sourceMappingURL=PDFAcroForm.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroForm.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroForm.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,sBAA4B;AAC7C,OAAO,OAAO,2BAAiC;AAC/C,OAAO,QAAQ,4BAAkC;AAEjD,OAAO,MAAM,0BAAgC;AAC7C,OAAO,YAAY,uBAAuC;AAO1D,cAAM,WAAW;IACf,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAEvB,MAAM,CAAC,QAAQ,SAAU,OAAO,iBAA2B;IAE3D,MAAM,CAAC,MAAM,YAAa,UAAU,iBAGlC;IAEF,OAAO;IAIP,MAAM,IAAI,QAAQ,GAAG,SAAS;IAM9B,SAAS,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE;IAarC,YAAY,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE;IAoBxC,QAAQ,CAAC,KAAK,EAAE,MAAM;IAKtB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAmBtC,iBAAiB;;;CAUlB;AAED,eAAe,WAAW,CAAC"}

75
node_modules/pdf-lib/es/core/acroform/PDFAcroForm.js generated vendored Normal file
View File

@@ -0,0 +1,75 @@
import PDFDict from "../objects/PDFDict";
import PDFArray from "../objects/PDFArray";
import PDFName from "../objects/PDFName";
import PDFAcroNonTerminal from "./PDFAcroNonTerminal";
import { createPDFAcroField, createPDFAcroFields, } from "./utils";
var PDFAcroForm = /** @class */ (function () {
function PDFAcroForm(dict) {
this.dict = dict;
}
PDFAcroForm.prototype.Fields = function () {
var fields = this.dict.lookup(PDFName.of('Fields'));
if (fields instanceof PDFArray)
return fields;
return undefined;
};
PDFAcroForm.prototype.getFields = function () {
var Fields = this.normalizedEntries().Fields;
var fields = new Array(Fields.size());
for (var idx = 0, len = Fields.size(); idx < len; idx++) {
var ref = Fields.get(idx);
var dict = Fields.lookup(idx, PDFDict);
fields[idx] = [createPDFAcroField(dict, ref), ref];
}
return fields;
};
PDFAcroForm.prototype.getAllFields = function () {
var allFields = [];
var pushFields = function (fields) {
if (!fields)
return;
for (var idx = 0, len = fields.length; idx < len; idx++) {
var field = fields[idx];
allFields.push(field);
var fieldModel = field[0];
if (fieldModel instanceof PDFAcroNonTerminal) {
pushFields(createPDFAcroFields(fieldModel.Kids()));
}
}
};
pushFields(this.getFields());
return allFields;
};
PDFAcroForm.prototype.addField = function (field) {
var Fields = this.normalizedEntries().Fields;
Fields === null || Fields === void 0 ? void 0 : Fields.push(field);
};
PDFAcroForm.prototype.removeField = function (field) {
var parent = field.getParent();
var fields = parent === undefined ? this.normalizedEntries().Fields : parent.Kids();
var index = fields === null || fields === void 0 ? void 0 : fields.indexOf(field.ref);
if (fields === undefined || index === undefined) {
throw new Error("Tried to remove inexistent field " + field.getFullyQualifiedName());
}
fields.remove(index);
if (parent !== undefined && fields.size() === 0) {
this.removeField(parent);
}
};
PDFAcroForm.prototype.normalizedEntries = function () {
var Fields = this.Fields();
if (!Fields) {
Fields = this.dict.context.obj([]);
this.dict.set(PDFName.of('Fields'), Fields);
}
return { Fields: Fields };
};
PDFAcroForm.fromDict = function (dict) { return new PDFAcroForm(dict); };
PDFAcroForm.create = function (context) {
var dict = context.obj({ Fields: [] });
return new PDFAcroForm(dict);
};
return PDFAcroForm;
}());
export default PDFAcroForm;
//# sourceMappingURL=PDFAcroForm.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroForm.js","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroForm.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,QAAQ,4BAAkC;AACjD,OAAO,OAAO,2BAAiC;AAG/C,OAAO,kBAAkB,6BAA6C;AACtE,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GACpB,gBAAgC;AAEjC;IAUE,qBAAoB,IAAa;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,4BAAM,GAAN;QACE,IAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;QACtD,IAAI,MAAM,YAAY,QAAQ;YAAE,OAAO,MAAM,CAAC;QAC9C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED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AAW,CAAC,IAAI,CAAC,EAArB,CAAqB,CAAC;IAEpD,kBAAM,GAAG,UAAC,OAAmB;QAClC,IAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;QACzC,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC;IA+EJ,kBAAC;CAAA,AAvFD,IAuFC;AAED,eAAe,WAAW,CAAC"}

View File

@@ -0,0 +1,10 @@
import PDFDict from "../objects/PDFDict";
import PDFAcroChoice from "./PDFAcroChoice";
import PDFContext from "../PDFContext";
import PDFRef from "../objects/PDFRef";
declare class PDFAcroListBox extends PDFAcroChoice {
static fromDict: (dict: PDFDict, ref: PDFRef) => PDFAcroListBox;
static create: (context: PDFContext) => PDFAcroListBox;
}
export default PDFAcroListBox;
//# sourceMappingURL=PDFAcroListBox.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroListBox.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroListBox.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,aAAa,wBAAwC;AAC5D,OAAO,UAAU,sBAA4B;AAC7C,OAAO,MAAM,0BAAgC;AAE7C,cAAM,cAAe,SAAQ,aAAa;IACxC,MAAM,CAAC,QAAQ,SAAU,OAAO,OAAO,MAAM,oBACb;IAEhC,MAAM,CAAC,MAAM,YAAa,UAAU,oBAOlC;CACH;AAED,eAAe,cAAc,CAAC"}

View File

@@ -0,0 +1,22 @@
import { __extends } from "tslib";
import PDFAcroChoice from "./PDFAcroChoice";
var PDFAcroListBox = /** @class */ (function (_super) {
__extends(PDFAcroListBox, _super);
function PDFAcroListBox() {
return _super !== null && _super.apply(this, arguments) || this;
}
PDFAcroListBox.fromDict = function (dict, ref) {
return new PDFAcroListBox(dict, ref);
};
PDFAcroListBox.create = function (context) {
var dict = context.obj({
FT: 'Ch',
Kids: [],
});
var ref = context.register(dict);
return new PDFAcroListBox(dict, ref);
};
return PDFAcroListBox;
}(PDFAcroChoice));
export default PDFAcroListBox;
//# sourceMappingURL=PDFAcroListBox.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroListBox.js","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroListBox.ts"],"names":[],"mappings":";AACA,OAAO,aAAa,wBAAwC;AAI5D;IAA6B,kCAAa;IAA1C;;IAYA,CAAC;IAXQ,uBAAQ,GAAG,UAAC,IAAa,EAAE,GAAW;QAC3C,OAAA,IAAI,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC;IAA7B,CAA6B,CAAC;IAEzB,qBAAM,GAAG,UAAC,OAAmB;QAClC,IAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;YACvB,EAAE,EAAE,IAAI;YACR,IAAI,EAAE,EAAE;SACT,CAAC,CAAC;QACH,IAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC,CAAC;IACJ,qBAAC;CAAA,AAZD,CAA6B,aAAa,GAYzC;AAED,eAAe,cAAc,CAAC"}

View File

@@ -0,0 +1,14 @@
import PDFDict from "../objects/PDFDict";
import PDFRef from "../objects/PDFRef";
import PDFContext from "../PDFContext";
import PDFAcroField from "./PDFAcroField";
declare class PDFAcroNonTerminal extends PDFAcroField {
static fromDict: (dict: PDFDict, ref: PDFRef) => PDFAcroNonTerminal;
static create: (context: PDFContext) => PDFAcroNonTerminal;
addField(field: PDFRef): void;
normalizedEntries(): {
Kids: import("../objects/PDFArray").default;
};
}
export default PDFAcroNonTerminal;
//# sourceMappingURL=PDFAcroNonTerminal.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroNonTerminal.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroNonTerminal.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,MAAM,0BAAgC;AAE7C,OAAO,UAAU,sBAA4B;AAC7C,OAAO,YAAY,uBAAuC;AAE1D,cAAM,kBAAmB,SAAQ,YAAY;IAC3C,MAAM,CAAC,QAAQ,SAAU,OAAO,OAAO,MAAM,wBACT;IAEpC,MAAM,CAAC,MAAM,YAAa,UAAU,wBAIlC;IAEF,QAAQ,CAAC,KAAK,EAAE,MAAM;IAKtB,iBAAiB;;;CAUlB;AAED,eAAe,kBAAkB,CAAC"}

View File

@@ -0,0 +1,32 @@
import { __extends } from "tslib";
import PDFName from "../objects/PDFName";
import PDFAcroField from "./PDFAcroField";
var PDFAcroNonTerminal = /** @class */ (function (_super) {
__extends(PDFAcroNonTerminal, _super);
function PDFAcroNonTerminal() {
return _super !== null && _super.apply(this, arguments) || this;
}
PDFAcroNonTerminal.prototype.addField = function (field) {
var Kids = this.normalizedEntries().Kids;
Kids === null || Kids === void 0 ? void 0 : Kids.push(field);
};
PDFAcroNonTerminal.prototype.normalizedEntries = function () {
var Kids = this.Kids();
if (!Kids) {
Kids = this.dict.context.obj([]);
this.dict.set(PDFName.of('Kids'), Kids);
}
return { Kids: Kids };
};
PDFAcroNonTerminal.fromDict = function (dict, ref) {
return new PDFAcroNonTerminal(dict, ref);
};
PDFAcroNonTerminal.create = function (context) {
var dict = context.obj({});
var ref = context.register(dict);
return new PDFAcroNonTerminal(dict, ref);
};
return PDFAcroNonTerminal;
}(PDFAcroField));
export default PDFAcroNonTerminal;
//# sourceMappingURL=PDFAcroNonTerminal.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroNonTerminal.js","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroNonTerminal.ts"],"names":[],"mappings":";AAEA,OAAO,OAAO,2BAAiC;AAE/C,OAAO,YAAY,uBAAuC;AAE1D;IAAiC,sCAAY;IAA7C;;IAyBA,CAAC;IAfC,qCAAQ,GAAR,UAAS,KAAa;QACZ,IAAA,IAAI,GAAK,IAAI,CAAC,iBAAiB,EAAE,KAA7B,CAA8B;QAC1C,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAC,KAAK,EAAE;IACpB,CAAC;IAED,8CAAiB,GAAjB;QACE,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAEvB,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACjC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;SACzC;QAED,OAAO,EAAE,IAAI,MAAA,EAAE,CAAC;IAClB,CAAC;IAvBM,2BAAQ,GAAG,UAAC,IAAa,EAAE,GAAW;QAC3C,OAAA,IAAI,kBAAkB,CAAC,IAAI,EAAE,GAAG,CAAC;IAAjC,CAAiC,CAAC;IAE7B,yBAAM,GAAG,UAAC,OAAmB;QAClC,IAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC7B,IAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,kBAAkB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC,CAAC;IAiBJ,yBAAC;CAAA,AAzBD,CAAiC,YAAY,GAyB5C;AAED,eAAe,kBAAkB,CAAC"}

View File

@@ -0,0 +1,10 @@
import PDFDict from "../objects/PDFDict";
import PDFAcroButton from "./PDFAcroButton";
import PDFContext from "../PDFContext";
import PDFRef from "../objects/PDFRef";
declare class PDFAcroPushButton extends PDFAcroButton {
static fromDict: (dict: PDFDict, ref: PDFRef) => PDFAcroPushButton;
static create: (context: PDFContext) => PDFAcroPushButton;
}
export default PDFAcroPushButton;
//# sourceMappingURL=PDFAcroPushButton.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroPushButton.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroPushButton.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,aAAa,wBAAwC;AAC5D,OAAO,UAAU,sBAA4B;AAC7C,OAAO,MAAM,0BAAgC;AAG7C,cAAM,iBAAkB,SAAQ,aAAa;IAC3C,MAAM,CAAC,QAAQ,SAAU,OAAO,OAAO,MAAM,uBACV;IAEnC,MAAM,CAAC,MAAM,YAAa,UAAU,uBAQlC;CACH;AAED,eAAe,iBAAiB,CAAC"}

View File

@@ -0,0 +1,24 @@
import { __extends } from "tslib";
import PDFAcroButton from "./PDFAcroButton";
import { AcroButtonFlags } from "./flags";
var PDFAcroPushButton = /** @class */ (function (_super) {
__extends(PDFAcroPushButton, _super);
function PDFAcroPushButton() {
return _super !== null && _super.apply(this, arguments) || this;
}
PDFAcroPushButton.fromDict = function (dict, ref) {
return new PDFAcroPushButton(dict, ref);
};
PDFAcroPushButton.create = function (context) {
var dict = context.obj({
FT: 'Btn',
Ff: AcroButtonFlags.PushButton,
Kids: [],
});
var ref = context.register(dict);
return new PDFAcroPushButton(dict, ref);
};
return PDFAcroPushButton;
}(PDFAcroButton));
export default PDFAcroPushButton;
//# sourceMappingURL=PDFAcroPushButton.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroPushButton.js","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroPushButton.ts"],"names":[],"mappings":";AACA,OAAO,aAAa,wBAAwC;AAG5D,OAAO,EAAE,eAAe,EAAE,gBAAgC;AAE1D;IAAgC,qCAAa;IAA7C;;IAaA,CAAC;IAZQ,0BAAQ,GAAG,UAAC,IAAa,EAAE,GAAW;QAC3C,OAAA,IAAI,iBAAiB,CAAC,IAAI,EAAE,GAAG,CAAC;IAAhC,CAAgC,CAAC;IAE5B,wBAAM,GAAG,UAAC,OAAmB;QAClC,IAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;YACvB,EAAE,EAAE,KAAK;YACT,EAAE,EAAE,eAAe,CAAC,UAAU;YAC9B,IAAI,EAAE,EAAE;SACT,CAAC,CAAC;QACH,IAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,iBAAiB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC,CAAC;IACJ,wBAAC;CAAA,AAbD,CAAgC,aAAa,GAa5C;AAED,eAAe,iBAAiB,CAAC"}

View File

@@ -0,0 +1,14 @@
import PDFRef from "../objects/PDFRef";
import PDFDict from "../objects/PDFDict";
import PDFName from "../objects/PDFName";
import PDFAcroButton from "./PDFAcroButton";
import PDFContext from "../PDFContext";
declare class PDFAcroRadioButton extends PDFAcroButton {
static fromDict: (dict: PDFDict, ref: PDFRef) => PDFAcroRadioButton;
static create: (context: PDFContext) => PDFAcroRadioButton;
setValue(value: PDFName): void;
getValue(): PDFName;
getOnValues(): PDFName[];
}
export default PDFAcroRadioButton;
//# sourceMappingURL=PDFAcroRadioButton.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroRadioButton.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroRadioButton.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,0BAAgC;AAC7C,OAAO,OAAO,2BAAiC;AAC/C,OAAO,OAAO,2BAAiC;AAC/C,OAAO,aAAa,wBAAwC;AAC5D,OAAO,UAAU,sBAA4B;AAI7C,cAAM,kBAAmB,SAAQ,aAAa;IAC5C,MAAM,CAAC,QAAQ,SAAU,OAAO,OAAO,MAAM,wBACT;IAEpC,MAAM,CAAC,MAAM,YAAa,UAAU,wBAQlC;IAEF,QAAQ,CAAC,KAAK,EAAE,OAAO;IAgBvB,QAAQ,IAAI,OAAO;IAMnB,WAAW,IAAI,OAAO,EAAE;CAWzB;AAED,eAAe,kBAAkB,CAAC"}

View File

@@ -0,0 +1,55 @@
import { __extends } from "tslib";
import PDFName from "../objects/PDFName";
import PDFAcroButton from "./PDFAcroButton";
import { AcroButtonFlags } from "./flags";
import { InvalidAcroFieldValueError } from "../errors";
var PDFAcroRadioButton = /** @class */ (function (_super) {
__extends(PDFAcroRadioButton, _super);
function PDFAcroRadioButton() {
return _super !== null && _super.apply(this, arguments) || this;
}
PDFAcroRadioButton.prototype.setValue = function (value) {
var onValues = this.getOnValues();
if (!onValues.includes(value) && value !== PDFName.of('Off')) {
throw new InvalidAcroFieldValueError();
}
this.dict.set(PDFName.of('V'), value);
var widgets = this.getWidgets();
for (var idx = 0, len = widgets.length; idx < len; idx++) {
var widget = widgets[idx];
var state = widget.getOnValue() === value ? value : PDFName.of('Off');
widget.setAppearanceState(state);
}
};
PDFAcroRadioButton.prototype.getValue = function () {
var v = this.V();
if (v instanceof PDFName)
return v;
return PDFName.of('Off');
};
PDFAcroRadioButton.prototype.getOnValues = function () {
var widgets = this.getWidgets();
var onValues = [];
for (var idx = 0, len = widgets.length; idx < len; idx++) {
var onValue = widgets[idx].getOnValue();
if (onValue)
onValues.push(onValue);
}
return onValues;
};
PDFAcroRadioButton.fromDict = function (dict, ref) {
return new PDFAcroRadioButton(dict, ref);
};
PDFAcroRadioButton.create = function (context) {
var dict = context.obj({
FT: 'Btn',
Ff: AcroButtonFlags.Radio,
Kids: [],
});
var ref = context.register(dict);
return new PDFAcroRadioButton(dict, ref);
};
return PDFAcroRadioButton;
}(PDFAcroButton));
export default PDFAcroRadioButton;
//# sourceMappingURL=PDFAcroRadioButton.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroRadioButton.js","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroRadioButton.ts"],"names":[],"mappings":";AAEA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,aAAa,wBAAwC;AAE5D,OAAO,EAAE,eAAe,EAAE,gBAAgC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,kBAAwB;AAE7D;IAAiC,sCAAa;IAA9C;;IA+CA,CAAC;IAjC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GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;YAC1C,IAAI,OAAO;gBAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACrC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IA7CM,2BAAQ,GAAG,UAAC,IAAa,EAAE,GAAW;QAC3C,OAAA,IAAI,kBAAkB,CAAC,IAAI,EAAE,GAAG,CAAC;IAAjC,CAAiC,CAAC;IAE7B,yBAAM,GAAG,UAAC,OAAmB;QAClC,IAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;YACvB,EAAE,EAAE,KAAK;YACT,EAAE,EAAE,eAAe,CAAC,KAAK;YACzB,IAAI,EAAE,EAAE;SACT,CAAC,CAAC;QACH,IAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,kBAAkB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC,CAAC;IAmCJ,yBAAC;CAAA,AA/CD,CAAiC,aAAa,GA+C7C;AAED,eAAe,kBAAkB,CAAC"}

View File

@@ -0,0 +1,8 @@
import PDFDict from "../objects/PDFDict";
import PDFRef from "../objects/PDFRef";
import PDFAcroTerminal from "./PDFAcroTerminal";
declare class PDFAcroSignature extends PDFAcroTerminal {
static fromDict: (dict: PDFDict, ref: PDFRef) => PDFAcroSignature;
}
export default PDFAcroSignature;
//# sourceMappingURL=PDFAcroSignature.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroSignature.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroSignature.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,MAAM,0BAAgC;AAC7C,OAAO,eAAe,0BAA0C;AAEhE,cAAM,gBAAiB,SAAQ,eAAe;IAC5C,MAAM,CAAC,QAAQ,SAAU,OAAO,OAAO,MAAM,sBACX;CACnC;AAED,eAAe,gBAAgB,CAAC"}

View File

@@ -0,0 +1,14 @@
import { __extends } from "tslib";
import PDFAcroTerminal from "./PDFAcroTerminal";
var PDFAcroSignature = /** @class */ (function (_super) {
__extends(PDFAcroSignature, _super);
function PDFAcroSignature() {
return _super !== null && _super.apply(this, arguments) || this;
}
PDFAcroSignature.fromDict = function (dict, ref) {
return new PDFAcroSignature(dict, ref);
};
return PDFAcroSignature;
}(PDFAcroTerminal));
export default PDFAcroSignature;
//# sourceMappingURL=PDFAcroSignature.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroSignature.js","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroSignature.ts"],"names":[],"mappings":";AAEA,OAAO,eAAe,0BAA0C;AAEhE;IAA+B,oCAAe;IAA9C;;IAGA,CAAC;IAFQ,yBAAQ,GAAG,UAAC,IAAa,EAAE,GAAW;QAC3C,OAAA,IAAI,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC;IAA/B,CAA+B,CAAC;IACpC,uBAAC;CAAA,AAHD,CAA+B,eAAe,GAG7C;AAED,eAAe,gBAAgB,CAAC"}

View File

@@ -0,0 +1,17 @@
import PDFDict from "../objects/PDFDict";
import PDFName from "../objects/PDFName";
import PDFRef from "../objects/PDFRef";
import PDFAcroField from "./PDFAcroField";
import PDFWidgetAnnotation from "../annotation/PDFWidgetAnnotation";
declare class PDFAcroTerminal extends PDFAcroField {
static fromDict: (dict: PDFDict, ref: PDFRef) => PDFAcroTerminal;
FT(): PDFName;
getWidgets(): PDFWidgetAnnotation[];
addWidget(ref: PDFRef): void;
removeWidget(idx: number): void;
normalizedEntries(): {
Kids: import("../objects/PDFArray").default;
};
}
export default PDFAcroTerminal;
//# sourceMappingURL=PDFAcroTerminal.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroTerminal.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroTerminal.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,OAAO,2BAAiC;AAC/C,OAAO,MAAM,0BAAgC;AAC7C,OAAO,YAAY,uBAAuC;AAC1D,OAAO,mBAAmB,0CAAgD;AAG1E,cAAM,eAAgB,SAAQ,YAAY;IACxC,MAAM,CAAC,QAAQ,SAAU,OAAO,OAAO,MAAM,qBACZ;IAEjC,EAAE,IAAI,OAAO;IAKb,UAAU,IAAI,mBAAmB,EAAE;IAgBnC,SAAS,CAAC,GAAG,EAAE,MAAM;IAKrB,YAAY,CAAC,GAAG,EAAE,MAAM;IAgBxB,iBAAiB;;;CAelB;AAED,eAAe,eAAe,CAAC"}

View File

@@ -0,0 +1,68 @@
import { __extends } from "tslib";
import PDFDict from "../objects/PDFDict";
import PDFName from "../objects/PDFName";
import PDFAcroField from "./PDFAcroField";
import PDFWidgetAnnotation from "../annotation/PDFWidgetAnnotation";
import { IndexOutOfBoundsError } from "../errors";
var PDFAcroTerminal = /** @class */ (function (_super) {
__extends(PDFAcroTerminal, _super);
function PDFAcroTerminal() {
return _super !== null && _super.apply(this, arguments) || this;
}
PDFAcroTerminal.prototype.FT = function () {
var nameOrRef = this.getInheritableAttribute(PDFName.of('FT'));
return this.dict.context.lookup(nameOrRef, PDFName);
};
PDFAcroTerminal.prototype.getWidgets = function () {
var kidDicts = this.Kids();
// This field is itself a widget
if (!kidDicts)
return [PDFWidgetAnnotation.fromDict(this.dict)];
// This field's kids are its widgets
var widgets = new Array(kidDicts.size());
for (var idx = 0, len = kidDicts.size(); idx < len; idx++) {
var dict = kidDicts.lookup(idx, PDFDict);
widgets[idx] = PDFWidgetAnnotation.fromDict(dict);
}
return widgets;
};
PDFAcroTerminal.prototype.addWidget = function (ref) {
var Kids = this.normalizedEntries().Kids;
Kids.push(ref);
};
PDFAcroTerminal.prototype.removeWidget = function (idx) {
var kidDicts = this.Kids();
if (!kidDicts) {
// This field is itself a widget
if (idx !== 0)
throw new IndexOutOfBoundsError(idx, 0, 0);
this.setKids([]);
}
else {
// This field's kids are its widgets
if (idx < 0 || idx > kidDicts.size()) {
throw new IndexOutOfBoundsError(idx, 0, kidDicts.size());
}
kidDicts.remove(idx);
}
};
PDFAcroTerminal.prototype.normalizedEntries = function () {
var Kids = this.Kids();
// If this field is itself a widget (because it was only rendered once in
// the document, so the field and widget properties were merged) then we
// add itself to the `Kids` array. The alternative would be to try
// splitting apart the widget properties and creating a separate object
// for them.
if (!Kids) {
Kids = this.dict.context.obj([this.ref]);
this.dict.set(PDFName.of('Kids'), Kids);
}
return { Kids: Kids };
};
PDFAcroTerminal.fromDict = function (dict, ref) {
return new PDFAcroTerminal(dict, ref);
};
return PDFAcroTerminal;
}(PDFAcroField));
export default PDFAcroTerminal;
//# sourceMappingURL=PDFAcroTerminal.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroTerminal.js","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroTerminal.ts"],"names":[],"mappings":";AAAA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,OAAO,2BAAiC;AAE/C,OAAO,YAAY,uBAAuC;AAC1D,OAAO,mBAAmB,0CAAgD;AAC1E,OAAO,EAAE,qBAAqB,EAAE,kBAAwB;AAExD;IAA8B,mCAAY;IAA1C;;IA6DA,CAAC;IAzDC,4BAAE,GAAF;QACE,IAAM,SAAS,GAAG,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,oCAAU,GAAV;QACE,IAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAE7B,gCAAgC;QAChC,IAAI,CAAC,QAAQ;YAAE,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEhE,oCAAoC;QACpC,IAAM,OAAO,GAAG,IAAI,KAAK,CAAsB,QAAQ,CAA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C,IAAI,EAAE;YACT,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YACzC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;SACzC;QAED,OAAO,EAAE,IAAI,MAAA,EAAE,CAAC;IAClB,CAAC;IA3DM,wBAAQ,GAAG,UAAC,IAAa,EAAE,GAAW;QAC3C,OAAA,IAAI,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC;IAA9B,CAA8B,CAAC;IA2DnC,sBAAC;CAAA,AA7DD,CAA8B,YAAY,GA6DzC;AAED,eAAe,eAAe,CAAC"}

23
node_modules/pdf-lib/es/core/acroform/PDFAcroText.d.ts generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import PDFContext from "../PDFContext";
import PDFDict from "../objects/PDFDict";
import PDFNumber from "../objects/PDFNumber";
import PDFString from "../objects/PDFString";
import PDFHexString from "../objects/PDFHexString";
import PDFRef from "../objects/PDFRef";
import PDFAcroTerminal from "./PDFAcroTerminal";
declare class PDFAcroText extends PDFAcroTerminal {
static fromDict: (dict: PDFDict, ref: PDFRef) => PDFAcroText;
static create: (context: PDFContext) => PDFAcroText;
MaxLen(): PDFNumber | undefined;
Q(): PDFNumber | undefined;
setMaxLength(maxLength: number): void;
removeMaxLength(): void;
getMaxLength(): number | undefined;
setQuadding(quadding: 0 | 1 | 2): void;
getQuadding(): number | undefined;
setValue(value: PDFHexString | PDFString): void;
removeValue(): void;
getValue(): PDFString | PDFHexString | undefined;
}
export default PDFAcroText;
//# sourceMappingURL=PDFAcroText.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroText.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroText.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,sBAA4B;AAC7C,OAAO,OAAO,2BAAiC;AAC/C,OAAO,SAAS,6BAAmC;AACnD,OAAO,SAAS,6BAAmC;AACnD,OAAO,YAAY,gCAAsC;AAEzD,OAAO,MAAM,0BAAgC;AAC7C,OAAO,eAAe,0BAA0C;AAEhE,cAAM,WAAY,SAAQ,eAAe;IACvC,MAAM,CAAC,QAAQ,SAAU,OAAO,OAAO,MAAM,iBAAgC;IAE7E,MAAM,CAAC,MAAM,YAAa,UAAU,iBAOlC;IAEF,MAAM,IAAI,SAAS,GAAG,SAAS;IAM/B,CAAC,IAAI,SAAS,GAAG,SAAS;IAM1B,YAAY,CAAC,SAAS,EAAE,MAAM;IAI9B,eAAe;IAIf,YAAY,IAAI,MAAM,GAAG,SAAS;IAIlC,WAAW,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC;IAI/B,WAAW,IAAI,MAAM,GAAG,SAAS;IAIjC,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS;IAWxC,WAAW;IAIX,QAAQ,IAAI,SAAS,GAAG,YAAY,GAAG,SAAS;CAKjD;AAED,eAAe,WAAW,CAAC"}

71
node_modules/pdf-lib/es/core/acroform/PDFAcroText.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
import { __extends } from "tslib";
import PDFNumber from "../objects/PDFNumber";
import PDFString from "../objects/PDFString";
import PDFHexString from "../objects/PDFHexString";
import PDFName from "../objects/PDFName";
import PDFAcroTerminal from "./PDFAcroTerminal";
var PDFAcroText = /** @class */ (function (_super) {
__extends(PDFAcroText, _super);
function PDFAcroText() {
return _super !== null && _super.apply(this, arguments) || this;
}
PDFAcroText.prototype.MaxLen = function () {
var maxLen = this.dict.lookup(PDFName.of('MaxLen'));
if (maxLen instanceof PDFNumber)
return maxLen;
return undefined;
};
PDFAcroText.prototype.Q = function () {
var q = this.dict.lookup(PDFName.of('Q'));
if (q instanceof PDFNumber)
return q;
return undefined;
};
PDFAcroText.prototype.setMaxLength = function (maxLength) {
this.dict.set(PDFName.of('MaxLen'), PDFNumber.of(maxLength));
};
PDFAcroText.prototype.removeMaxLength = function () {
this.dict.delete(PDFName.of('MaxLen'));
};
PDFAcroText.prototype.getMaxLength = function () {
var _a;
return (_a = this.MaxLen()) === null || _a === void 0 ? void 0 : _a.asNumber();
};
PDFAcroText.prototype.setQuadding = function (quadding) {
this.dict.set(PDFName.of('Q'), PDFNumber.of(quadding));
};
PDFAcroText.prototype.getQuadding = function () {
var _a;
return (_a = this.Q()) === null || _a === void 0 ? void 0 : _a.asNumber();
};
PDFAcroText.prototype.setValue = function (value) {
this.dict.set(PDFName.of('V'), value);
// const widgets = this.getWidgets();
// for (let idx = 0, len = widgets.length; idx < len; idx++) {
// const widget = widgets[idx];
// const state = widget.getOnValue() === value ? value : PDFName.of('Off');
// widget.setAppearanceState(state);
// }
};
PDFAcroText.prototype.removeValue = function () {
this.dict.delete(PDFName.of('V'));
};
PDFAcroText.prototype.getValue = function () {
var v = this.V();
if (v instanceof PDFString || v instanceof PDFHexString)
return v;
return undefined;
};
PDFAcroText.fromDict = function (dict, ref) { return new PDFAcroText(dict, ref); };
PDFAcroText.create = function (context) {
var dict = context.obj({
FT: 'Tx',
Kids: [],
});
var ref = context.register(dict);
return new PDFAcroText(dict, ref);
};
return PDFAcroText;
}(PDFAcroTerminal));
export default PDFAcroText;
//# sourceMappingURL=PDFAcroText.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAcroText.js","sourceRoot":"","sources":["../../../src/core/acroform/PDFAcroText.ts"],"names":[],"mappings":";AAEA,OAAO,SAAS,6BAAmC;AACnD,OAAO,SAAS,6BAAmC;AACnD,OAAO,YAAY,gCAAsC;AACzD,OAAO,OAAO,2BAAiC;AAE/C,OAAO,eAAe,0BAA0C;AAEhE;IAA0B,+BAAe;IAAzC;;IAgEA,CAAC;IApDC,4BAAM,GAAN;QACE,IAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;QACtD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CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,8BAAQ,GAAR;QACE,IAAM,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,YAAY,SAAS,IAAI,CAAC,YAAY,YAAY;YAAE,OAAO,CAAC,CAAC;QAClE,OAAO,SAAS,CAAC;IACnB,CAAC;IA9DM,oBAAQ,GAAG,UAAC,IAAa,EAAE,GAAW,IAAK,OAAA,IAAI,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,EAA1B,CAA0B,CAAC;IAEtE,kBAAM,GAAG,UAAC,OAAmB;QAClC,IAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;YACvB,EAAE,EAAE,IAAI;YACR,IAAI,EAAE,EAAE;SACT,CAAC,CAAC;QACH,IAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACpC,CAAC,CAAC;IAsDJ,kBAAC;CAAA,AAhED,CAA0B,eAAe,GAgExC;AAED,eAAe,WAAW,CAAC"}

142
node_modules/pdf-lib/es/core/acroform/flags.d.ts generated vendored Normal file
View File

@@ -0,0 +1,142 @@
/** From PDF spec table 221 */
export declare enum AcroFieldFlags {
/**
* If set, the user may not change the value of the field. Any associated
* widget annotations will not interact with the user; that is, they will not
* respond to mouse clicks or change their appearance in response to mouse
* motions. This flag is useful for fields whose values are computed or
* imported from a database.
*/
ReadOnly,
/**
* If set, the field shall have a value at the time it is exported by a
* submit-form action (see 12.7.5.2, "Submit-Form Action").
*/
Required,
/**
* If set, the field shall not be exported by a submit-form action
* (see 12.7.5.2, "Submit-Form Action").
*/
NoExport
}
/** From PDF spec table 226 */
export declare enum AcroButtonFlags {
/**
* (Radio buttons only) If set, exactly one radio button shall be selected at
* all times; selecting the currently selected button has no effect. If clear,
* clicking the selected button deselects it, leaving no button selected.
*/
NoToggleToOff,
/**
* If set, the field is a set of radio buttons; if clear, the field is a check
* box. This flag may be set only if the Pushbutton flag is clear.
*/
Radio,
/**
* If set, the field is a pushbutton that does not retain a permanent value.
*/
PushButton,
/**
* If set, a group of radio buttons within a radio button field that use the
* same value for the on state will turn on and off in unison; that is if one
* is checked, they are all checked. If clear, the buttons are mutually
* exclusive (the same behavior as HTML radio buttons).
*/
RadiosInUnison
}
/** From PDF spec table 228 */
export declare enum AcroTextFlags {
/**
* If set, the field may contain multiple lines of text; if clear, the field's
* text shall be restricted to a single line.
*/
Multiline,
/**
* If set, the field is intended for entering a secure password that should
* not be echoed visibly to the screen. Characters typed from the keyboard
* shall instead be echoed in some unreadable form, such as asterisks or
* bullet characters.
* > NOTE To protect password confidentiality, readers should never store
* > the value of the text field in the PDF file if this flag is set.
*/
Password,
/**
* If set, the text entered in the field represents the pathname of a file
* whose contents shall be submitted as the value of the field.
*/
FileSelect,
/**
* If set, text entered in the field shall not be spell-checked.
*/
DoNotSpellCheck,
/**
* If set, the field shall not scroll (horizontally for single-line fields,
* vertically for multiple-line fields) to accommodate more text than fits
* within its annotation rectangle. Once the field is full, no further text
* shall be accepted for interactive form filling; for non-interactive form
* filling, the filler should take care not to add more character than will
* visibly fit in the defined area.
*/
DoNotScroll,
/**
* May be set only if the MaxLen entry is present in the text field dictionary
* (see Table 229) and if the Multiline, Password, and FileSelect flags are
* clear. If set, the field shall be automatically divided into as many
* equally spaced positions, or combs, as the value of MaxLen, and the text
* is laid out into those combs.
*/
Comb,
/**
* If set, the value of this field shall be a rich text string
* (see 12.7.3.4, "Rich Text Strings"). If the field has a value, the RV
* entry of the field dictionary (Table 222) shall specify the rich text
* string.
*/
RichText
}
/** From PDF spec table 230 */
export declare enum AcroChoiceFlags {
/**
* If set, the field is a combo box; if clear, the field is a list box.
*/
Combo,
/**
* If set, the combo box shall include an editable text box as well as a
* drop-down list; if clear, it shall include only a drop-down list. This
* flag shall be used only if the Combo flag is set.
*/
Edit,
/**
* If set, the field's option items shall be sorted alphabetically. This flag
* is intended for use by writers, not by readers. Conforming readers shall
* display the options in the order in which they occur in the Opt array
* (see Table 231).
*/
Sort,
/**
* If set, more than one of the field's option items may be selected
* simultaneously; if clear, at most one item shall be selected.
*/
MultiSelect,
/**
* If set, text entered in the field shall not be spell-checked. This flag
* shall not be used unless the Combo and Edit flags are both set.
*/
DoNotSpellCheck,
/**
* If set, the new value shall be committed as soon as a selection is made
* (commonly with the pointing device). In this case, supplying a value for
* a field involves three actions: selecting the field for fill-in,
* selecting a choice for the fill-in value, and leaving that field, which
* finalizes or "commits" the data choice and triggers any actions associated
* with the entry or changing of this data. If this flag is on, then
* processing does not wait for leaving the field action to occur, but
* immediately proceeds to the third step.
*
* This option enables applications to perform an action once a selection is
* made, without requiring the user to exit the field. If clear, the new
* value is not committed until the user exits the field.
*/
CommitOnSelChange
}
//# sourceMappingURL=flags.d.ts.map

1
node_modules/pdf-lib/es/core/acroform/flags.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/flags.ts"],"names":[],"mappings":"AAEA,8BAA8B;AAC9B,oBAAY,cAAc;IACxB;;;;;;OAMG;IACH,QAAsB;IAEtB;;;OAGG;IACH,QAAsB;IAEtB;;;OAGG;IACH,QAAsB;CACvB;AAED,8BAA8B;AAC9B,oBAAY,eAAe;IACzB;;;;OAIG;IACH,aAA4B;IAE5B;;;OAGG;IACH,KAAoB;IAEpB;;OAEG;IACH,UAAyB;IAEzB;;;;;OAKG;IACH,cAA6B;CAC9B;AAED,8BAA8B;AAC9B,oBAAY,aAAa;IACvB;;;OAGG;IACH,SAAwB;IAExB;;;;;;;OAOG;IACH,QAAuB;IAEvB;;;OAGG;IACH,UAAyB;IAEzB;;OAEG;IACH,eAA8B;IAE9B;;;;;;;OAOG;IACH,WAA0B;IAE1B;;;;;;OAMG;IACH,IAAmB;IAEnB;;;;;OAKG;IACH,QAAuB;CACxB;AAED,8BAA8B;AAC9B,oBAAY,eAAe;IACzB;;OAEG;IACH,KAAoB;IAEpB;;;;OAIG;IACH,IAAmB;IAEnB;;;;;OAKG;IACH,IAAmB;IAEnB;;;OAGG;IACH,WAA0B;IAE1B;;;OAGG;IACH,eAA8B;IAE9B;;;;;;;;;;;;;OAaG;IACH,iBAAgC;CACjC"}

147
node_modules/pdf-lib/es/core/acroform/flags.js generated vendored Normal file
View File

@@ -0,0 +1,147 @@
var flag = function (bitIndex) { return 1 << bitIndex; };
/** From PDF spec table 221 */
export var AcroFieldFlags;
(function (AcroFieldFlags) {
/**
* If set, the user may not change the value of the field. Any associated
* widget annotations will not interact with the user; that is, they will not
* respond to mouse clicks or change their appearance in response to mouse
* motions. This flag is useful for fields whose values are computed or
* imported from a database.
*/
AcroFieldFlags[AcroFieldFlags["ReadOnly"] = flag(1 - 1)] = "ReadOnly";
/**
* If set, the field shall have a value at the time it is exported by a
* submit-form action (see 12.7.5.2, "Submit-Form Action").
*/
AcroFieldFlags[AcroFieldFlags["Required"] = flag(2 - 1)] = "Required";
/**
* If set, the field shall not be exported by a submit-form action
* (see 12.7.5.2, "Submit-Form Action").
*/
AcroFieldFlags[AcroFieldFlags["NoExport"] = flag(3 - 1)] = "NoExport";
})(AcroFieldFlags || (AcroFieldFlags = {}));
/** From PDF spec table 226 */
export var AcroButtonFlags;
(function (AcroButtonFlags) {
/**
* (Radio buttons only) If set, exactly one radio button shall be selected at
* all times; selecting the currently selected button has no effect. If clear,
* clicking the selected button deselects it, leaving no button selected.
*/
AcroButtonFlags[AcroButtonFlags["NoToggleToOff"] = flag(15 - 1)] = "NoToggleToOff";
/**
* If set, the field is a set of radio buttons; if clear, the field is a check
* box. This flag may be set only if the Pushbutton flag is clear.
*/
AcroButtonFlags[AcroButtonFlags["Radio"] = flag(16 - 1)] = "Radio";
/**
* If set, the field is a pushbutton that does not retain a permanent value.
*/
AcroButtonFlags[AcroButtonFlags["PushButton"] = flag(17 - 1)] = "PushButton";
/**
* If set, a group of radio buttons within a radio button field that use the
* same value for the on state will turn on and off in unison; that is if one
* is checked, they are all checked. If clear, the buttons are mutually
* exclusive (the same behavior as HTML radio buttons).
*/
AcroButtonFlags[AcroButtonFlags["RadiosInUnison"] = flag(26 - 1)] = "RadiosInUnison";
})(AcroButtonFlags || (AcroButtonFlags = {}));
/** From PDF spec table 228 */
export var AcroTextFlags;
(function (AcroTextFlags) {
/**
* If set, the field may contain multiple lines of text; if clear, the field's
* text shall be restricted to a single line.
*/
AcroTextFlags[AcroTextFlags["Multiline"] = flag(13 - 1)] = "Multiline";
/**
* If set, the field is intended for entering a secure password that should
* not be echoed visibly to the screen. Characters typed from the keyboard
* shall instead be echoed in some unreadable form, such as asterisks or
* bullet characters.
* > NOTE To protect password confidentiality, readers should never store
* > the value of the text field in the PDF file if this flag is set.
*/
AcroTextFlags[AcroTextFlags["Password"] = flag(14 - 1)] = "Password";
/**
* If set, the text entered in the field represents the pathname of a file
* whose contents shall be submitted as the value of the field.
*/
AcroTextFlags[AcroTextFlags["FileSelect"] = flag(21 - 1)] = "FileSelect";
/**
* If set, text entered in the field shall not be spell-checked.
*/
AcroTextFlags[AcroTextFlags["DoNotSpellCheck"] = flag(23 - 1)] = "DoNotSpellCheck";
/**
* If set, the field shall not scroll (horizontally for single-line fields,
* vertically for multiple-line fields) to accommodate more text than fits
* within its annotation rectangle. Once the field is full, no further text
* shall be accepted for interactive form filling; for non-interactive form
* filling, the filler should take care not to add more character than will
* visibly fit in the defined area.
*/
AcroTextFlags[AcroTextFlags["DoNotScroll"] = flag(24 - 1)] = "DoNotScroll";
/**
* May be set only if the MaxLen entry is present in the text field dictionary
* (see Table 229) and if the Multiline, Password, and FileSelect flags are
* clear. If set, the field shall be automatically divided into as many
* equally spaced positions, or combs, as the value of MaxLen, and the text
* is laid out into those combs.
*/
AcroTextFlags[AcroTextFlags["Comb"] = flag(25 - 1)] = "Comb";
/**
* If set, the value of this field shall be a rich text string
* (see 12.7.3.4, "Rich Text Strings"). If the field has a value, the RV
* entry of the field dictionary (Table 222) shall specify the rich text
* string.
*/
AcroTextFlags[AcroTextFlags["RichText"] = flag(26 - 1)] = "RichText";
})(AcroTextFlags || (AcroTextFlags = {}));
/** From PDF spec table 230 */
export var AcroChoiceFlags;
(function (AcroChoiceFlags) {
/**
* If set, the field is a combo box; if clear, the field is a list box.
*/
AcroChoiceFlags[AcroChoiceFlags["Combo"] = flag(18 - 1)] = "Combo";
/**
* If set, the combo box shall include an editable text box as well as a
* drop-down list; if clear, it shall include only a drop-down list. This
* flag shall be used only if the Combo flag is set.
*/
AcroChoiceFlags[AcroChoiceFlags["Edit"] = flag(19 - 1)] = "Edit";
/**
* If set, the field's option items shall be sorted alphabetically. This flag
* is intended for use by writers, not by readers. Conforming readers shall
* display the options in the order in which they occur in the Opt array
* (see Table 231).
*/
AcroChoiceFlags[AcroChoiceFlags["Sort"] = flag(20 - 1)] = "Sort";
/**
* If set, more than one of the field's option items may be selected
* simultaneously; if clear, at most one item shall be selected.
*/
AcroChoiceFlags[AcroChoiceFlags["MultiSelect"] = flag(22 - 1)] = "MultiSelect";
/**
* If set, text entered in the field shall not be spell-checked. This flag
* shall not be used unless the Combo and Edit flags are both set.
*/
AcroChoiceFlags[AcroChoiceFlags["DoNotSpellCheck"] = flag(23 - 1)] = "DoNotSpellCheck";
/**
* If set, the new value shall be committed as soon as a selection is made
* (commonly with the pointing device). In this case, supplying a value for
* a field involves three actions: selecting the field for fill-in,
* selecting a choice for the fill-in value, and leaving that field, which
* finalizes or "commits" the data choice and triggers any actions associated
* with the entry or changing of this data. If this flag is on, then
* processing does not wait for leaving the field action to occur, but
* immediately proceeds to the third step.
*
* This option enables applications to perform an action once a selection is
* made, without requiring the user to exit the field. If clear, the new
* value is not committed until the user exits the field.
*/
AcroChoiceFlags[AcroChoiceFlags["CommitOnSelChange"] = flag(27 - 1)] = "CommitOnSelChange";
})(AcroChoiceFlags || (AcroChoiceFlags = {}));
//# sourceMappingURL=flags.js.map

1
node_modules/pdf-lib/es/core/acroform/flags.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../../../src/core/acroform/flags.ts"],"names":[],"mappings":"AAAA,IAAM,IAAI,GAAG,UAAC,QAAgB,IAAK,OAAA,CAAC,IAAI,QAAQ,EAAb,CAAa,CAAC;AAEjD,8BAA8B;AAC9B,MAAM,CAAN,IAAY,cAqBX;AArBD,WAAY,cAAc;IACxB;;;;;;OAMG;IACH,4CAAW,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,cAAA,CAAA;IAEtB;;;OAGG;IACH,4CAAW,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,cAAA,CAAA;IAEtB;;;OAGG;IACH,4CAAW,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,cAAA,CAAA;AACxB,CAAC,EArBW,cAAc,KAAd,cAAc,QAqBzB;AAED,8BAA8B;AAC9B,MAAM,CAAN,IAAY,eA0BX;AA1BD,WAAY,eAAe;IACzB;;;;OAIG;IACH,mDAAgB,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,mBAAA,CAAA;IAE5B;;;OAGG;IACH,2CAAQ,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,WAAA,CAAA;IAEpB;;OAEG;IACH,gDAAa,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,gBAAA,CAAA;IAEzB;;;;;OAKG;IACH,oDAAiB,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,oBAAA,CAAA;AAC/B,CAAC,EA1BW,eAAe,KAAf,eAAe,QA0B1B;AAED,8BAA8B;AAC9B,MAAM,CAAN,IAAY,aAsDX;AAtDD,WAAY,aAAa;IACvB;;;OAGG;IACH,2CAAY,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,eAAA,CAAA;IAExB;;;;;;;OAOG;IACH,0CAAW,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,cAAA,CAAA;IAEvB;;;OAGG;IACH,4CAAa,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,gBAAA,CAAA;IAEzB;;OAEG;IACH,iDAAkB,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,qBAAA,CAAA;IAE9B;;;;;;;OAOG;IACH,6CAAc,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,iBAAA,CAAA;IAE1B;;;;;;OAMG;IACH,sCAAO,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,UAAA,CAAA;IAEnB;;;;;OAKG;IACH,0CAAW,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,cAAA,CAAA;AACzB,CAAC,EAtDW,aAAa,KAAb,aAAa,QAsDxB;AAED,8BAA8B;AAC9B,MAAM,CAAN,IAAY,eAgDX;AAhDD,WAAY,eAAe;IACzB;;OAEG;IACH,2CAAQ,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,WAAA,CAAA;IAEpB;;;;OAIG;IACH,0CAAO,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,UAAA,CAAA;IAEnB;;;;;OAKG;IACH,0CAAO,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,UAAA,CAAA;IAEnB;;;OAGG;IACH,iDAAc,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,iBAAA,CAAA;IAE1B;;;OAGG;IACH,qDAAkB,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,qBAAA,CAAA;IAE9B;;;;;;;;;;;;;OAaG;IACH,uDAAoB,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,uBAAA,CAAA;AAClC,CAAC,EAhDW,eAAe,KAAf,eAAe,QAgD1B"}

16
node_modules/pdf-lib/es/core/acroform/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
export { default as PDFAcroButton } from "./PDFAcroButton";
export { default as PDFAcroCheckBox } from "./PDFAcroCheckBox";
export { default as PDFAcroChoice } from "./PDFAcroChoice";
export { default as PDFAcroComboBox } from "./PDFAcroComboBox";
export { default as PDFAcroField } from "./PDFAcroField";
export { default as PDFAcroForm } from "./PDFAcroForm";
export { default as PDFAcroListBox } from "./PDFAcroListBox";
export { default as PDFAcroNonTerminal } from "./PDFAcroNonTerminal";
export { default as PDFAcroPushButton } from "./PDFAcroPushButton";
export { default as PDFAcroRadioButton } from "./PDFAcroRadioButton";
export { default as PDFAcroSignature } from "./PDFAcroSignature";
export { default as PDFAcroTerminal } from "./PDFAcroTerminal";
export { default as PDFAcroText } from "./PDFAcroText";
export * from "./flags";
export * from "./utils";
//# sourceMappingURL=index.d.ts.map

1
node_modules/pdf-lib/es/core/acroform/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAe+N,iBAAiB,CAfxM;AAC3E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAc8O,mBAAmB,CAdvN;AAC/E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAamQ,iBAAiB,CAb5O;AAC3E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAYkR,mBAAmB,CAZ3P;AAC/E,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAWwS,gBAAgB,CAXjR;AACzE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAUyT,eAAe,CAVlS;AACvE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MASqU,kBAAkB,CAT9S;AAC7E,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAQmV,sBAAsB,CAR5T;AACrF,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAO0W,qBAAqB,CAPnV;AACnF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAM8X,sBAAsB,CANvW;AACrF,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAKsZ,oBAAoB,CAL/X;AACjF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAI2a,mBAAmB,CAJpZ;AAC/E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAGkc,eAAe,CAH3a;AACvE,cAEkf,SAAS,CAFnd;AACxC,cAC2f,SAAS,CAD5d"}

16
node_modules/pdf-lib/es/core/acroform/index.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
export { default as PDFAcroButton } from "./PDFAcroButton";
export { default as PDFAcroCheckBox } from "./PDFAcroCheckBox";
export { default as PDFAcroChoice } from "./PDFAcroChoice";
export { default as PDFAcroComboBox } from "./PDFAcroComboBox";
export { default as PDFAcroField } from "./PDFAcroField";
export { default as PDFAcroForm } from "./PDFAcroForm";
export { default as PDFAcroListBox } from "./PDFAcroListBox";
export { default as PDFAcroNonTerminal } from "./PDFAcroNonTerminal";
export { default as PDFAcroPushButton } from "./PDFAcroPushButton";
export { default as PDFAcroRadioButton } from "./PDFAcroRadioButton";
export { default as PDFAcroSignature } from "./PDFAcroSignature";
export { default as PDFAcroTerminal } from "./PDFAcroTerminal";
export { default as PDFAcroText } from "./PDFAcroText";
export * from "./flags";
export * from "./utils";
//# sourceMappingURL=index.js.map

1
node_modules/pdf-lib/es/core/acroform/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/acroform/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAenC,iBAAiB,CAf0D;AAC3E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAcpB,mBAAmB,CAd2C;AAC/E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAaC,iBAAiB,CAbsB;AAC3E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAYgB,mBAAmB,CAZO;AAC/E,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAWsC,gBAAgB,CAXf;AACzE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAUuD,eAAe,CAVhC;AACvE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MASmE,kBAAkB,CAT5C;AAC7E,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAQiF,sBAAsB,CAR1D;AACrF,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAOwG,qBAAqB,CAPjF;AACnF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAM4H,sBAAsB,CANrG;AACrF,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAKoJ,oBAAoB,CAL7H;AACjF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAIyK,mBAAmB,CAJlJ;AAC/E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAGgM,eAAe,CAHzK;AACvE,cAEgP,SAAS,CAFjN;AACxC,cACyP,SAAS,CAD1N"}

7
node_modules/pdf-lib/es/core/acroform/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
import PDFDict from "../objects/PDFDict";
import PDFArray from "../objects/PDFArray";
import PDFRef from "../objects/PDFRef";
import PDFAcroField from "./PDFAcroField";
export declare const createPDFAcroFields: (kidDicts?: PDFArray | undefined) => [PDFAcroField, PDFRef][];
export declare const createPDFAcroField: (dict: PDFDict, ref: PDFRef) => PDFAcroField;
//# sourceMappingURL=utils.d.ts.map

1
node_modules/pdf-lib/es/core/acroform/utils.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/acroform/utils.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,2BAAiC;AAE/C,OAAO,QAAQ,4BAAkC;AACjD,OAAO,MAAM,0BAAgC;AAE7C,OAAO,YAAY,uBAAuC;AAc1D,eAAO,MAAM,mBAAmB,uCAE7B,CAAC,YAAY,EAAE,MAAM,CAAC,EAcxB,CAAC;AAEF,eAAO,MAAM,kBAAkB,SACvB,OAAO,OACR,MAAM,KACV,YAIF,CAAC"}

123
node_modules/pdf-lib/es/core/acroform/utils.js generated vendored Normal file
View File

@@ -0,0 +1,123 @@
import PDFNumber from "../objects/PDFNumber";
import PDFDict from "../objects/PDFDict";
import PDFName from "../objects/PDFName";
import PDFArray from "../objects/PDFArray";
import PDFRef from "../objects/PDFRef";
import PDFAcroTerminal from "./PDFAcroTerminal";
import PDFAcroNonTerminal from "./PDFAcroNonTerminal";
import PDFAcroSignature from "./PDFAcroSignature";
import PDFAcroText from "./PDFAcroText";
import PDFAcroPushButton from "./PDFAcroPushButton";
import PDFAcroRadioButton from "./PDFAcroRadioButton";
import PDFAcroCheckBox from "./PDFAcroCheckBox";
import PDFAcroComboBox from "./PDFAcroComboBox";
import PDFAcroListBox from "./PDFAcroListBox";
import { AcroButtonFlags, AcroChoiceFlags } from "./flags";
export var createPDFAcroFields = function (kidDicts) {
if (!kidDicts)
return [];
var kids = [];
for (var idx = 0, len = kidDicts.size(); idx < len; idx++) {
var ref = kidDicts.get(idx);
var dict = kidDicts.lookup(idx);
// if (dict instanceof PDFDict) kids.push(PDFAcroField.fromDict(dict));
if (ref instanceof PDFRef && dict instanceof PDFDict) {
kids.push([createPDFAcroField(dict, ref), ref]);
}
}
return kids;
};
export var createPDFAcroField = function (dict, ref) {
var isNonTerminal = isNonTerminalAcroField(dict);
if (isNonTerminal)
return PDFAcroNonTerminal.fromDict(dict, ref);
return createPDFAcroTerminal(dict, ref);
};
// TODO: Maybe just check if the dict is *not* a widget? That might be better.
// According to the PDF spec:
//
// > A field's children in the hierarchy may also include widget annotations
// > that define its appearance on the page. A field that has children that
// > are fields is called a non-terminal field. A field that does not have
// > children that are fields is called a terminal field.
//
// The spec is not entirely clear about how to determine whether a given
// dictionary represents an acrofield or a widget annotation. So we will assume
// that a dictionary is an acrofield if it is a member of the `/Kids` array
// and it contains a `/T` entry (widgets do not have `/T` entries). This isn't
// a bullet proof solution, because the `/T` entry is technically defined as
// optional for acrofields by the PDF spec. But in practice all acrofields seem
// to have a `/T` entry defined.
var isNonTerminalAcroField = function (dict) {
var kids = dict.lookup(PDFName.of('Kids'));
if (kids instanceof PDFArray) {
for (var idx = 0, len = kids.size(); idx < len; idx++) {
var kid = kids.lookup(idx);
var kidIsField = kid instanceof PDFDict && kid.has(PDFName.of('T'));
if (kidIsField)
return true;
}
}
return false;
};
var createPDFAcroTerminal = function (dict, ref) {
var ftNameOrRef = getInheritableAttribute(dict, PDFName.of('FT'));
var type = dict.context.lookup(ftNameOrRef, PDFName);
if (type === PDFName.of('Btn'))
return createPDFAcroButton(dict, ref);
if (type === PDFName.of('Ch'))
return createPDFAcroChoice(dict, ref);
if (type === PDFName.of('Tx'))
return PDFAcroText.fromDict(dict, ref);
if (type === PDFName.of('Sig'))
return PDFAcroSignature.fromDict(dict, ref);
// We should never reach this line. But there are a lot of weird PDFs out
// there. So, just to be safe, we'll try to handle things gracefully instead
// of throwing an error.
return PDFAcroTerminal.fromDict(dict, ref);
};
var createPDFAcroButton = function (dict, ref) {
var _a;
var ffNumberOrRef = getInheritableAttribute(dict, PDFName.of('Ff'));
var ffNumber = dict.context.lookupMaybe(ffNumberOrRef, PDFNumber);
var flags = (_a = ffNumber === null || ffNumber === void 0 ? void 0 : ffNumber.asNumber()) !== null && _a !== void 0 ? _a : 0;
if (flagIsSet(flags, AcroButtonFlags.PushButton)) {
return PDFAcroPushButton.fromDict(dict, ref);
}
else if (flagIsSet(flags, AcroButtonFlags.Radio)) {
return PDFAcroRadioButton.fromDict(dict, ref);
}
else {
return PDFAcroCheckBox.fromDict(dict, ref);
}
};
var createPDFAcroChoice = function (dict, ref) {
var _a;
var ffNumberOrRef = getInheritableAttribute(dict, PDFName.of('Ff'));
var ffNumber = dict.context.lookupMaybe(ffNumberOrRef, PDFNumber);
var flags = (_a = ffNumber === null || ffNumber === void 0 ? void 0 : ffNumber.asNumber()) !== null && _a !== void 0 ? _a : 0;
if (flagIsSet(flags, AcroChoiceFlags.Combo)) {
return PDFAcroComboBox.fromDict(dict, ref);
}
else {
return PDFAcroListBox.fromDict(dict, ref);
}
};
var flagIsSet = function (flags, flag) {
return (flags & flag) !== 0;
};
var getInheritableAttribute = function (startNode, name) {
var attribute;
ascend(startNode, function (node) {
if (!attribute)
attribute = node.get(name);
});
return attribute;
};
var ascend = function (startNode, visitor) {
visitor(startNode);
var Parent = startNode.lookupMaybe(PDFName.of('Parent'), PDFDict);
if (Parent)
ascend(Parent, visitor);
};
//# sourceMappingURL=utils.js.map

1
node_modules/pdf-lib/es/core/acroform/utils.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/acroform/utils.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,6BAAmC;AACnD,OAAO,OAAO,2BAAiC;AAC/C,OAAO,OAAO,2BAAiC;AAC/C,OAAO,QAAQ,4BAAkC;AACjD,OAAO,MAAM,0BAAgC;AAG7C,OAAO,eAAe,0BAA0C;AAChE,OAAO,kBAAkB,6BAA6C;AAEtE,OAAO,gBAAgB,2BAA2C;AAElE,OAAO,WAAW,sBAAsC;AACxD,OAAO,iBAAiB,4BAA4C;AACpE,OAAO,kBAAkB,6BAA6C;AACtE,OAAO,eAAe,0BAA0C;AAChE,OAAO,eAAe,0BAA0C;AAChE,OAAO,cAAc,yBAAyC;AAC9D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgC;AAE3E,MAAM,CAAC,IAAM,mBAAmB,GAAG,UACjC,QAAmB;IAEnB,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,CAAC;IAEzB,IAAM,IAAI,GAA6B,EAAE,CAAC;IAC1C,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,EAAE;QACzD,IAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAA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,EAAE,UAAC,IAAI;QACrB,IAAI,CAAC,SAAS;YAAE,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,IAAM,MAAM,GAAG,UAAC,SAAkB,EAAE,OAA+B;IACjE,OAAO,CAAC,SAAS,CAAC,CAAC;IACnB,IAAM,MAAM,GAAG,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;IACpE,IAAI,MAAM;QAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC,CAAC"}

View File

@@ -0,0 +1,34 @@
import PDFDict from "../objects/PDFDict";
import PDFNumber from "../objects/PDFNumber";
import PDFArray from "../objects/PDFArray";
import PDFHexString from "../objects/PDFHexString";
import PDFString from "../objects/PDFString";
declare class AppearanceCharacteristics {
readonly dict: PDFDict;
static fromDict: (dict: PDFDict) => AppearanceCharacteristics;
protected constructor(dict: PDFDict);
R(): PDFNumber | undefined;
BC(): PDFArray | undefined;
BG(): PDFArray | undefined;
CA(): PDFHexString | PDFString | undefined;
RC(): PDFHexString | PDFString | undefined;
AC(): PDFHexString | PDFString | undefined;
getRotation(): number | undefined;
getBorderColor(): number[] | undefined;
getBackgroundColor(): number[] | undefined;
getCaptions(): {
normal?: string;
rollover?: string;
down?: string;
};
setRotation(rotation: number): void;
setBorderColor(color: number[]): void;
setBackgroundColor(color: number[]): void;
setCaptions(captions: {
normal: string;
rollover?: string;
down?: string;
}): void;
}
export default AppearanceCharacteristics;
//# sourceMappingURL=AppearanceCharacteristics.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AppearanceCharacteristics.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/AppearanceCharacteristics.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,2BAAiC;AAE/C,OAAO,SAAS,6BAAmC;AACnD,OAAO,QAAQ,4BAAkC;AACjD,OAAO,YAAY,gCAAsC;AACzD,OAAO,SAAS,6BAAmC;AAEnD,cAAM,yBAAyB;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAEvB,MAAM,CAAC,QAAQ,SAAU,OAAO,KAAG,yBAAyB,CACtB;IAEtC,SAAS,aAAa,IAAI,EAAE,OAAO;IAInC,CAAC,IAAI,SAAS,GAAG,SAAS;IAM1B,EAAE,IAAI,QAAQ,GAAG,SAAS;IAM1B,EAAE,IAAI,QAAQ,GAAG,SAAS;IAM1B,EAAE,IAAI,YAAY,GAAG,SAAS,GAAG,SAAS;IAM1C,EAAE,IAAI,YAAY,GAAG,SAAS,GAAG,SAAS;IAM1C,EAAE,IAAI,YAAY,GAAG,SAAS,GAAG,SAAS;IAM1C,WAAW,IAAI,MAAM,GAAG,SAAS;IAIjC,cAAc,IAAI,MAAM,EAAE,GAAG,SAAS;IActC,kBAAkB,IAAI,MAAM,EAAE,GAAG,SAAS;IAc1C,WAAW,IAAI;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;IAYpE,WAAW,CAAC,QAAQ,EAAE,MAAM;IAK5B,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE;IAK9B,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE;IAKlC,WAAW,CAAC,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;CAkB3E;AAED,eAAe,yBAAyB,CAAC"}

View File

@@ -0,0 +1,120 @@
import PDFName from "../objects/PDFName";
import PDFNumber from "../objects/PDFNumber";
import PDFArray from "../objects/PDFArray";
import PDFHexString from "../objects/PDFHexString";
import PDFString from "../objects/PDFString";
var AppearanceCharacteristics = /** @class */ (function () {
function AppearanceCharacteristics(dict) {
this.dict = dict;
}
AppearanceCharacteristics.prototype.R = function () {
var R = this.dict.lookup(PDFName.of('R'));
if (R instanceof PDFNumber)
return R;
return undefined;
};
AppearanceCharacteristics.prototype.BC = function () {
var BC = this.dict.lookup(PDFName.of('BC'));
if (BC instanceof PDFArray)
return BC;
return undefined;
};
AppearanceCharacteristics.prototype.BG = function () {
var BG = this.dict.lookup(PDFName.of('BG'));
if (BG instanceof PDFArray)
return BG;
return undefined;
};
AppearanceCharacteristics.prototype.CA = function () {
var CA = this.dict.lookup(PDFName.of('CA'));
if (CA instanceof PDFHexString || CA instanceof PDFString)
return CA;
return undefined;
};
AppearanceCharacteristics.prototype.RC = function () {
var RC = this.dict.lookup(PDFName.of('RC'));
if (RC instanceof PDFHexString || RC instanceof PDFString)
return RC;
return undefined;
};
AppearanceCharacteristics.prototype.AC = function () {
var AC = this.dict.lookup(PDFName.of('AC'));
if (AC instanceof PDFHexString || AC instanceof PDFString)
return AC;
return undefined;
};
AppearanceCharacteristics.prototype.getRotation = function () {
var _a;
return (_a = this.R()) === null || _a === void 0 ? void 0 : _a.asNumber();
};
AppearanceCharacteristics.prototype.getBorderColor = function () {
var BC = this.BC();
if (!BC)
return undefined;
var components = [];
for (var idx = 0, len = BC === null || BC === void 0 ? void 0 : BC.size(); idx < len; idx++) {
var component = BC.get(idx);
if (component instanceof PDFNumber)
components.push(component.asNumber());
}
return components;
};
AppearanceCharacteristics.prototype.getBackgroundColor = function () {
var BG = this.BG();
if (!BG)
return undefined;
var components = [];
for (var idx = 0, len = BG === null || BG === void 0 ? void 0 : BG.size(); idx < len; idx++) {
var component = BG.get(idx);
if (component instanceof PDFNumber)
components.push(component.asNumber());
}
return components;
};
AppearanceCharacteristics.prototype.getCaptions = function () {
var CA = this.CA();
var RC = this.RC();
var AC = this.AC();
return {
normal: CA === null || CA === void 0 ? void 0 : CA.decodeText(),
rollover: RC === null || RC === void 0 ? void 0 : RC.decodeText(),
down: AC === null || AC === void 0 ? void 0 : AC.decodeText(),
};
};
AppearanceCharacteristics.prototype.setRotation = function (rotation) {
var R = this.dict.context.obj(rotation);
this.dict.set(PDFName.of('R'), R);
};
AppearanceCharacteristics.prototype.setBorderColor = function (color) {
var BC = this.dict.context.obj(color);
this.dict.set(PDFName.of('BC'), BC);
};
AppearanceCharacteristics.prototype.setBackgroundColor = function (color) {
var BG = this.dict.context.obj(color);
this.dict.set(PDFName.of('BG'), BG);
};
AppearanceCharacteristics.prototype.setCaptions = function (captions) {
var CA = PDFHexString.fromText(captions.normal);
this.dict.set(PDFName.of('CA'), CA);
if (captions.rollover) {
var RC = PDFHexString.fromText(captions.rollover);
this.dict.set(PDFName.of('RC'), RC);
}
else {
this.dict.delete(PDFName.of('RC'));
}
if (captions.down) {
var AC = PDFHexString.fromText(captions.down);
this.dict.set(PDFName.of('AC'), AC);
}
else {
this.dict.delete(PDFName.of('AC'));
}
};
AppearanceCharacteristics.fromDict = function (dict) {
return new AppearanceCharacteristics(dict);
};
return AppearanceCharacteristics;
}());
export default AppearanceCharacteristics;
//# sourceMappingURL=AppearanceCharacteristics.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AppearanceCharacteristics.js","sourceRoot":"","sources":["../../../src/core/annotation/AppearanceCharacteristics.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,SAAS,6BAAmC;AACnD,OAAO,QAAQ,4BAAkC;AACjD,OAAO,YAAY,gCAAsC;AACzD,OAAO,SAAS,6BAAmC;AAEnD;IAME,mCAAsB,IAAa;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,qCAAC,GAAD;QACE,IAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5C,IAAI,CAAC,YAAY,SAAS;YAAE,OAAO,CAAC,CAAC;QACrC,OAAO,SAAS,CAAC;IACnB,C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AAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACpD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;SACrC;aAAM;YACL,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;SACpC;QAED,IAAI,QAAQ,CAAC,IAAI,EAAE;YACjB,IAAM,EAAE,GAAG,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAChD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;SACrC;aAAM;YACL,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;SACpC;IACH,CAAC;IAvHM,kCAAQ,GAAG,UAAC,IAAa;QAC9B,OAAA,IAAI,yBAAyB,CAAC,IAAI,CAAC;IAAnC,CAAmC,CAAC;IAuHxC,gCAAC;CAAA,AA3HD,IA2HC;AAED,eAAe,yBAAyB,CAAC"}

View File

@@ -0,0 +1,12 @@
import PDFDict from "../objects/PDFDict";
import PDFNumber from "../objects/PDFNumber";
declare class BorderStyle {
readonly dict: PDFDict;
static fromDict: (dict: PDFDict) => BorderStyle;
protected constructor(dict: PDFDict);
W(): PDFNumber | undefined;
getWidth(): number | undefined;
setWidth(width: number): void;
}
export default BorderStyle;
//# sourceMappingURL=BorderStyle.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BorderStyle.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/BorderStyle.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,2BAAiC;AAE/C,OAAO,SAAS,6BAAmC;AAGnD,cAAM,WAAW;IACf,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAEvB,MAAM,CAAC,QAAQ,SAAU,OAAO,KAAG,WAAW,CAA0B;IAExE,SAAS,aAAa,IAAI,EAAE,OAAO;IAInC,CAAC,IAAI,SAAS,GAAG,SAAS;IAM1B,QAAQ,IAAI,MAAM,GAAG,SAAS;IAI9B,QAAQ,CAAC,KAAK,EAAE,MAAM;CAIvB;AAED,eAAe,WAAW,CAAC"}

26
node_modules/pdf-lib/es/core/annotation/BorderStyle.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
import PDFName from "../objects/PDFName";
import PDFNumber from "../objects/PDFNumber";
// TODO: Also handle the `/S` and `/D` entries
var BorderStyle = /** @class */ (function () {
function BorderStyle(dict) {
this.dict = dict;
}
BorderStyle.prototype.W = function () {
var W = this.dict.lookup(PDFName.of('W'));
if (W instanceof PDFNumber)
return W;
return undefined;
};
BorderStyle.prototype.getWidth = function () {
var _a, _b;
return (_b = (_a = this.W()) === null || _a === void 0 ? void 0 : _a.asNumber()) !== null && _b !== void 0 ? _b : 1;
};
BorderStyle.prototype.setWidth = function (width) {
var W = this.dict.context.obj(width);
this.dict.set(PDFName.of('W'), W);
};
BorderStyle.fromDict = function (dict) { return new BorderStyle(dict); };
return BorderStyle;
}());
export default BorderStyle;
//# sourceMappingURL=BorderStyle.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BorderStyle.js","sourceRoot":"","sources":["../../../src/core/annotation/BorderStyle.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,SAAS,6BAAmC;AAEnD,8CAA8C;AAC9C;IAKE,qBAAsB,IAAa;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,uBAAC,GAAD;QACE,IAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5C,IAAI,CAAC,YAAY,SAAS;YAAE,OAAO,CAAC,CAAC;QACrC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,8BAAQ,GAAR;;QACE,mBAAO,IAAI,CAAC,CAAC,EAAE,0CAAE,QAAQ,qCAAM,CAAC,CAAC;IACnC,CAAC;IAED,8BAAQ,GAAR,UAAS,KAAa;QACpB,IAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,CAAC;IAnBM,oBAAQ,GAAG,UAAC,IAAa,IAAkB,OAAA,IAAI,WAAW,CAAC,IAAI,CAAC,EAArB,CAAqB,CAAC;IAoB1E,kBAAC;CAAA,AAvBD,IAuBC;AAED,eAAe,WAAW,CAAC"}

View File

@@ -0,0 +1,52 @@
import PDFDict from "../objects/PDFDict";
import PDFName from "../objects/PDFName";
import PDFStream from "../objects/PDFStream";
import PDFArray from "../objects/PDFArray";
import PDFRef from "../objects/PDFRef";
import PDFNumber from "../objects/PDFNumber";
declare class PDFAnnotation {
readonly dict: PDFDict;
static fromDict: (dict: PDFDict) => PDFAnnotation;
protected constructor(dict: PDFDict);
Rect(): PDFArray | undefined;
AP(): PDFDict | undefined;
F(): PDFNumber | undefined;
getRectangle(): {
x: number;
y: number;
width: number;
height: number;
};
setRectangle(rect: {
x: number;
y: number;
width: number;
height: number;
}): void;
getAppearanceState(): PDFName | undefined;
setAppearanceState(state: PDFName): void;
setAppearances(appearances: PDFDict): void;
ensureAP(): PDFDict;
getNormalAppearance(): PDFRef | PDFDict;
/** @param appearance A PDFDict or PDFStream (direct or ref) */
setNormalAppearance(appearance: PDFRef | PDFDict): void;
/** @param appearance A PDFDict or PDFStream (direct or ref) */
setRolloverAppearance(appearance: PDFRef | PDFDict): void;
/** @param appearance A PDFDict or PDFStream (direct or ref) */
setDownAppearance(appearance: PDFRef | PDFDict): void;
removeRolloverAppearance(): void;
removeDownAppearance(): void;
getAppearances(): {
normal: PDFStream | PDFDict;
rollover?: PDFStream | PDFDict;
down?: PDFStream | PDFDict;
} | undefined;
getFlags(): number;
setFlags(flags: number): void;
hasFlag(flag: number): boolean;
setFlag(flag: number): void;
clearFlag(flag: number): void;
setFlagTo(flag: number, enable: boolean): void;
}
export default PDFAnnotation;
//# sourceMappingURL=PDFAnnotation.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAnnotation.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/PDFAnnotation.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,OAAO,2BAAiC;AAC/C,OAAO,SAAS,6BAAmC;AACnD,OAAO,QAAQ,4BAAkC;AACjD,OAAO,MAAM,0BAAgC;AAC7C,OAAO,SAAS,6BAAmC;AAEnD,cAAM,aAAa;IACjB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAEvB,MAAM,CAAC,QAAQ,SAAU,OAAO,KAAG,aAAa,CAA4B;IAE5E,SAAS,aAAa,IAAI,EAAE,OAAO;IAKnC,IAAI,IAAI,QAAQ,GAAG,SAAS;IAI5B,EAAE,IAAI,OAAO,GAAG,SAAS;IAIzB,CAAC,IAAI,SAAS,GAAG,SAAS;IAK1B,YAAY,IAAI;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAKvE,YAAY,CAAC,IAAI,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAM1E,kBAAkB,IAAI,OAAO,GAAG,SAAS;IAMzC,kBAAkB,CAAC,KAAK,EAAE,OAAO;IAIjC,cAAc,CAAC,WAAW,EAAE,OAAO;IAInC,QAAQ,IAAI,OAAO;IASnB,mBAAmB,IAAI,MAAM,GAAG,OAAO;IAQvC,+DAA+D;IAC/D,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAKhD,+DAA+D;IAC/D,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAKlD,+DAA+D;IAC/D,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAK9C,wBAAwB;IAKxB,oBAAoB;IAKpB,cAAc,IACV;QACE,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;QAC5B,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;QAC/B,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;KAC5B,GACD,SAAS;IAYb,QAAQ,IAAI,MAAM;IAIlB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAItB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAK9B,OAAO,CAAC,IAAI,EAAE,MAAM;IAKpB,SAAS,CAAC,IAAI,EAAE,MAAM;IAKtB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;CAIxC;AAED,eAAe,aAAa,CAAC"}

View File

@@ -0,0 +1,120 @@
import PDFDict from "../objects/PDFDict";
import PDFName from "../objects/PDFName";
import PDFStream from "../objects/PDFStream";
import PDFArray from "../objects/PDFArray";
import PDFRef from "../objects/PDFRef";
import PDFNumber from "../objects/PDFNumber";
var PDFAnnotation = /** @class */ (function () {
function PDFAnnotation(dict) {
this.dict = dict;
}
// This is technically required by the PDF spec
PDFAnnotation.prototype.Rect = function () {
return this.dict.lookup(PDFName.of('Rect'), PDFArray);
};
PDFAnnotation.prototype.AP = function () {
return this.dict.lookupMaybe(PDFName.of('AP'), PDFDict);
};
PDFAnnotation.prototype.F = function () {
var numberOrRef = this.dict.lookup(PDFName.of('F'));
return this.dict.context.lookupMaybe(numberOrRef, PDFNumber);
};
PDFAnnotation.prototype.getRectangle = function () {
var _a;
var Rect = this.Rect();
return (_a = Rect === null || Rect === void 0 ? void 0 : Rect.asRectangle()) !== null && _a !== void 0 ? _a : { x: 0, y: 0, width: 0, height: 0 };
};
PDFAnnotation.prototype.setRectangle = function (rect) {
var x = rect.x, y = rect.y, width = rect.width, height = rect.height;
var Rect = this.dict.context.obj([x, y, x + width, y + height]);
this.dict.set(PDFName.of('Rect'), Rect);
};
PDFAnnotation.prototype.getAppearanceState = function () {
var AS = this.dict.lookup(PDFName.of('AS'));
if (AS instanceof PDFName)
return AS;
return undefined;
};
PDFAnnotation.prototype.setAppearanceState = function (state) {
this.dict.set(PDFName.of('AS'), state);
};
PDFAnnotation.prototype.setAppearances = function (appearances) {
this.dict.set(PDFName.of('AP'), appearances);
};
PDFAnnotation.prototype.ensureAP = function () {
var AP = this.AP();
if (!AP) {
AP = this.dict.context.obj({});
this.dict.set(PDFName.of('AP'), AP);
}
return AP;
};
PDFAnnotation.prototype.getNormalAppearance = function () {
var AP = this.ensureAP();
var N = AP.get(PDFName.of('N'));
if (N instanceof PDFRef || N instanceof PDFDict)
return N;
throw new Error("Unexpected N type: " + (N === null || N === void 0 ? void 0 : N.constructor.name));
};
/** @param appearance A PDFDict or PDFStream (direct or ref) */
PDFAnnotation.prototype.setNormalAppearance = function (appearance) {
var AP = this.ensureAP();
AP.set(PDFName.of('N'), appearance);
};
/** @param appearance A PDFDict or PDFStream (direct or ref) */
PDFAnnotation.prototype.setRolloverAppearance = function (appearance) {
var AP = this.ensureAP();
AP.set(PDFName.of('R'), appearance);
};
/** @param appearance A PDFDict or PDFStream (direct or ref) */
PDFAnnotation.prototype.setDownAppearance = function (appearance) {
var AP = this.ensureAP();
AP.set(PDFName.of('D'), appearance);
};
PDFAnnotation.prototype.removeRolloverAppearance = function () {
var AP = this.AP();
AP === null || AP === void 0 ? void 0 : AP.delete(PDFName.of('R'));
};
PDFAnnotation.prototype.removeDownAppearance = function () {
var AP = this.AP();
AP === null || AP === void 0 ? void 0 : AP.delete(PDFName.of('D'));
};
PDFAnnotation.prototype.getAppearances = function () {
var AP = this.AP();
if (!AP)
return undefined;
var N = AP.lookup(PDFName.of('N'), PDFDict, PDFStream);
var R = AP.lookupMaybe(PDFName.of('R'), PDFDict, PDFStream);
var D = AP.lookupMaybe(PDFName.of('D'), PDFDict, PDFStream);
return { normal: N, rollover: R, down: D };
};
PDFAnnotation.prototype.getFlags = function () {
var _a, _b;
return (_b = (_a = this.F()) === null || _a === void 0 ? void 0 : _a.asNumber()) !== null && _b !== void 0 ? _b : 0;
};
PDFAnnotation.prototype.setFlags = function (flags) {
this.dict.set(PDFName.of('F'), PDFNumber.of(flags));
};
PDFAnnotation.prototype.hasFlag = function (flag) {
var flags = this.getFlags();
return (flags & flag) !== 0;
};
PDFAnnotation.prototype.setFlag = function (flag) {
var flags = this.getFlags();
this.setFlags(flags | flag);
};
PDFAnnotation.prototype.clearFlag = function (flag) {
var flags = this.getFlags();
this.setFlags(flags & ~flag);
};
PDFAnnotation.prototype.setFlagTo = function (flag, enable) {
if (enable)
this.setFlag(flag);
else
this.clearFlag(flag);
};
PDFAnnotation.fromDict = function (dict) { return new PDFAnnotation(dict); };
return PDFAnnotation;
}());
export default PDFAnnotation;
//# sourceMappingURL=PDFAnnotation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFAnnotation.js","sourceRoot":"","sources":["../../../src/core/annotation/PDFAnnotation.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,OAAO,2BAAiC;AAC/C,OAAO,SAAS,6BAAmC;AACnD,OAAO,QAAQ,4BAAkC;AACjD,OAAO,MAAM,0BAAgC;AAC7C,OAAO,SAAS,6BAAmC;AAEnD;IAKE,uBAAsB,IAAa;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,+CAA+C;IAC/C,4BAAI,GAAJ;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,QAAQ,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,EAAvB,CAAuB,CAAC;IAuI9E,oBAAC;CAAA,AA1ID,IA0IC;AAED,eAAe,aAAa,CAAC"}

View File

@@ -0,0 +1,27 @@
import PDFDict from "../objects/PDFDict";
import PDFName from "../objects/PDFName";
import PDFRef from "../objects/PDFRef";
import PDFString from "../objects/PDFString";
import PDFHexString from "../objects/PDFHexString";
import PDFContext from "../PDFContext";
import BorderStyle from "./BorderStyle";
import PDFAnnotation from "./PDFAnnotation";
import AppearanceCharacteristics from "./AppearanceCharacteristics";
declare class PDFWidgetAnnotation extends PDFAnnotation {
static fromDict: (dict: PDFDict) => PDFWidgetAnnotation;
static create: (context: PDFContext, parent: PDFRef) => PDFWidgetAnnotation;
MK(): PDFDict | undefined;
BS(): PDFDict | undefined;
DA(): PDFString | PDFHexString | undefined;
P(): PDFRef | undefined;
setP(page: PDFRef): void;
setDefaultAppearance(appearance: string): void;
getDefaultAppearance(): string | undefined;
getAppearanceCharacteristics(): AppearanceCharacteristics | undefined;
getOrCreateAppearanceCharacteristics(): AppearanceCharacteristics;
getBorderStyle(): BorderStyle | undefined;
getOrCreateBorderStyle(): BorderStyle;
getOnValue(): PDFName | undefined;
}
export default PDFWidgetAnnotation;
//# sourceMappingURL=PDFWidgetAnnotation.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFWidgetAnnotation.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/PDFWidgetAnnotation.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,OAAO,2BAAiC;AAC/C,OAAO,MAAM,0BAAgC;AAC7C,OAAO,SAAS,6BAAmC;AACnD,OAAO,YAAY,gCAAsC;AACzD,OAAO,UAAU,sBAA4B;AAC7C,OAAO,WAAW,sBAAwC;AAC1D,OAAO,aAAa,wBAA0C;AAC9D,OAAO,yBAAyB,oCAAsD;AAEtF,cAAM,mBAAoB,SAAQ,aAAa;IAC7C,MAAM,CAAC,QAAQ,SAAU,OAAO,KAAG,mBAAmB,CACtB;IAEhC,MAAM,CAAC,MAAM,YAAa,UAAU,UAAU,MAAM,yBAQlD;IAEF,EAAE,IAAI,OAAO,GAAG,SAAS;IAMzB,EAAE,IAAI,OAAO,GAAG,SAAS;IAMzB,EAAE,IAAI,SAAS,GAAG,YAAY,GAAG,SAAS;IAM1C,CAAC,IAAI,MAAM,GAAG,SAAS;IAMvB,IAAI,CAAC,IAAI,EAAE,MAAM;IAIjB,oBAAoB,CAAC,UAAU,EAAE,MAAM;IAIvC,oBAAoB,IAAI,MAAM,GAAG,SAAS;IAU1C,4BAA4B,IAAI,yBAAyB,GAAG,SAAS;IAMrE,oCAAoC,IAAI,yBAAyB;IASjE,cAAc,IAAI,WAAW,GAAG,SAAS;IAMzC,sBAAsB,IAAI,WAAW;IASrC,UAAU,IAAI,OAAO,GAAG,SAAS;CAalC;AAED,eAAe,mBAAmB,CAAC"}

View File

@@ -0,0 +1,108 @@
import { __extends } from "tslib";
import PDFDict from "../objects/PDFDict";
import PDFName from "../objects/PDFName";
import PDFRef from "../objects/PDFRef";
import PDFString from "../objects/PDFString";
import PDFHexString from "../objects/PDFHexString";
import BorderStyle from "./BorderStyle";
import PDFAnnotation from "./PDFAnnotation";
import AppearanceCharacteristics from "./AppearanceCharacteristics";
var PDFWidgetAnnotation = /** @class */ (function (_super) {
__extends(PDFWidgetAnnotation, _super);
function PDFWidgetAnnotation() {
return _super !== null && _super.apply(this, arguments) || this;
}
PDFWidgetAnnotation.prototype.MK = function () {
var MK = this.dict.lookup(PDFName.of('MK'));
if (MK instanceof PDFDict)
return MK;
return undefined;
};
PDFWidgetAnnotation.prototype.BS = function () {
var BS = this.dict.lookup(PDFName.of('BS'));
if (BS instanceof PDFDict)
return BS;
return undefined;
};
PDFWidgetAnnotation.prototype.DA = function () {
var da = this.dict.lookup(PDFName.of('DA'));
if (da instanceof PDFString || da instanceof PDFHexString)
return da;
return undefined;
};
PDFWidgetAnnotation.prototype.P = function () {
var P = this.dict.get(PDFName.of('P'));
if (P instanceof PDFRef)
return P;
return undefined;
};
PDFWidgetAnnotation.prototype.setP = function (page) {
this.dict.set(PDFName.of('P'), page);
};
PDFWidgetAnnotation.prototype.setDefaultAppearance = function (appearance) {
this.dict.set(PDFName.of('DA'), PDFString.of(appearance));
};
PDFWidgetAnnotation.prototype.getDefaultAppearance = function () {
var DA = this.DA();
if (DA instanceof PDFHexString) {
return DA.decodeText();
}
return DA === null || DA === void 0 ? void 0 : DA.asString();
};
PDFWidgetAnnotation.prototype.getAppearanceCharacteristics = function () {
var MK = this.MK();
if (MK)
return AppearanceCharacteristics.fromDict(MK);
return undefined;
};
PDFWidgetAnnotation.prototype.getOrCreateAppearanceCharacteristics = function () {
var MK = this.MK();
if (MK)
return AppearanceCharacteristics.fromDict(MK);
var ac = AppearanceCharacteristics.fromDict(this.dict.context.obj({}));
this.dict.set(PDFName.of('MK'), ac.dict);
return ac;
};
PDFWidgetAnnotation.prototype.getBorderStyle = function () {
var BS = this.BS();
if (BS)
return BorderStyle.fromDict(BS);
return undefined;
};
PDFWidgetAnnotation.prototype.getOrCreateBorderStyle = function () {
var BS = this.BS();
if (BS)
return BorderStyle.fromDict(BS);
var bs = BorderStyle.fromDict(this.dict.context.obj({}));
this.dict.set(PDFName.of('BS'), bs.dict);
return bs;
};
PDFWidgetAnnotation.prototype.getOnValue = function () {
var _a;
var normal = (_a = this.getAppearances()) === null || _a === void 0 ? void 0 : _a.normal;
if (normal instanceof PDFDict) {
var keys = normal.keys();
for (var idx = 0, len = keys.length; idx < len; idx++) {
var key = keys[idx];
if (key !== PDFName.of('Off'))
return key;
}
}
return undefined;
};
PDFWidgetAnnotation.fromDict = function (dict) {
return new PDFWidgetAnnotation(dict);
};
PDFWidgetAnnotation.create = function (context, parent) {
var dict = context.obj({
Type: 'Annot',
Subtype: 'Widget',
Rect: [0, 0, 0, 0],
Parent: parent,
});
return new PDFWidgetAnnotation(dict);
};
return PDFWidgetAnnotation;
}(PDFAnnotation));
export default PDFWidgetAnnotation;
//# sourceMappingURL=PDFWidgetAnnotation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFWidgetAnnotation.js","sourceRoot":"","sources":["../../../src/core/annotation/PDFWidgetAnnotation.ts"],"names":[],"mappings":";AAAA,OAAO,OAAO,2BAAiC;AAC/C,OAAO,OAAO,2BAAiC;AAC/C,OAAO,MAAM,0BAAgC;AAC7C,OAAO,SAAS,6BAAmC;AACnD,OAAO,YAAY,gCAAsC;AAEzD,OAAO,WAAW,sBAAwC;AAC1D,OAAO,aAAa,wBAA0C;AAC9D,OAAO,yBAAyB,oCAAsD;AAEtF;IAAkC,uCAAa;IAA/C;;IAmGA,CAAC;IArFC,gCAAE,GAAF;QACE,IAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9C,IAAI,EAAE,YAAY,OAAO;YAAE,OAAO,EAAE,CAAC;QACrC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,gCAAE,GAAF;QACE,IAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9C,IAAI,EAAE,YAAY,OAAO;YAAE,OAAO,EAAE,CAAC;QACrC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,gCAAE,GAAF;QACE,IAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9C,IAAI,EAAE,YAAY,SAAS,IAAI,EAAE,YAAY,YAAY;YAAE,OAAO,EAAE,CAAC;QACrE,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,+BAAC,GAAD;QACE,IAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACzC,IAAI,CAAC,YAAY,MA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ClD,IAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;YACvB,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,QAAQ;YACjB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YAClB,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;QACH,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC,CAAC;IAuFJ,0BAAC;CAAA,AAnGD,CAAkC,aAAa,GAmG9C;AAED,eAAe,mBAAmB,CAAC"}

80
node_modules/pdf-lib/es/core/annotation/flags.d.ts generated vendored Normal file
View File

@@ -0,0 +1,80 @@
/** From PDF spec table 165 */
export declare enum AnnotationFlags {
/**
* If set, do not display the annotation if it does not belong to one of the
* standard annotation types and no annotation handler is available. If clear,
* display such an unknown annotation using an appearance stream specified by
* its appearance dictionary, if any.
*/
Invisible,
/**
* If set, do not display or print the annotation or allow it to interact with
* the user, regardless of its annotation type or whether an annotation
* handler is available.
*
* In cases where screen space is limited, the ability to hide and show
* annotations selectively can be used in combination with appearance streams
* to display auxiliary pop-up information similar in function to online help
* systems.
*/
Hidden,
/**
* If set, print the annotation when the page is printed. If clear, never
* print the annotation, regardless of whether it is displayed on the screen.
*
* This can be useful for annotations representing interactive pushbuttons,
* which would serve no meaningful purpose on the printed page.
*/
Print,
/**
* If set, do not scale the annotations appearance to match the magnification
* of the page. The location of the annotation on the page (defined by the
* upper-left corner of its annotation rectangle) shall remain fixed,
* regardless of the page magnification.
*/
NoZoom,
/**
* If set, do not rotate the annotations appearance to match the rotation of
* the page. The upper-left corner of the annotation rectangle shall remain in
* a fixed location on the page, regardless of the page rotation.
*/
NoRotate,
/**
* If set, do not display the annotation on the screen or allow it to interact
* with the user. The annotation may be printed (depending on the setting of
* the Print flag) but should be considered hidden for purposes of on-screen
* display and user interaction.
*/
NoView,
/**
* If set, do not allow the annotation to interact with the user. The
* annotation may be displayed or printed (depending on the settings of the
* NoView and Print flags) but should not respond to mouse clicks or change
* its appearance in response to mouse motions.
*
* This flag shall be ignored for widget annotations; its function is
* subsumed by the ReadOnly flag of the associated form field.
*/
ReadOnly,
/**
* If set, do not allow the annotation to be deleted or its properties
* (including position and size) to be modified by the user. However, this
* flag does not restrict changes to the annotations contents, such as the
* value of a form field.
*/
Locked,
/**
* If set, invert the interpretation of the NoView flag for certain events.
*
* A typical use is to have an annotation that appears only when a mouse
* cursor is held over it.
*/
ToggleNoView,
/**
* If set, do not allow the contents of the annotation to be modified by the
* user. This flag does not restrict deletion of the annotation or changes to
* other annotation properties, such as position and size.
*/
LockedContents
}
//# sourceMappingURL=flags.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/flags.ts"],"names":[],"mappings":"AAEA,8BAA8B;AAC9B,oBAAY,eAAe;IACzB;;;;;OAKG;IACH,SAAuB;IAEvB;;;;;;;;;OASG;IACH,MAAoB;IAEpB;;;;;;OAMG;IACH,KAAmB;IAEnB;;;;;OAKG;IACH,MAAoB;IAEpB;;;;OAIG;IACH,QAAsB;IAEtB;;;;;OAKG;IACH,MAAoB;IAEpB;;;;;;;;OAQG;IACH,QAAsB;IAEtB;;;;;OAKG;IACH,MAAoB;IAEpB;;;;;OAKG;IACH,YAA0B;IAE1B;;;;OAIG;IACH,cAA6B;CAC9B"}

82
node_modules/pdf-lib/es/core/annotation/flags.js generated vendored Normal file
View File

@@ -0,0 +1,82 @@
var flag = function (bitIndex) { return 1 << bitIndex; };
/** From PDF spec table 165 */
export var AnnotationFlags;
(function (AnnotationFlags) {
/**
* If set, do not display the annotation if it does not belong to one of the
* standard annotation types and no annotation handler is available. If clear,
* display such an unknown annotation using an appearance stream specified by
* its appearance dictionary, if any.
*/
AnnotationFlags[AnnotationFlags["Invisible"] = flag(1 - 1)] = "Invisible";
/**
* If set, do not display or print the annotation or allow it to interact with
* the user, regardless of its annotation type or whether an annotation
* handler is available.
*
* In cases where screen space is limited, the ability to hide and show
* annotations selectively can be used in combination with appearance streams
* to display auxiliary pop-up information similar in function to online help
* systems.
*/
AnnotationFlags[AnnotationFlags["Hidden"] = flag(2 - 1)] = "Hidden";
/**
* If set, print the annotation when the page is printed. If clear, never
* print the annotation, regardless of whether it is displayed on the screen.
*
* This can be useful for annotations representing interactive pushbuttons,
* which would serve no meaningful purpose on the printed page.
*/
AnnotationFlags[AnnotationFlags["Print"] = flag(3 - 1)] = "Print";
/**
* If set, do not scale the annotations appearance to match the magnification
* of the page. The location of the annotation on the page (defined by the
* upper-left corner of its annotation rectangle) shall remain fixed,
* regardless of the page magnification.
*/
AnnotationFlags[AnnotationFlags["NoZoom"] = flag(4 - 1)] = "NoZoom";
/**
* If set, do not rotate the annotations appearance to match the rotation of
* the page. The upper-left corner of the annotation rectangle shall remain in
* a fixed location on the page, regardless of the page rotation.
*/
AnnotationFlags[AnnotationFlags["NoRotate"] = flag(5 - 1)] = "NoRotate";
/**
* If set, do not display the annotation on the screen or allow it to interact
* with the user. The annotation may be printed (depending on the setting of
* the Print flag) but should be considered hidden for purposes of on-screen
* display and user interaction.
*/
AnnotationFlags[AnnotationFlags["NoView"] = flag(6 - 1)] = "NoView";
/**
* If set, do not allow the annotation to interact with the user. The
* annotation may be displayed or printed (depending on the settings of the
* NoView and Print flags) but should not respond to mouse clicks or change
* its appearance in response to mouse motions.
*
* This flag shall be ignored for widget annotations; its function is
* subsumed by the ReadOnly flag of the associated form field.
*/
AnnotationFlags[AnnotationFlags["ReadOnly"] = flag(7 - 1)] = "ReadOnly";
/**
* If set, do not allow the annotation to be deleted or its properties
* (including position and size) to be modified by the user. However, this
* flag does not restrict changes to the annotations contents, such as the
* value of a form field.
*/
AnnotationFlags[AnnotationFlags["Locked"] = flag(8 - 1)] = "Locked";
/**
* If set, invert the interpretation of the NoView flag for certain events.
*
* A typical use is to have an annotation that appears only when a mouse
* cursor is held over it.
*/
AnnotationFlags[AnnotationFlags["ToggleNoView"] = flag(9 - 1)] = "ToggleNoView";
/**
* If set, do not allow the contents of the annotation to be modified by the
* user. This flag does not restrict deletion of the annotation or changes to
* other annotation properties, such as position and size.
*/
AnnotationFlags[AnnotationFlags["LockedContents"] = flag(10 - 1)] = "LockedContents";
})(AnnotationFlags || (AnnotationFlags = {}));
//# sourceMappingURL=flags.js.map

1
node_modules/pdf-lib/es/core/annotation/flags.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../../../src/core/annotation/flags.ts"],"names":[],"mappings":"AAAA,IAAM,IAAI,GAAG,UAAC,QAAgB,IAAK,OAAA,CAAC,IAAI,QAAQ,EAAb,CAAa,CAAC;AAEjD,8BAA8B;AAC9B,MAAM,CAAN,IAAY,eAsFX;AAtFD,WAAY,eAAe;IACzB;;;;;OAKG;IACH,+CAAY,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,eAAA,CAAA;IAEvB;;;;;;;;;OASG;IACH,4CAAS,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,YAAA,CAAA;IAEpB;;;;;;OAMG;IACH,2CAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,WAAA,CAAA;IAEnB;;;;;OAKG;IACH,4CAAS,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,YAAA,CAAA;IAEpB;;;;OAIG;IACH,8CAAW,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,cAAA,CAAA;IAEtB;;;;;OAKG;IACH,4CAAS,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,YAAA,CAAA;IAEpB;;;;;;;;OAQG;IACH,8CAAW,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,cAAA,CAAA;IAEtB;;;;;OAKG;IACH,4CAAS,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,YAAA,CAAA;IAEpB;;;;;OAKG;IACH,kDAAe,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,kBAAA,CAAA;IAE1B;;;;OAIG;IACH,oDAAiB,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,oBAAA,CAAA;AAC/B,CAAC,EAtFW,eAAe,KAAf,eAAe,QAsF1B"}

5
node_modules/pdf-lib/es/core/annotation/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
export { default as PDFAnnotation } from "./PDFAnnotation";
export { default as PDFWidgetAnnotation } from "./PDFWidgetAnnotation";
export { default as AppearanceCharacteristics } from "./AppearanceCharacteristics";
export * from "./flags";
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/annotation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAI2C,iBAAiB,CAJlB;AAC7E,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAGsD,uBAAuB,CAH7B;AACzF,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAEuE,6BAA6B,CAF9C;AACrG,cACmJ,SAAS,CADlH"}

5
node_modules/pdf-lib/es/core/annotation/index.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
export { default as PDFAnnotation } from "./PDFAnnotation";
export { default as PDFWidgetAnnotation } from "./PDFWidgetAnnotation";
export { default as AppearanceCharacteristics } from "./AppearanceCharacteristics";
export * from "./flags";
//# sourceMappingURL=index.js.map

1
node_modules/pdf-lib/es/core/annotation/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/annotation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAInC,iBAAiB,CAJ4D;AAC7E,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAGxB,uBAAuB,CAHiD;AACzF,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAEP,6BAA6B,CAFgC;AACrG,cACqE,SAAS,CADpC"}

View File

@@ -0,0 +1,28 @@
import PDFRef from "../objects/PDFRef";
export interface Entry {
ref: PDFRef;
offset: number;
deleted: boolean;
}
/**
* Entries should be added using the [[addEntry]] and [[addDeletedEntry]]
* methods **in order of ascending object number**.
*/
declare class PDFCrossRefSection {
static create: () => PDFCrossRefSection;
static createEmpty: () => PDFCrossRefSection;
private subsections;
private chunkIdx;
private chunkLength;
private constructor();
addEntry(ref: PDFRef, offset: number): void;
addDeletedEntry(ref: PDFRef, nextFreeObjectNumber: number): void;
toString(): string;
sizeInBytes(): number;
copyBytesInto(buffer: Uint8Array, offset: number): number;
private copySubsectionsIntoBuffer;
private copyEntriesIntoBuffer;
private append;
}
export default PDFCrossRefSection;
//# sourceMappingURL=PDFCrossRefSection.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFCrossRefSection.d.ts","sourceRoot":"","sources":["../../../src/core/document/PDFCrossRefSection.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,0BAAgC;AAI7C,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,cAAM,kBAAkB;IACtB,MAAM,CAAC,MAAM,2BAKR;IAEL,MAAM,CAAC,WAAW,2BAAkC;IAEpD,OAAO,CAAC,WAAW,CAAY;IAC/B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO;IAMP,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAI3C,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,GAAG,IAAI;IAIhE,QAAQ,IAAI,MAAM;IA4BlB,WAAW,IAAI,MAAM;IAcrB,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;IAczD,OAAO,CAAC,yBAAyB;IAyBjC,OAAO,CAAC,qBAAqB;IA2B7B,OAAO,CAAC,MAAM;CAoBf;AAED,eAAe,kBAAkB,CAAC"}

View File

@@ -0,0 +1,121 @@
import PDFRef from "../objects/PDFRef";
import CharCodes from "../syntax/CharCodes";
import { copyStringIntoBuffer, padStart } from "../../utils";
/**
* Entries should be added using the [[addEntry]] and [[addDeletedEntry]]
* methods **in order of ascending object number**.
*/
var PDFCrossRefSection = /** @class */ (function () {
function PDFCrossRefSection(firstEntry) {
this.subsections = firstEntry ? [[firstEntry]] : [];
this.chunkIdx = 0;
this.chunkLength = firstEntry ? 1 : 0;
}
PDFCrossRefSection.prototype.addEntry = function (ref, offset) {
this.append({ ref: ref, offset: offset, deleted: false });
};
PDFCrossRefSection.prototype.addDeletedEntry = function (ref, nextFreeObjectNumber) {
this.append({ ref: ref, offset: nextFreeObjectNumber, deleted: true });
};
PDFCrossRefSection.prototype.toString = function () {
var section = "xref\n";
for (var rangeIdx = 0, rangeLen = this.subsections.length; rangeIdx < rangeLen; rangeIdx++) {
var range = this.subsections[rangeIdx];
section += range[0].ref.objectNumber + " " + range.length + "\n";
for (var entryIdx = 0, entryLen = range.length; entryIdx < entryLen; entryIdx++) {
var entry = range[entryIdx];
section += padStart(String(entry.offset), 10, '0');
section += ' ';
section += padStart(String(entry.ref.generationNumber), 5, '0');
section += ' ';
section += entry.deleted ? 'f' : 'n';
section += ' \n';
}
}
return section;
};
PDFCrossRefSection.prototype.sizeInBytes = function () {
var size = 5;
for (var idx = 0, len = this.subsections.length; idx < len; idx++) {
var subsection = this.subsections[idx];
var subsectionLength = subsection.length;
var firstEntry = subsection[0];
size += 2;
size += String(firstEntry.ref.objectNumber).length;
size += String(subsectionLength).length;
size += 20 * subsectionLength;
}
return size;
};
PDFCrossRefSection.prototype.copyBytesInto = function (buffer, offset) {
var initialOffset = offset;
buffer[offset++] = CharCodes.x;
buffer[offset++] = CharCodes.r;
buffer[offset++] = CharCodes.e;
buffer[offset++] = CharCodes.f;
buffer[offset++] = CharCodes.Newline;
offset += this.copySubsectionsIntoBuffer(this.subsections, buffer, offset);
return offset - initialOffset;
};
PDFCrossRefSection.prototype.copySubsectionsIntoBuffer = function (subsections, buffer, offset) {
var initialOffset = offset;
var length = subsections.length;
for (var idx = 0; idx < length; idx++) {
var subsection = this.subsections[idx];
var firstObjectNumber = String(subsection[0].ref.objectNumber);
offset += copyStringIntoBuffer(firstObjectNumber, buffer, offset);
buffer[offset++] = CharCodes.Space;
var rangeLength = String(subsection.length);
offset += copyStringIntoBuffer(rangeLength, buffer, offset);
buffer[offset++] = CharCodes.Newline;
offset += this.copyEntriesIntoBuffer(subsection, buffer, offset);
}
return offset - initialOffset;
};
PDFCrossRefSection.prototype.copyEntriesIntoBuffer = function (entries, buffer, offset) {
var length = entries.length;
for (var idx = 0; idx < length; idx++) {
var entry = entries[idx];
var entryOffset = padStart(String(entry.offset), 10, '0');
offset += copyStringIntoBuffer(entryOffset, buffer, offset);
buffer[offset++] = CharCodes.Space;
var entryGen = padStart(String(entry.ref.generationNumber), 5, '0');
offset += copyStringIntoBuffer(entryGen, buffer, offset);
buffer[offset++] = CharCodes.Space;
buffer[offset++] = entry.deleted ? CharCodes.f : CharCodes.n;
buffer[offset++] = CharCodes.Space;
buffer[offset++] = CharCodes.Newline;
}
return 20 * length;
};
PDFCrossRefSection.prototype.append = function (currEntry) {
if (this.chunkLength === 0) {
this.subsections.push([currEntry]);
this.chunkIdx = 0;
this.chunkLength = 1;
return;
}
var chunk = this.subsections[this.chunkIdx];
var prevEntry = chunk[this.chunkLength - 1];
if (currEntry.ref.objectNumber - prevEntry.ref.objectNumber > 1) {
this.subsections.push([currEntry]);
this.chunkIdx += 1;
this.chunkLength = 1;
}
else {
chunk.push(currEntry);
this.chunkLength += 1;
}
};
PDFCrossRefSection.create = function () {
return new PDFCrossRefSection({
ref: PDFRef.of(0, 65535),
offset: 0,
deleted: true,
});
};
PDFCrossRefSection.createEmpty = function () { return new PDFCrossRefSection(); };
return PDFCrossRefSection;
}());
export default PDFCrossRefSection;
//# sourceMappingURL=PDFCrossRefSection.js.map

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More