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AAWA,EACXJ,UAASA,EACTgB,KAAMA,EAAKrF,KACXiD,SAAQA,EACR3E,MAAOggB,EACPuB,UAAWM,EACXO,WAAUA,EACVG,cAAehjB,EACf8iB,cAAaA,EACbX,QA/CY,IAkDlB,C,mBCxpBO,IAAK7d,E,iBAAZ,SAAYA,GACVA,EAAAA,EAAA,eACAA,EAAAA,EAAA,mBACAA,EAAAA,EAAA,gBACD,CAJD,CAAYA,IAAAA,EAAc,I","sources":["../node_modules/pdf-lib/src/api/colors.ts","../node_modules/pdf-lib/src/api/errors.ts","../node_modules/pdf-lib/src/api/form/PDFButton.ts","../node_modules/pdf-lib/src/api/form/PDFCheckBox.ts","../node_modules/pdf-lib/src/api/form/PDFDropdown.ts","../node_modules/pdf-lib/src/api/form/PDFField.ts","../node_modules/pdf-lib/src/api/form/PDFForm.ts","../node_modules/pdf-lib/src/api/form/PDFOptionList.ts","../node_modules/pdf-lib/src/api/form/PDFRadioGroup.ts","../node_modules/pdf-lib/src/api/form/PDFSignature.ts","../node_modules/pdf-lib/src/api/form/PDFTextField.ts","../node_modules/pdf-lib/src/api/form/appearances.ts","../node_modules/pdf-lib/src/api/image/alignment.ts"],"sourcesContent":["import {\n setFillingCmykColor,\n setFillingGrayscaleColor,\n setFillingRgbColor,\n setStrokingCmykColor,\n setStrokingGrayscaleColor,\n setStrokingRgbColor,\n} from 'src/api/operators';\nimport { assertRange, error } from 'src/utils';\n\nexport enum ColorTypes {\n Grayscale = 'Grayscale',\n RGB = 'RGB',\n CMYK = 'CMYK',\n}\n\nexport interface Grayscale {\n type: ColorTypes.Grayscale;\n gray: number;\n}\n\nexport interface RGB {\n type: ColorTypes.RGB;\n red: number;\n green: number;\n blue: number;\n}\n\nexport interface CMYK {\n type: ColorTypes.CMYK;\n cyan: number;\n magenta: number;\n yellow: number;\n key: number;\n}\n\nexport type Color = Grayscale | RGB | CMYK;\n\nexport const grayscale = (gray: number): Grayscale => {\n assertRange(gray, 'gray', 0.0, 1.0);\n return { type: ColorTypes.Grayscale, gray };\n};\n\nexport const rgb = (red: number, green: number, blue: number): RGB => {\n assertRange(red, 'red', 0, 1);\n assertRange(green, 'green', 0, 1);\n assertRange(blue, 'blue', 0, 1);\n return { type: ColorTypes.RGB, red, green, blue };\n};\n\nexport const cmyk = (\n cyan: number,\n magenta: number,\n yellow: number,\n key: number,\n): CMYK => {\n assertRange(cyan, 'cyan', 0, 1);\n assertRange(magenta, 'magenta', 0, 1);\n assertRange(yellow, 'yellow', 0, 1);\n assertRange(key, 'key', 0, 1);\n return { type: ColorTypes.CMYK, cyan, magenta, yellow, key };\n};\n\nconst { Grayscale, RGB, CMYK } = ColorTypes;\n\n// prettier-ignore\nexport const setFillingColor = (color: Color) => \n color.type === Grayscale ? setFillingGrayscaleColor(color.gray)\n : color.type === RGB ? setFillingRgbColor(color.red, color.green, color.blue)\n : color.type === CMYK ? setFillingCmykColor(color.cyan, color.magenta, color.yellow, color.key)\n : error(`Invalid color: ${JSON.stringify(color)}`);\n\n// prettier-ignore\nexport const setStrokingColor = (color: Color) => \n color.type === Grayscale ? setStrokingGrayscaleColor(color.gray)\n : color.type === RGB ? setStrokingRgbColor(color.red, color.green, color.blue)\n : color.type === CMYK ? setStrokingCmykColor(color.cyan, color.magenta, color.yellow, color.key)\n : error(`Invalid color: ${JSON.stringify(color)}`);\n\n// prettier-ignore\nexport const componentsToColor = (comps?: number[], scale = 1) => (\n comps?.length === 1 ? grayscale(\n comps[0] * scale,\n )\n : comps?.length === 3 ? rgb(\n comps[0] * scale, \n comps[1] * scale, \n comps[2] * scale,\n )\n : comps?.length === 4 ? cmyk(\n comps[0] * scale, \n comps[1] * scale, \n comps[2] * scale, \n comps[3] * scale,\n )\n : undefined\n);\n\n// prettier-ignore\nexport const colorToComponents = (color: Color) =>\n color.type === Grayscale ? [color.gray]\n : color.type === RGB ? [color.red, color.green, color.blue]\n : color.type === CMYK ? [color.cyan, color.magenta, color.yellow, color.key]\n : error(`Invalid color: ${JSON.stringify(color)}`);\n","// tslint:disable: max-classes-per-file\n\n// TODO: Include link to documentation with example\nexport class EncryptedPDFError extends Error {\n constructor() {\n const msg =\n 'Input document to `PDFDocument.load` is encrypted. You can use `PDFDocument.load(..., { ignoreEncryption: true })` if you wish to load the document anyways.';\n super(msg);\n }\n}\n\n// TODO: Include link to documentation with example\nexport class FontkitNotRegisteredError extends Error {\n constructor() {\n const msg =\n 'Input to `PDFDocument.embedFont` was a custom font, but no `fontkit` instance was found. You must register a `fontkit` instance with `PDFDocument.registerFontkit(...)` before embedding custom fonts.';\n super(msg);\n }\n}\n\n// TODO: Include link to documentation with example\nexport class ForeignPageError extends Error {\n constructor() {\n const msg =\n 'A `page` passed to `PDFDocument.addPage` or `PDFDocument.insertPage` was from a different (foreign) PDF document. If you want to copy pages from one PDFDocument to another, you must use `PDFDocument.copyPages(...)` to copy the pages before adding or inserting them.';\n super(msg);\n }\n}\n\n// TODO: Include link to documentation with example\nexport class RemovePageFromEmptyDocumentError extends Error {\n constructor() {\n const msg =\n 'PDFDocument has no pages so `PDFDocument.removePage` cannot be called';\n super(msg);\n }\n}\n\nexport class NoSuchFieldError extends Error {\n constructor(name: string) {\n const msg = `PDFDocument has no form field with the name \"${name}\"`;\n super(msg);\n }\n}\n\nexport class UnexpectedFieldTypeError extends Error {\n constructor(name: string, expected: any, actual: any) {\n const expectedType = expected?.name;\n const actualType = actual?.constructor?.name ?? actual;\n const msg =\n `Expected field \"${name}\" to be of type ${expectedType}, ` +\n `but it is actually of type ${actualType}`;\n super(msg);\n }\n}\n\nexport class MissingOnValueCheckError extends Error {\n constructor(onValue: any) {\n const msg = `Failed to select check box due to missing onValue: \"${onValue}\"`;\n super(msg);\n }\n}\n\nexport class FieldAlreadyExistsError extends Error {\n constructor(name: string) {\n const msg = `A field already exists with the specified name: \"${name}\"`;\n super(msg);\n }\n}\n\nexport class InvalidFieldNamePartError extends Error {\n constructor(namePart: string) {\n const msg = `Field name contains invalid component: \"${namePart}\"`;\n super(msg);\n }\n}\n\nexport class FieldExistsAsNonTerminalError extends Error {\n constructor(name: string) {\n const msg = `A non-terminal field already exists with the specified name: \"${name}\"`;\n super(msg);\n }\n}\n\nexport class RichTextFieldReadError extends Error {\n constructor(fieldName: string) {\n const msg = `Reading rich text fields is not supported: Attempted to read rich text field: ${fieldName}`;\n super(msg);\n }\n}\n\nexport class CombedTextLayoutError extends Error {\n constructor(lineLength: number, cellCount: number) {\n const msg = `Failed to layout combed text as lineLength=${lineLength} is greater than cellCount=${cellCount}`;\n super(msg);\n }\n}\n\nexport class ExceededMaxLengthError extends Error {\n constructor(textLength: number, maxLength: number, name: string) {\n const msg = `Attempted to set text with length=${textLength} for TextField with maxLength=${maxLength} and name=${name}`;\n super(msg);\n }\n}\n\nexport class InvalidMaxLengthError extends Error {\n constructor(textLength: number, maxLength: number, name: string) {\n const msg = `Attempted to set maxLength=${maxLength}, which is less than ${textLength}, the length of this field's current value (name=${name})`;\n super(msg);\n }\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFPage from 'src/api/PDFPage';\nimport PDFFont from 'src/api/PDFFont';\nimport PDFImage from 'src/api/PDFImage';\nimport { ImageAlignment } from 'src/api/image/alignment';\nimport {\n AppearanceProviderFor,\n normalizeAppearance,\n defaultButtonAppearanceProvider,\n} from 'src/api/form/appearances';\nimport PDFField, {\n FieldAppearanceOptions,\n assertFieldAppearanceOptions,\n} from 'src/api/form/PDFField';\nimport { rgb } from 'src/api/colors';\nimport { degrees } from 'src/api/rotations';\n\nimport {\n PDFRef,\n PDFStream,\n PDFAcroPushButton,\n PDFWidgetAnnotation,\n} from 'src/core';\nimport { assertIs, assertOrUndefined, assertPositive } from 'src/utils';\n\n/**\n * Represents a button field of a [[PDFForm]].\n *\n * [[PDFButton]] fields are interactive controls that users can click with their\n * mouse. This type of [[PDFField]] is not stateful. The purpose of a button\n * is to perform an action when the user clicks on it, such as opening a print\n * modal or resetting the form. Buttons are typically rectangular in shape and\n * have a text label describing the action that they perform when clicked.\n */\nexport default class PDFButton extends PDFField {\n /**\n * > **NOTE:** You probably don't want to call this method directly. Instead,\n * > consider using the [[PDFForm.getButton]] method, which will create an\n * > instance of [[PDFButton]] for you.\n *\n * Create an instance of [[PDFButton]] from an existing acroPushButton and ref\n *\n * @param acroPushButton The underlying `PDFAcroPushButton` for this button.\n * @param ref The unique reference for this button.\n * @param doc The document to which this button will belong.\n */\n static of = (\n acroPushButton: PDFAcroPushButton,\n ref: PDFRef,\n doc: PDFDocument,\n ) => new PDFButton(acroPushButton, ref, doc);\n\n /** The low-level PDFAcroPushButton wrapped by this button. */\n readonly acroField: PDFAcroPushButton;\n\n private constructor(\n acroPushButton: PDFAcroPushButton,\n ref: PDFRef,\n doc: PDFDocument,\n ) {\n super(acroPushButton, ref, doc);\n\n assertIs(acroPushButton, 'acroButton', [\n [PDFAcroPushButton, 'PDFAcroPushButton'],\n ]);\n\n this.acroField = acroPushButton;\n }\n\n /**\n * Display an image inside the bounds of this button's widgets. For example:\n * ```js\n * const pngImage = await pdfDoc.embedPng(...)\n * const button = form.getButton('some.button.field')\n * button.setImage(pngImage, ImageAlignment.Center)\n * ```\n * This will update the appearances streams for each of this button's widgets.\n * @param image The image that should be displayed.\n * @param alignment The alignment of the image.\n */\n setImage(image: PDFImage, alignment = ImageAlignment.Center) {\n const widgets = this.acroField.getWidgets();\n for (let idx = 0, len = widgets.length; idx < len; idx++) {\n const widget = widgets[idx];\n const streamRef = this.createImageAppearanceStream(\n widget,\n image,\n alignment,\n );\n this.updateWidgetAppearances(widget, { normal: streamRef });\n }\n\n this.markAsClean();\n }\n\n /**\n * Set the font size for this field. Larger font sizes will result in larger\n * text being displayed when PDF readers render this button. Font sizes may\n * be integer or floating point numbers. Supplying a negative font size will\n * cause this method to throw an error.\n *\n * For example:\n * ```js\n * const button = form.getButton('some.button.field')\n * button.setFontSize(4)\n * button.setFontSize(15.7)\n * ```\n *\n * > This method depends upon the existence of a default appearance\n * > (`/DA`) string. If this field does not have a default appearance string,\n * > or that string does not contain a font size (via the `Tf` operator),\n * > then this method will throw an error.\n *\n * @param fontSize The font size to be used when rendering text in this field.\n */\n setFontSize(fontSize: number) {\n assertPositive(fontSize, 'fontSize');\n this.acroField.setFontSize(fontSize);\n this.markAsDirty();\n }\n\n /**\n * Show this button on the specified page with the given text. For example:\n * ```js\n * const ubuntuFont = await pdfDoc.embedFont(ubuntuFontBytes)\n * const page = pdfDoc.addPage()\n *\n * const form = pdfDoc.getForm()\n * const button = form.createButton('some.button.field')\n *\n * button.addToPage('Do Stuff', page, {\n * x: 50,\n * y: 75,\n * width: 200,\n * height: 100,\n * textColor: rgb(1, 0, 0),\n * backgroundColor: rgb(0, 1, 0),\n * borderColor: rgb(0, 0, 1),\n * borderWidth: 2,\n * rotate: degrees(90),\n * font: ubuntuFont,\n * })\n * ```\n * This will create a new widget for this button field.\n * @param text The text to be displayed for this button widget.\n * @param page The page to which this button widget should be added.\n * @param options The options to be used when adding this button widget.\n */\n addToPage(\n // TODO: This needs to be optional, e.g. for image buttons\n text: string,\n page: PDFPage,\n options?: FieldAppearanceOptions,\n ) {\n assertOrUndefined(text, 'text', ['string']);\n assertOrUndefined(page, 'page', [[PDFPage, 'PDFPage']]);\n assertFieldAppearanceOptions(options);\n\n // Create a widget for this button\n const widget = this.createWidget({\n x: (options?.x ?? 0) - (options?.borderWidth ?? 0) / 2,\n y: (options?.y ?? 0) - (options?.borderWidth ?? 0) / 2,\n width: options?.width ?? 100,\n height: options?.height ?? 50,\n textColor: options?.textColor ?? rgb(0, 0, 0),\n backgroundColor: options?.backgroundColor ?? rgb(0.75, 0.75, 0.75),\n borderColor: options?.borderColor,\n borderWidth: options?.borderWidth ?? 0,\n rotate: options?.rotate ?? degrees(0),\n caption: text,\n hidden: options?.hidden,\n page: page.ref,\n });\n const widgetRef = this.doc.context.register(widget.dict);\n\n // Add widget to this field\n this.acroField.addWidget(widgetRef);\n\n // Set appearance streams for widget\n const font = options?.font ?? this.doc.getForm().getDefaultFont();\n this.updateWidgetAppearance(widget, font);\n\n // Add widget to the given page\n page.node.addAnnot(widgetRef);\n }\n\n /**\n * Returns `true` if this button has been marked as dirty, or if any of this\n * button's widgets do not have an appearance stream. For example:\n * ```js\n * const button = form.getButton('some.button.field')\n * if (button.needsAppearancesUpdate()) console.log('Needs update')\n * ```\n * @returns Whether or not this button needs an appearance update.\n */\n needsAppearancesUpdate(): boolean {\n if (this.isDirty()) return true;\n\n const widgets = this.acroField.getWidgets();\n for (let idx = 0, len = widgets.length; idx < len; idx++) {\n const widget = widgets[idx];\n const hasAppearances =\n widget.getAppearances()?.normal instanceof PDFStream;\n if (!hasAppearances) return true;\n }\n\n return false;\n }\n\n /**\n * Update the appearance streams for each of this button's widgets using\n * the default appearance provider for buttons. For example:\n * ```js\n * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const button = form.getButton('some.button.field')\n * button.defaultUpdateAppearances(helvetica)\n * ```\n * @param font The font to be used for creating the appearance streams.\n */\n defaultUpdateAppearances(font: PDFFont) {\n assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n this.updateAppearances(font);\n }\n\n /**\n * Update the appearance streams for each of this button's widgets using\n * the given appearance provider. If no `provider` is passed, the default\n * appearance provider for buttons will be used. For example:\n * ```js\n * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const button = form.getButton('some.button.field')\n * button.updateAppearances(helvetica, (field, widget, font) => {\n * ...\n * return {\n * normal: drawButton(...),\n * down: drawButton(...),\n * }\n * })\n * ```\n * @param font The font to be used for creating the appearance streams.\n * @param provider Optionally, the appearance provider to be used for\n * generating the contents of the appearance streams.\n */\n updateAppearances(\n font: PDFFont,\n provider?: AppearanceProviderFor,\n ) {\n assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n assertOrUndefined(provider, 'provider', [Function]);\n\n const widgets = this.acroField.getWidgets();\n for (let idx = 0, len = widgets.length; idx < len; idx++) {\n const widget = widgets[idx];\n this.updateWidgetAppearance(widget, font, provider);\n }\n }\n\n private updateWidgetAppearance(\n widget: PDFWidgetAnnotation,\n font: PDFFont,\n provider?: AppearanceProviderFor,\n ) {\n const apProvider = provider ?? defaultButtonAppearanceProvider;\n const appearances = normalizeAppearance(apProvider(this, widget, font));\n this.updateWidgetAppearanceWithFont(widget, font, appearances);\n }\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFPage from 'src/api/PDFPage';\nimport {\n AppearanceProviderFor,\n normalizeAppearance,\n defaultCheckBoxAppearanceProvider,\n} from 'src/api/form/appearances';\nimport { rgb } from 'src/api/colors';\nimport { degrees } from 'src/api/rotations';\nimport PDFField, {\n FieldAppearanceOptions,\n assertFieldAppearanceOptions,\n} from 'src/api/form/PDFField';\n\nimport {\n PDFName,\n PDFRef,\n PDFDict,\n PDFAcroCheckBox,\n PDFWidgetAnnotation,\n} from 'src/core';\nimport { assertIs, assertOrUndefined } from 'src/utils';\n\n/**\n * Represents a check box field of a [[PDFForm]].\n *\n * [[PDFCheckBox]] fields are interactive boxes that users can click with their\n * mouse. This type of [[PDFField]] has two states: `on` and `off`. The purpose\n * of a check box is to enable users to select from one or more options, where\n * each option is represented by a single check box. Check boxes are typically\n * square in shape and display a check mark when they are in the `on` state.\n */\nexport default class PDFCheckBox extends PDFField {\n /**\n * > **NOTE:** You probably don't want to call this method directly. Instead,\n * > consider using the [[PDFForm.getCheckBox]] method, which will create an\n * > instance of [[PDFCheckBox]] for you.\n *\n * Create an instance of [[PDFCheckBox]] from an existing acroCheckBox and ref\n *\n * @param acroCheckBox The underlying `PDFAcroCheckBox` for this check box.\n * @param ref The unique reference for this check box.\n * @param doc The document to which this check box will belong.\n */\n static of = (acroCheckBox: PDFAcroCheckBox, ref: PDFRef, doc: PDFDocument) =>\n new PDFCheckBox(acroCheckBox, ref, doc);\n\n /** The low-level PDFAcroCheckBox wrapped by this check box. */\n readonly acroField: PDFAcroCheckBox;\n\n private constructor(\n acroCheckBox: PDFAcroCheckBox,\n ref: PDFRef,\n doc: PDFDocument,\n ) {\n super(acroCheckBox, ref, doc);\n\n assertIs(acroCheckBox, 'acroCheckBox', [\n [PDFAcroCheckBox, 'PDFAcroCheckBox'],\n ]);\n\n this.acroField = acroCheckBox;\n }\n\n /**\n * Mark this check box. This operation is analogous to a human user clicking\n * a check box to fill it in a PDF reader. This method will update the\n * underlying state of the check box field to indicate it has been selected.\n * PDF libraries and readers will be able to extract this value from the\n * saved document and determine that it was selected.\n *\n * For example:\n * ```js\n * const checkBox = form.getCheckBox('some.checkBox.field')\n * checkBox.check()\n * ```\n *\n * This method will mark this check box as dirty, causing its appearance\n * streams to be updated when either [[PDFDocument.save]] or\n * [[PDFForm.updateFieldAppearances]] is called. The updated appearance\n * streams will display a check mark inside the widgets of this check box\n * field.\n */\n check() {\n const onValue = this.acroField.getOnValue() ?? PDFName.of('Yes');\n this.markAsDirty();\n this.acroField.setValue(onValue);\n }\n\n /**\n * Clears this check box. This operation is analogous to a human user clicking\n * a check box to unmark it in a PDF reader. This method will update the\n * underlying state of the check box field to indicate it has been deselected.\n * PDF libraries and readers will be able to extract this value from the\n * saved document and determine that it was not selected.\n *\n * For example:\n * ```js\n * const checkBox = form.getCheckBox('some.checkBox.field')\n * checkBox.uncheck()\n * ```\n *\n * This method will mark this check box as dirty. See [[PDFCheckBox.check]]\n * for more details about what this means.\n */\n uncheck() {\n this.markAsDirty();\n this.acroField.setValue(PDFName.of('Off'));\n }\n\n /**\n * Returns `true` if this check box is selected (either by a human user via\n * a PDF reader, or else programmatically via software). For example:\n * ```js\n * const checkBox = form.getCheckBox('some.checkBox.field')\n * if (checkBox.isChecked()) console.log('check box is selected')\n * ```\n * @returns Whether or not this check box is selected.\n */\n isChecked(): boolean {\n const onValue = this.acroField.getOnValue();\n return !!onValue && onValue === this.acroField.getValue();\n }\n\n /**\n * Show this check box on the specified page. For example:\n * ```js\n * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const page = pdfDoc.addPage()\n *\n * const form = pdfDoc.getForm()\n * const checkBox = form.createCheckBox('some.checkBox.field')\n *\n * checkBox.addToPage(page, {\n * x: 50,\n * y: 75,\n * width: 25,\n * height: 25,\n * textColor: rgb(1, 0, 0),\n * backgroundColor: rgb(0, 1, 0),\n * borderColor: rgb(0, 0, 1),\n * borderWidth: 2,\n * rotate: degrees(90),\n * })\n * ```\n * This will create a new widget for this check box field.\n * @param page The page to which this check box widget should be added.\n * @param options The options to be used when adding this check box widget.\n */\n addToPage(page: PDFPage, options?: FieldAppearanceOptions) {\n assertIs(page, 'page', [[PDFPage, 'PDFPage']]);\n assertFieldAppearanceOptions(options);\n\n if (!options) options = {};\n\n if (!('textColor' in options)) options.textColor = rgb(0, 0, 0);\n if (!('backgroundColor' in options)) options.backgroundColor = rgb(1, 1, 1);\n if (!('borderColor' in options)) options.borderColor = rgb(0, 0, 0);\n if (!('borderWidth' in options)) options.borderWidth = 1;\n\n // Create a widget for this check box\n const widget = this.createWidget({\n x: options.x ?? 0,\n y: options.y ?? 0,\n width: options.width ?? 50,\n height: options.height ?? 50,\n textColor: options.textColor,\n backgroundColor: options.backgroundColor,\n borderColor: options.borderColor,\n borderWidth: options.borderWidth ?? 0,\n rotate: options.rotate ?? degrees(0),\n hidden: options.hidden,\n page: page.ref,\n });\n const widgetRef = this.doc.context.register(widget.dict);\n\n // Add widget to this field\n this.acroField.addWidget(widgetRef);\n\n // Set appearance streams for widget\n widget.setAppearanceState(PDFName.of('Off'));\n this.updateWidgetAppearance(widget, PDFName.of('Yes'));\n\n // Add widget to the given page\n page.node.addAnnot(widgetRef);\n }\n\n /**\n * Returns `true` if any of this check box's widgets do not have an\n * appearance stream for its current state. For example:\n * ```js\n * const checkBox = form.getCheckBox('some.checkBox.field')\n * if (checkBox.needsAppearancesUpdate()) console.log('Needs update')\n * ```\n * @returns Whether or not this check box needs an appearance update.\n */\n needsAppearancesUpdate(): boolean {\n const widgets = this.acroField.getWidgets();\n for (let idx = 0, len = widgets.length; idx < len; idx++) {\n const widget = widgets[idx];\n const state = widget.getAppearanceState();\n const normal = widget.getAppearances()?.normal;\n\n if (!(normal instanceof PDFDict)) return true;\n if (state && !normal.has(state)) return true;\n }\n\n return false;\n }\n\n /**\n * Update the appearance streams for each of this check box's widgets using\n * the default appearance provider for check boxes. For example:\n * ```js\n * const checkBox = form.getCheckBox('some.checkBox.field')\n * checkBox.defaultUpdateAppearances()\n * ```\n */\n defaultUpdateAppearances() {\n this.updateAppearances();\n }\n\n /**\n * Update the appearance streams for each of this check box's widgets using\n * the given appearance provider. If no `provider` is passed, the default\n * appearance provider for check boxs will be used. For example:\n * ```js\n * const checkBox = form.getCheckBox('some.checkBox.field')\n * checkBox.updateAppearances((field, widget) => {\n * ...\n * return {\n * normal: { on: drawCheckBox(...), off: drawCheckBox(...) },\n * down: { on: drawCheckBox(...), off: drawCheckBox(...) },\n * }\n * })\n * ```\n * @param provider Optionally, the appearance provider to be used for\n * generating the contents of the appearance streams.\n */\n updateAppearances(provider?: AppearanceProviderFor) {\n assertOrUndefined(provider, 'provider', [Function]);\n\n const widgets = this.acroField.getWidgets();\n for (let idx = 0, len = widgets.length; idx < len; idx++) {\n const widget = widgets[idx];\n const onValue = widget.getOnValue() ?? PDFName.of('Yes');\n if (!onValue) continue;\n this.updateWidgetAppearance(widget, onValue, provider);\n }\n this.markAsClean();\n }\n\n private updateWidgetAppearance(\n widget: PDFWidgetAnnotation,\n onValue: PDFName,\n provider?: AppearanceProviderFor,\n ) {\n const apProvider = provider ?? defaultCheckBoxAppearanceProvider;\n const appearances = normalizeAppearance(apProvider(this, widget));\n this.updateOnOffWidgetAppearance(widget, onValue, appearances);\n }\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFPage from 'src/api/PDFPage';\nimport PDFFont from 'src/api/PDFFont';\nimport PDFField, {\n FieldAppearanceOptions,\n assertFieldAppearanceOptions,\n} from 'src/api/form/PDFField';\nimport {\n AppearanceProviderFor,\n normalizeAppearance,\n defaultDropdownAppearanceProvider,\n} from 'src/api/form/appearances';\nimport { rgb } from 'src/api/colors';\nimport { degrees } from 'src/api/rotations';\n\nimport {\n PDFHexString,\n PDFRef,\n PDFString,\n PDFStream,\n PDFWidgetAnnotation,\n PDFAcroComboBox,\n AcroChoiceFlags,\n} from 'src/core';\nimport { assertIs, assertOrUndefined, assertPositive } from 'src/utils';\n\n/**\n * Represents a dropdown field of a [[PDFForm]].\n *\n * [[PDFDropdown]] fields are interactive text boxes that display a single\n * element (the currently selected value). The purpose of a dropdown is to\n * enable users to select a single option from a set of possible options. Users\n * can click on a dropdown to view the full list of options it provides.\n * Clicking on an option in the list will cause it to be selected and displayed\n * in the dropdown's text box. Some dropdowns allow users to enter text\n * directly into the box from their keyboard, rather than only being allowed to\n * choose an option from the list (see [[PDFDropdown.isEditable]]).\n */\nexport default class PDFDropdown extends PDFField {\n /**\n * > **NOTE:** You probably don't want to call this method directly. Instead,\n * > consider using the [[PDFForm.getDropdown]] method, which will create an\n * > instance of [[PDFDropdown]] for you.\n *\n * Create an instance of [[PDFDropdown]] from an existing acroComboBox and ref\n *\n * @param acroComboBox The underlying `PDFAcroComboBox` for this dropdown.\n * @param ref The unique reference for this dropdown.\n * @param doc The document to which this dropdown will belong.\n */\n static of = (acroComboBox: PDFAcroComboBox, ref: PDFRef, doc: PDFDocument) =>\n new PDFDropdown(acroComboBox, ref, doc);\n\n /** The low-level PDFAcroComboBox wrapped by this dropdown. */\n readonly acroField: PDFAcroComboBox;\n\n private constructor(\n acroComboBox: PDFAcroComboBox,\n ref: PDFRef,\n doc: PDFDocument,\n ) {\n super(acroComboBox, ref, doc);\n\n assertIs(acroComboBox, 'acroComboBox', [\n [PDFAcroComboBox, 'PDFAcroComboBox'],\n ]);\n\n this.acroField = acroComboBox;\n }\n\n /**\n * Get the list of available options for this dropdown. These options will be\n * displayed to users who click on this dropdown in a PDF reader.\n * For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * const options = dropdown.getOptions()\n * console.log('Dropdown options:', options)\n * ```\n * @returns The options for this dropdown.\n */\n getOptions(): string[] {\n const rawOptions = this.acroField.getOptions();\n\n const options = new Array(rawOptions.length);\n for (let idx = 0, len = options.length; idx < len; idx++) {\n const { display, value } = rawOptions[idx];\n options[idx] = (display ?? value).decodeText();\n }\n\n return options;\n }\n\n /**\n * Get the selected options for this dropdown. These are the values that were\n * selected by a human user via a PDF reader, or programatically via\n * software.\n * For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * const selections = dropdown.getSelected()\n * console.log('Dropdown selections:', selections)\n * ```\n * > **NOTE:** Note that PDF readers only display one selected option when\n * > rendering dropdowns. However, the PDF specification does allow for\n * > multiple values to be selected in a dropdown. As such, the `pdf-lib`\n * > API supports this. However, in most cases the array returned by this\n * > method will contain only a single element (or no elements).\n * @returns The selected options in this dropdown.\n */\n getSelected(): string[] {\n const values = this.acroField.getValues();\n\n const selected = new Array(values.length);\n for (let idx = 0, len = values.length; idx < len; idx++) {\n selected[idx] = values[idx].decodeText();\n }\n\n return selected;\n }\n\n /**\n * Set the list of options that are available for this dropdown. These are\n * the values that will be available for users to select when they view this\n * dropdown in a PDF reader. Note that preexisting options for this dropdown\n * will be removed. Only the values passed as `options` will be available to\n * select.\n * For example:\n * ```js\n * const dropdown = form.getDropdown('planets.dropdown')\n * dropdown.setOptions(['Earth', 'Mars', 'Pluto', 'Venus'])\n * ```\n * @param options The options that should be available in this dropdown.\n */\n setOptions(options: string[]) {\n assertIs(options, 'options', [Array]);\n\n const optionObjects = new Array<{ value: PDFHexString }>(options.length);\n for (let idx = 0, len = options.length; idx < len; idx++) {\n optionObjects[idx] = { value: PDFHexString.fromText(options[idx]) };\n }\n this.acroField.setOptions(optionObjects);\n }\n\n /**\n * Add to the list of options that are available for this dropdown. Users\n * will be able to select these values in a PDF reader. In addition to the\n * values passed as `options`, any preexisting options for this dropdown will\n * still be available for users to select.\n * For example:\n * ```js\n * const dropdown = form.getDropdown('rockets.dropdown')\n * dropdown.addOptions(['Saturn IV', 'Falcon Heavy'])\n * ```\n * @param options New options that should be available in this dropdown.\n */\n addOptions(options: string | string[]) {\n assertIs(options, 'options', ['string', Array]);\n\n const optionsArr = Array.isArray(options) ? options : [options];\n\n const existingOptions: {\n value: PDFString | PDFHexString;\n display?: PDFString | PDFHexString;\n }[] = this.acroField.getOptions();\n\n const newOptions = new Array<{ value: PDFHexString }>(optionsArr.length);\n for (let idx = 0, len = optionsArr.length; idx < len; idx++) {\n newOptions[idx] = { value: PDFHexString.fromText(optionsArr[idx]) };\n }\n\n this.acroField.setOptions(existingOptions.concat(newOptions));\n }\n\n /**\n * Select one or more values for this dropdown. This operation is analogous\n * to a human user opening the dropdown in a PDF reader and clicking on a\n * value to select it. This method will update the underlying state of the\n * dropdown to indicate which values have been selected. PDF libraries and\n * readers will be able to extract these values from the saved document and\n * determine which values were selected.\n *\n * For example:\n * ```js\n * const dropdown = form.getDropdown('best.superhero.dropdown')\n * dropdown.select('One Punch Man')\n * ```\n *\n * This method will mark this dropdown as dirty, causing its appearance\n * streams to be updated when either [[PDFDocument.save]] or\n * [[PDFForm.updateFieldAppearances]] is called. The updated streams will\n * display the selected option inside the widgets of this dropdown.\n *\n * **IMPORTANT:** The default font used to update appearance streams is\n * [[StandardFonts.Helvetica]]. Note that this is a WinAnsi font. This means\n * that encoding errors will be thrown if the selected option for this field\n * contains characters outside the WinAnsi character set (the latin alphabet).\n *\n * Embedding a custom font and passing it to\n * [[PDFForm.updateFieldAppearances]] or [[PDFDropdown.updateAppearances]]\n * allows you to generate appearance streams with characters outside the\n * latin alphabet (assuming the custom font supports them).\n *\n * Selecting an option that does not exist in this dropdown's option list\n * (see [[PDFDropdown.getOptions]]) will enable editing on this dropdown\n * (see [[PDFDropdown.enableEditing]]).\n *\n * > **NOTE:** PDF readers only display one selected option when rendering\n * > dropdowns. However, the PDF specification does allow for multiple values\n * > to be selected in a dropdown. As such, the `pdf-lib` API supports this.\n * > However, it is not recommended to select more than one value with this\n * > method, as only one will be visible. [[PDFOptionList]] fields are better\n * > suited for displaying multiple selected values.\n *\n * @param options The options to be selected.\n * @param merge Whether or not existing selections should be preserved.\n */\n select(options: string | string[], merge = false) {\n assertIs(options, 'options', ['string', Array]);\n assertIs(merge, 'merge', ['boolean']);\n\n const optionsArr = Array.isArray(options) ? options : [options];\n\n const validOptions = this.getOptions();\n const hasCustomOption = optionsArr.find(\n (option) => !validOptions.includes(option),\n );\n if (hasCustomOption) this.enableEditing();\n\n this.markAsDirty();\n\n if (optionsArr.length > 1 || (optionsArr.length === 1 && merge)) {\n this.enableMultiselect();\n }\n\n const values = new Array(optionsArr.length);\n for (let idx = 0, len = optionsArr.length; idx < len; idx++) {\n values[idx] = PDFHexString.fromText(optionsArr[idx]);\n }\n\n if (merge) {\n const existingValues = this.acroField.getValues();\n this.acroField.setValues(existingValues.concat(values));\n } else {\n this.acroField.setValues(values);\n }\n }\n\n /**\n * Clear all selected values for this dropdown. This operation is equivalent\n * to selecting an empty list. This method will update the underlying state\n * of the dropdown to indicate that no values have been selected.\n * For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * dropdown.clear()\n * ```\n * This method will mark this text field as dirty. See [[PDFDropdown.select]]\n * for more details about what this means.\n */\n clear() {\n this.markAsDirty();\n this.acroField.setValues([]);\n }\n\n /**\n * Set the font size for this field. Larger font sizes will result in larger\n * text being displayed when PDF readers render this dropdown. Font sizes may\n * be integer or floating point numbers. Supplying a negative font size will\n * cause this method to throw an error.\n *\n * For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * dropdown.setFontSize(4)\n * dropdown.setFontSize(15.7)\n * ```\n *\n * > This method depends upon the existence of a default appearance\n * > (`/DA`) string. If this field does not have a default appearance string,\n * > or that string does not contain a font size (via the `Tf` operator),\n * > then this method will throw an error.\n *\n * @param fontSize The font size to be used when rendering text in this field.\n */\n setFontSize(fontSize: number) {\n assertPositive(fontSize, 'fontSize');\n this.acroField.setFontSize(fontSize);\n this.markAsDirty();\n }\n\n /**\n * Returns `true` if users are allowed to edit the selected value of this\n * dropdown directly and are not constrained by the list of available\n * options. See [[PDFDropdown.enableEditing]] and\n * [[PDFDropdown.disableEditing]]. For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * if (dropdown.isEditable()) console.log('Editing is enabled')\n * ```\n * @returns Whether or not this dropdown is editable.\n */\n isEditable(): boolean {\n return this.acroField.hasFlag(AcroChoiceFlags.Edit);\n }\n\n /**\n * Allow users to edit the selected value of this dropdown in PDF readers\n * with their keyboard. This means that the selected value of this dropdown\n * will not be constrained by the list of available options. However, if this\n * dropdown has any available options, users will still be allowed to select\n * from that list.\n * For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * dropdown.enableEditing()\n * ```\n */\n enableEditing() {\n this.acroField.setFlagTo(AcroChoiceFlags.Edit, true);\n }\n\n /**\n * Do not allow users to edit the selected value of this dropdown in PDF\n * readers with their keyboard. This will constrain the selected value of\n * this dropdown to the list of available options. Users will only be able\n * to select an option from that list.\n * For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * dropdown.disableEditing()\n * ```\n */\n disableEditing() {\n this.acroField.setFlagTo(AcroChoiceFlags.Edit, false);\n }\n\n /**\n * Returns `true` if the option list of this dropdown is always displayed\n * in alphabetical order, irrespective of the order in which the options\n * were added to the dropdown. See [[PDFDropdown.enableSorting]] and\n * [[PDFDropdown.disableSorting]]. For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * if (dropdown.isSorted()) console.log('Sorting is enabled')\n * ```\n * @returns Whether or not this dropdown's options are sorted.\n */\n isSorted(): boolean {\n return this.acroField.hasFlag(AcroChoiceFlags.Sort);\n }\n\n /**\n * Always display the option list of this dropdown in alphabetical order,\n * irrespective of the order in which the options were added to this dropdown.\n * For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * dropdown.enableSorting()\n * ```\n */\n enableSorting() {\n this.acroField.setFlagTo(AcroChoiceFlags.Sort, true);\n }\n\n /**\n * Do not always display the option list of this dropdown in alphabetical\n * order. Instead, display the options in whichever order they were added\n * to the list. For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * dropdown.disableSorting()\n * ```\n */\n disableSorting() {\n this.acroField.setFlagTo(AcroChoiceFlags.Sort, false);\n }\n\n /**\n * Returns `true` if multiple options can be selected from this dropdown's\n * option list. See [[PDFDropdown.enableMultiselect]] and\n * [[PDFDropdown.disableMultiselect]]. For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * if (dropdown.isMultiselect()) console.log('Multiselect is enabled')\n * ```\n * @returns Whether or not multiple options can be selected.\n */\n isMultiselect(): boolean {\n return this.acroField.hasFlag(AcroChoiceFlags.MultiSelect);\n }\n\n /**\n * Allow users to select more than one option from this dropdown's option\n * list. For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * dropdown.enableMultiselect()\n * ```\n */\n enableMultiselect() {\n this.acroField.setFlagTo(AcroChoiceFlags.MultiSelect, true);\n }\n\n /**\n * Do not allow users to select more than one option from this dropdown's\n * option list. For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * dropdown.disableMultiselect()\n * ```\n */\n disableMultiselect() {\n this.acroField.setFlagTo(AcroChoiceFlags.MultiSelect, false);\n }\n\n /**\n * Returns `true` if the selected option should be spell checked by PDF\n * readers. Spell checking will only be performed if this dropdown allows\n * editing (see [[PDFDropdown.isEditable]]). See\n * [[PDFDropdown.enableSpellChecking]] and\n * [[PDFDropdown.disableSpellChecking]]. For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * if (dropdown.isSpellChecked()) console.log('Spell checking is enabled')\n * ```\n * @returns Whether or not this dropdown can be spell checked.\n */\n isSpellChecked(): boolean {\n return !this.acroField.hasFlag(AcroChoiceFlags.DoNotSpellCheck);\n }\n\n /**\n * Allow PDF readers to spell check the selected option of this dropdown.\n * For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * dropdown.enableSpellChecking()\n * ```\n */\n enableSpellChecking() {\n this.acroField.setFlagTo(AcroChoiceFlags.DoNotSpellCheck, false);\n }\n\n /**\n * Do not allow PDF readers to spell check the selected option of this\n * dropdown. For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * dropdown.disableSpellChecking()\n * ```\n */\n disableSpellChecking() {\n this.acroField.setFlagTo(AcroChoiceFlags.DoNotSpellCheck, true);\n }\n\n /**\n * Returns `true` if the option selected by a user is stored, or \"committed\",\n * when the user clicks the option. The alternative is that the user's\n * selection is stored when the user leaves this dropdown field (by clicking\n * outside of it - on another field, for example). See\n * [[PDFDropdown.enableSelectOnClick]] and\n * [[PDFDropdown.disableSelectOnClick]]. For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * if (dropdown.isSelectOnClick()) console.log('Select on click is enabled')\n * ```\n * @returns Whether or not options are selected immediately after they are\n * clicked.\n */\n isSelectOnClick(): boolean {\n return this.acroField.hasFlag(AcroChoiceFlags.CommitOnSelChange);\n }\n\n /**\n * Store the option selected by a user immediately after the user clicks the\n * option. Do not wait for the user to leave this dropdown field (by clicking\n * outside of it - on another field, for example). For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * dropdown.enableSelectOnClick()\n * ```\n */\n enableSelectOnClick() {\n this.acroField.setFlagTo(AcroChoiceFlags.CommitOnSelChange, true);\n }\n\n /**\n * Wait to store the option selected by a user until they leave this dropdown\n * field (by clicking outside of it - on another field, for example).\n * For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * dropdown.disableSelectOnClick()\n * ```\n */\n disableSelectOnClick() {\n this.acroField.setFlagTo(AcroChoiceFlags.CommitOnSelChange, false);\n }\n\n /**\n * Show this dropdown on the specified page. For example:\n * ```js\n * const ubuntuFont = await pdfDoc.embedFont(ubuntuFontBytes)\n * const page = pdfDoc.addPage()\n *\n * const form = pdfDoc.getForm()\n * const dropdown = form.createDropdown('best.gundam')\n * dropdown.setOptions(['Exia', 'Dynames'])\n * dropdown.select('Exia')\n *\n * dropdown.addToPage(page, {\n * x: 50,\n * y: 75,\n * width: 200,\n * height: 100,\n * textColor: rgb(1, 0, 0),\n * backgroundColor: rgb(0, 1, 0),\n * borderColor: rgb(0, 0, 1),\n * borderWidth: 2,\n * rotate: degrees(90),\n * font: ubuntuFont,\n * })\n * ```\n * This will create a new widget for this dropdown field.\n * @param page The page to which this dropdown widget should be added.\n * @param options The options to be used when adding this dropdown widget.\n */\n addToPage(page: PDFPage, options?: FieldAppearanceOptions) {\n assertIs(page, 'page', [[PDFPage, 'PDFPage']]);\n assertFieldAppearanceOptions(options);\n\n if (!options) options = {};\n\n if (!('textColor' in options)) options.textColor = rgb(0, 0, 0);\n if (!('backgroundColor' in options)) options.backgroundColor = rgb(1, 1, 1);\n if (!('borderColor' in options)) options.borderColor = rgb(0, 0, 0);\n if (!('borderWidth' in options)) options.borderWidth = 1;\n\n // Create a widget for this dropdown\n const widget = this.createWidget({\n x: options.x ?? 0,\n y: options.y ?? 0,\n width: options.width ?? 200,\n height: options.height ?? 50,\n textColor: options.textColor,\n backgroundColor: options.backgroundColor,\n borderColor: options.borderColor,\n borderWidth: options.borderWidth ?? 0,\n rotate: options.rotate ?? degrees(0),\n hidden: options.hidden,\n page: page.ref,\n });\n const widgetRef = this.doc.context.register(widget.dict);\n\n // Add widget to this field\n this.acroField.addWidget(widgetRef);\n\n // Set appearance streams for widget\n const font = options.font ?? this.doc.getForm().getDefaultFont();\n this.updateWidgetAppearance(widget, font);\n\n // Add widget to the given page\n page.node.addAnnot(widgetRef);\n }\n\n /**\n * Returns `true` if this dropdown has been marked as dirty, or if any of\n * this dropdown's widgets do not have an appearance stream. For example:\n * ```js\n * const dropdown = form.getDropdown('some.dropdown.field')\n * if (dropdown.needsAppearancesUpdate()) console.log('Needs update')\n * ```\n * @returns Whether or not this dropdown needs an appearance update.\n */\n needsAppearancesUpdate(): boolean {\n if (this.isDirty()) return true;\n\n const widgets = this.acroField.getWidgets();\n for (let idx = 0, len = widgets.length; idx < len; idx++) {\n const widget = widgets[idx];\n const hasAppearances =\n widget.getAppearances()?.normal instanceof PDFStream;\n if (!hasAppearances) return true;\n }\n\n return false;\n }\n\n /**\n * Update the appearance streams for each of this dropdown's widgets using\n * the default appearance provider for dropdowns. For example:\n * ```js\n * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const dropdown = form.getDropdown('some.dropdown.field')\n * dropdown.defaultUpdateAppearances(helvetica)\n * ```\n * @param font The font to be used for creating the appearance streams.\n */\n defaultUpdateAppearances(font: PDFFont) {\n assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n this.updateAppearances(font);\n }\n\n /**\n * Update the appearance streams for each of this dropdown's widgets using\n * the given appearance provider. If no `provider` is passed, the default\n * appearance provider for dropdowns will be used. For example:\n * ```js\n * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const dropdown = form.getDropdown('some.dropdown.field')\n * dropdown.updateAppearances(helvetica, (field, widget, font) => {\n * ...\n * return drawTextField(...)\n * })\n * ```\n * @param font The font to be used for creating the appearance streams.\n * @param provider Optionally, the appearance provider to be used for\n * generating the contents of the appearance streams.\n */\n updateAppearances(\n font: PDFFont,\n provider?: AppearanceProviderFor,\n ) {\n assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n assertOrUndefined(provider, 'provider', [Function]);\n\n const widgets = this.acroField.getWidgets();\n for (let idx = 0, len = widgets.length; idx < len; idx++) {\n const widget = widgets[idx];\n this.updateWidgetAppearance(widget, font, provider);\n }\n this.markAsClean();\n }\n\n // getOption(index: number): string {}\n // getSelectedIndices(): number[] {}\n // removeOptions(option: string | string[]) {}\n // removeIndices(option: number[]) {}\n // deselect(options: string | string[]) {}\n // deselectIndices(optionIndices: number[]) {}\n\n private updateWidgetAppearance(\n widget: PDFWidgetAnnotation,\n font: PDFFont,\n provider?: AppearanceProviderFor,\n ) {\n const apProvider = provider ?? defaultDropdownAppearanceProvider;\n const appearances = normalizeAppearance(apProvider(this, widget, font));\n this.updateWidgetAppearanceWithFont(widget, font, appearances);\n }\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFFont from 'src/api/PDFFont';\nimport { AppearanceMapping } from 'src/api/form/appearances';\nimport { Color, colorToComponents, setFillingColor } from 'src/api/colors';\nimport {\n Rotation,\n toDegrees,\n rotateRectangle,\n reduceRotation,\n adjustDimsForRotation,\n degrees,\n} from 'src/api/rotations';\n\nimport {\n PDFRef,\n PDFWidgetAnnotation,\n PDFOperator,\n PDFName,\n PDFDict,\n MethodNotImplementedError,\n AcroFieldFlags,\n PDFAcroTerminal,\n AnnotationFlags,\n} from 'src/core';\nimport { assertIs, assertMultiple, assertOrUndefined } from 'src/utils';\nimport { ImageAlignment } from '../image';\nimport PDFImage from '../PDFImage';\nimport { drawImage, rotateInPlace } from '../operations';\n\nexport interface FieldAppearanceOptions {\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n textColor?: Color;\n backgroundColor?: Color;\n borderColor?: Color;\n borderWidth?: number;\n rotate?: Rotation;\n font?: PDFFont;\n hidden?: boolean;\n}\n\nexport const assertFieldAppearanceOptions = (\n options?: FieldAppearanceOptions,\n) => {\n assertOrUndefined(options?.x, 'options.x', ['number']);\n assertOrUndefined(options?.y, 'options.y', ['number']);\n assertOrUndefined(options?.width, 'options.width', ['number']);\n assertOrUndefined(options?.height, 'options.height', ['number']);\n assertOrUndefined(options?.textColor, 'options.textColor', [\n [Object, 'Color'],\n ]);\n assertOrUndefined(options?.backgroundColor, 'options.backgroundColor', [\n [Object, 'Color'],\n ]);\n assertOrUndefined(options?.borderColor, 'options.borderColor', [\n [Object, 'Color'],\n ]);\n assertOrUndefined(options?.borderWidth, 'options.borderWidth', ['number']);\n assertOrUndefined(options?.rotate, 'options.rotate', [[Object, 'Rotation']]);\n};\n\n/**\n * Represents a field of a [[PDFForm]].\n *\n * This class is effectively abstract. All fields in a [[PDFForm]] will\n * actually be an instance of a subclass of this class.\n *\n * Note that each field in a PDF is represented by a single field object.\n * However, a given field object may be rendered at multiple locations within\n * the document (across one or more pages). The rendering of a field is\n * controlled by its widgets. Each widget causes its field to be displayed at a\n * particular location in the document.\n *\n * Most of the time each field in a PDF has only a single widget, and thus is\n * only rendered once. However, if a field is rendered multiple times, it will\n * have multiple widgets - one for each location it is rendered.\n *\n * This abstraction of field objects and widgets is defined in the PDF\n * specification and dictates how PDF files store fields and where they are\n * to be rendered.\n */\nexport default class PDFField {\n /** The low-level PDFAcroTerminal wrapped by this field. */\n readonly acroField: PDFAcroTerminal;\n\n /** The unique reference assigned to this field within the document. */\n readonly ref: PDFRef;\n\n /** The document to which this field belongs. */\n readonly doc: PDFDocument;\n\n protected constructor(\n acroField: PDFAcroTerminal,\n ref: PDFRef,\n doc: PDFDocument,\n ) {\n assertIs(acroField, 'acroField', [[PDFAcroTerminal, 'PDFAcroTerminal']]);\n assertIs(ref, 'ref', [[PDFRef, 'PDFRef']]);\n assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);\n\n this.acroField = acroField;\n this.ref = ref;\n this.doc = doc;\n }\n\n /**\n * Get the fully qualified name of this field. For example:\n * ```js\n * const fields = form.getFields()\n * fields.forEach(field => {\n * const name = field.getName()\n * console.log('Field name:', name)\n * })\n * ```\n * Note that PDF fields are structured as a tree. Each field is the\n * descendent of a series of ancestor nodes all the way up to the form node,\n * which is always the root of the tree. Each node in the tree (except for\n * the form node) has a partial name. Partial names can be composed of any\n * unicode characters except a period (`.`). The fully qualified name of a\n * field is composed of the partial names of all its ancestors joined\n * with periods. This means that splitting the fully qualified name on\n * periods and taking the last element of the resulting array will give you\n * the partial name of a specific field.\n * @returns The fully qualified name of this field.\n */\n getName(): string {\n return this.acroField.getFullyQualifiedName() ?? '';\n }\n\n /**\n * Returns `true` if this field is read only. This means that PDF readers\n * will not allow users to interact with the field or change its value. See\n * [[PDFField.enableReadOnly]] and [[PDFField.disableReadOnly]].\n * For example:\n * ```js\n * const field = form.getField('some.field')\n * if (field.isReadOnly()) console.log('Read only is enabled')\n * ```\n * @returns Whether or not this is a read only field.\n */\n isReadOnly(): boolean {\n return this.acroField.hasFlag(AcroFieldFlags.ReadOnly);\n }\n\n /**\n * Prevent PDF readers from allowing users to interact with this field or\n * change its value. The field will not respond to mouse or keyboard input.\n * For example:\n * ```js\n * const field = form.getField('some.field')\n * field.enableReadOnly()\n * ```\n * Useful for fields whose values are computed, imported from a database, or\n * prefilled by software before being displayed to the user.\n */\n enableReadOnly() {\n this.acroField.setFlagTo(AcroFieldFlags.ReadOnly, true);\n }\n\n /**\n * Allow users to interact with this field and change its value in PDF\n * readers via mouse and keyboard input. For example:\n * ```js\n * const field = form.getField('some.field')\n * field.disableReadOnly()\n * ```\n */\n disableReadOnly() {\n this.acroField.setFlagTo(AcroFieldFlags.ReadOnly, false);\n }\n\n /**\n * Returns `true` if this field must have a value when the form is submitted.\n * See [[PDFField.enableRequired]] and [[PDFField.disableRequired]].\n * For example:\n * ```js\n * const field = form.getField('some.field')\n * if (field.isRequired()) console.log('Field is required')\n * ```\n * @returns Whether or not this field is required.\n */\n isRequired(): boolean {\n return this.acroField.hasFlag(AcroFieldFlags.Required);\n }\n\n /**\n * Require this field to have a value when the form is submitted.\n * For example:\n * ```js\n * const field = form.getField('some.field')\n * field.enableRequired()\n * ```\n */\n enableRequired() {\n this.acroField.setFlagTo(AcroFieldFlags.Required, true);\n }\n\n /**\n * Do not require this field to have a value when the form is submitted.\n * For example:\n * ```js\n * const field = form.getField('some.field')\n * field.disableRequired()\n * ```\n */\n disableRequired() {\n this.acroField.setFlagTo(AcroFieldFlags.Required, false);\n }\n\n /**\n * Returns `true` if this field's value should be exported when the form is\n * submitted. See [[PDFField.enableExporting]] and\n * [[PDFField.disableExporting]].\n * For example:\n * ```js\n * const field = form.getField('some.field')\n * if (field.isExported()) console.log('Exporting is enabled')\n * ```\n * @returns Whether or not this field's value should be exported.\n */\n isExported(): boolean {\n return !this.acroField.hasFlag(AcroFieldFlags.NoExport);\n }\n\n /**\n * Indicate that this field's value should be exported when the form is\n * submitted in a PDF reader. For example:\n * ```js\n * const field = form.getField('some.field')\n * field.enableExporting()\n * ```\n */\n enableExporting() {\n this.acroField.setFlagTo(AcroFieldFlags.NoExport, false);\n }\n\n /**\n * Indicate that this field's value should **not** be exported when the form\n * is submitted in a PDF reader. For example:\n * ```js\n * const field = form.getField('some.field')\n * field.disableExporting()\n * ```\n */\n disableExporting() {\n this.acroField.setFlagTo(AcroFieldFlags.NoExport, true);\n }\n\n /** @ignore */\n needsAppearancesUpdate(): boolean {\n throw new MethodNotImplementedError(\n this.constructor.name,\n 'needsAppearancesUpdate',\n );\n }\n\n /** @ignore */\n defaultUpdateAppearances(_font: PDFFont) {\n throw new MethodNotImplementedError(\n this.constructor.name,\n 'defaultUpdateAppearances',\n );\n }\n\n protected markAsDirty() {\n this.doc.getForm().markFieldAsDirty(this.ref);\n }\n\n protected markAsClean() {\n this.doc.getForm().markFieldAsClean(this.ref);\n }\n\n protected isDirty(): boolean {\n return this.doc.getForm().fieldIsDirty(this.ref);\n }\n\n protected createWidget(options: {\n x: number;\n y: number;\n width: number;\n height: number;\n textColor?: Color;\n backgroundColor?: Color;\n borderColor?: Color;\n borderWidth: number;\n rotate: Rotation;\n caption?: string;\n hidden?: boolean;\n page?: PDFRef;\n }): PDFWidgetAnnotation {\n const textColor = options.textColor;\n const backgroundColor = options.backgroundColor;\n const borderColor = options.borderColor;\n const borderWidth = options.borderWidth;\n const degreesAngle = toDegrees(options.rotate);\n const caption = options.caption;\n const x = options.x;\n const y = options.y;\n const width = options.width + borderWidth;\n const height = options.height + borderWidth;\n const hidden = Boolean(options.hidden);\n const pageRef = options.page;\n\n assertMultiple(degreesAngle, 'degreesAngle', 90);\n\n // Create a widget for this field\n const widget = PDFWidgetAnnotation.create(this.doc.context, this.ref);\n\n // Set widget properties\n const rect = rotateRectangle(\n { x, y, width, height },\n borderWidth,\n degreesAngle,\n );\n widget.setRectangle(rect);\n\n if (pageRef) widget.setP(pageRef);\n\n const ac = widget.getOrCreateAppearanceCharacteristics();\n if (backgroundColor) {\n ac.setBackgroundColor(colorToComponents(backgroundColor));\n }\n ac.setRotation(degreesAngle);\n if (caption) ac.setCaptions({ normal: caption });\n if (borderColor) ac.setBorderColor(colorToComponents(borderColor));\n\n const bs = widget.getOrCreateBorderStyle();\n if (borderWidth !== undefined) bs.setWidth(borderWidth);\n\n widget.setFlagTo(AnnotationFlags.Print, true);\n widget.setFlagTo(AnnotationFlags.Hidden, hidden);\n widget.setFlagTo(AnnotationFlags.Invisible, false);\n\n // Set acrofield properties\n if (textColor) {\n const da = this.acroField.getDefaultAppearance() ?? '';\n const newDa = da + '\\n' + setFillingColor(textColor).toString();\n this.acroField.setDefaultAppearance(newDa);\n }\n\n return widget;\n }\n\n protected updateWidgetAppearanceWithFont(\n widget: PDFWidgetAnnotation,\n font: PDFFont,\n { normal, rollover, down }: AppearanceMapping,\n ) {\n this.updateWidgetAppearances(widget, {\n normal: this.createAppearanceStream(widget, normal, font),\n rollover: rollover && this.createAppearanceStream(widget, rollover, font),\n down: down && this.createAppearanceStream(widget, down, font),\n });\n }\n\n protected updateOnOffWidgetAppearance(\n widget: PDFWidgetAnnotation,\n onValue: PDFName,\n {\n normal,\n rollover,\n down,\n }: AppearanceMapping<{ on: PDFOperator[]; off: PDFOperator[] }>,\n ) {\n this.updateWidgetAppearances(widget, {\n normal: this.createAppearanceDict(widget, normal, onValue),\n rollover:\n rollover && this.createAppearanceDict(widget, rollover, onValue),\n down: down && this.createAppearanceDict(widget, down, onValue),\n });\n }\n\n protected updateWidgetAppearances(\n widget: PDFWidgetAnnotation,\n { normal, rollover, down }: AppearanceMapping,\n ) {\n widget.setNormalAppearance(normal);\n\n if (rollover) {\n widget.setRolloverAppearance(rollover);\n } else {\n widget.removeRolloverAppearance();\n }\n\n if (down) {\n widget.setDownAppearance(down);\n } else {\n widget.removeDownAppearance();\n }\n }\n\n // // TODO: Do we need to do this...?\n // private foo(font: PDFFont, dict: PDFDict) {\n // if (!dict.lookup(PDFName.of('DR'))) {\n // dict.set(PDFName.of('DR'), dict.context.obj({}));\n // }\n // const DR = dict.lookup(PDFName.of('DR'), PDFDict);\n\n // if (!DR.lookup(PDFName.of('Font'))) {\n // DR.set(PDFName.of('Font'), dict.context.obj({}));\n // }\n // const Font = DR.lookup(PDFName.of('Font'), PDFDict);\n\n // Font.set(PDFName.of(font.name), font.ref);\n // }\n\n private createAppearanceStream(\n widget: PDFWidgetAnnotation,\n appearance: PDFOperator[],\n font?: PDFFont,\n ): PDFRef {\n const { context } = this.acroField.dict;\n const { width, height } = widget.getRectangle();\n\n // TODO: Do we need to do this...?\n // if (font) {\n // this.foo(font, widget.dict);\n // this.foo(font, this.doc.getForm().acroForm.dict);\n // }\n // END TODO\n\n const Resources = font && { Font: { [font.name]: font.ref } };\n const stream = context.formXObject(appearance, {\n Resources,\n BBox: context.obj([0, 0, width, height]),\n Matrix: context.obj([1, 0, 0, 1, 0, 0]),\n });\n const streamRef = context.register(stream);\n\n return streamRef;\n }\n\n /**\n * Create a FormXObject of the supplied image and add it to context.\n * The FormXObject size is calculated based on the widget (including\n * the alignment).\n * @param widget The widget that should display the image.\n * @param alignment The alignment of the image.\n * @param image The image that should be displayed.\n * @returns The ref for the FormXObject that was added to the context.\n */\n protected createImageAppearanceStream(\n widget: PDFWidgetAnnotation,\n image: PDFImage,\n alignment: ImageAlignment,\n ): PDFRef {\n // NOTE: This implementation doesn't handle image borders.\n // NOTE: Acrobat seems to resize the image (maybe even skewing its aspect\n // ratio) to fit perfectly within the widget's rectangle. This method\n // does not currently do that. Should there be an option for that?\n\n const { context } = this.acroField.dict;\n\n const rectangle = widget.getRectangle();\n const ap = widget.getAppearanceCharacteristics();\n const bs = widget.getBorderStyle();\n\n const borderWidth = bs?.getWidth() ?? 0;\n const rotation = reduceRotation(ap?.getRotation());\n\n const rotate = rotateInPlace({ ...rectangle, rotation });\n\n const adj = adjustDimsForRotation(rectangle, rotation);\n const imageDims = image.scaleToFit(\n adj.width - borderWidth * 2,\n adj.height - borderWidth * 2,\n );\n\n // Support borders on images and maybe other properties\n const options = {\n x: borderWidth,\n y: borderWidth,\n width: imageDims.width,\n height: imageDims.height,\n //\n rotate: degrees(0),\n xSkew: degrees(0),\n ySkew: degrees(0),\n };\n\n if (alignment === ImageAlignment.Center) {\n options.x += (adj.width - borderWidth * 2) / 2 - imageDims.width / 2;\n options.y += (adj.height - borderWidth * 2) / 2 - imageDims.height / 2;\n } else if (alignment === ImageAlignment.Right) {\n options.x = adj.width - borderWidth - imageDims.width;\n options.y = adj.height - borderWidth - imageDims.height;\n }\n\n const imageName = this.doc.context.addRandomSuffix('Image', 10);\n const appearance = [...rotate, ...drawImage(imageName, options)];\n ////////////\n\n const Resources = { XObject: { [imageName]: image.ref } };\n const stream = context.formXObject(appearance, {\n Resources,\n BBox: context.obj([0, 0, rectangle.width, rectangle.height]),\n Matrix: context.obj([1, 0, 0, 1, 0, 0]),\n });\n\n return context.register(stream);\n }\n\n private createAppearanceDict(\n widget: PDFWidgetAnnotation,\n appearance: { on: PDFOperator[]; off: PDFOperator[] },\n onValue: PDFName,\n ): PDFDict {\n const { context } = this.acroField.dict;\n\n const onStreamRef = this.createAppearanceStream(widget, appearance.on);\n const offStreamRef = this.createAppearanceStream(widget, appearance.off);\n\n const appearanceDict = context.obj({});\n appearanceDict.set(onValue, onStreamRef);\n appearanceDict.set(PDFName.of('Off'), offStreamRef);\n\n return appearanceDict;\n }\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFPage from 'src/api/PDFPage';\nimport PDFField from 'src/api/form/PDFField';\nimport PDFButton from 'src/api/form/PDFButton';\nimport PDFCheckBox from 'src/api/form/PDFCheckBox';\nimport PDFDropdown from 'src/api/form/PDFDropdown';\nimport PDFOptionList from 'src/api/form/PDFOptionList';\nimport PDFRadioGroup from 'src/api/form/PDFRadioGroup';\nimport PDFSignature from 'src/api/form/PDFSignature';\nimport PDFTextField from 'src/api/form/PDFTextField';\nimport {\n NoSuchFieldError,\n UnexpectedFieldTypeError,\n FieldAlreadyExistsError,\n InvalidFieldNamePartError,\n} from 'src/api/errors';\nimport PDFFont from 'src/api/PDFFont';\nimport { StandardFonts } from 'src/api/StandardFonts';\nimport { rotateInPlace } from 'src/api/operations';\nimport {\n drawObject,\n popGraphicsState,\n pushGraphicsState,\n translate,\n} from 'src/api/operators';\nimport {\n PDFAcroForm,\n PDFAcroField,\n PDFAcroCheckBox,\n PDFAcroComboBox,\n PDFAcroListBox,\n PDFAcroRadioButton,\n PDFAcroSignature,\n PDFAcroText,\n PDFAcroPushButton,\n PDFAcroNonTerminal,\n PDFDict,\n PDFOperator,\n PDFRef,\n createPDFAcroFields,\n PDFName,\n PDFWidgetAnnotation,\n} from 'src/core';\nimport { assertIs, Cache, assertOrUndefined } from 'src/utils';\n\nexport interface FlattenOptions {\n updateFieldAppearances: boolean;\n}\n\n/**\n * Represents the interactive form of a [[PDFDocument]].\n *\n * Interactive forms (sometimes called _AcroForms_) are collections of fields\n * designed to gather information from a user. A PDF document may contains any\n * number of fields that appear on various pages, all of which make up a single,\n * global interactive form spanning the entire document. This means that\n * instances of [[PDFDocument]] shall contain at most one [[PDFForm]].\n *\n * The fields of an interactive form are represented by [[PDFField]] instances.\n */\nexport default class PDFForm {\n /**\n * > **NOTE:** You probably don't want to call this method directly. Instead,\n * > consider using the [[PDFDocument.getForm]] method, which will create an\n * > instance of [[PDFForm]] for you.\n *\n * Create an instance of [[PDFForm]] from an existing acroForm and embedder\n *\n * @param acroForm The underlying `PDFAcroForm` for this form.\n * @param doc The document to which the form will belong.\n */\n static of = (acroForm: PDFAcroForm, doc: PDFDocument) =>\n new PDFForm(acroForm, doc);\n\n /** The low-level PDFAcroForm wrapped by this form. */\n readonly acroForm: PDFAcroForm;\n\n /** The document to which this form belongs. */\n readonly doc: PDFDocument;\n\n private readonly dirtyFields: Set;\n private readonly defaultFontCache: Cache;\n\n private constructor(acroForm: PDFAcroForm, doc: PDFDocument) {\n assertIs(acroForm, 'acroForm', [[PDFAcroForm, 'PDFAcroForm']]);\n assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);\n\n this.acroForm = acroForm;\n this.doc = doc;\n\n this.dirtyFields = new Set();\n this.defaultFontCache = Cache.populatedBy(this.embedDefaultFont);\n }\n\n /**\n * Returns `true` if this [[PDFForm]] has XFA data. Most PDFs with form\n * fields do not use XFA as it is not widely supported by PDF readers.\n *\n * > `pdf-lib` does not support creation, modification, or reading of XFA\n * > fields.\n *\n * For example:\n * ```js\n * const form = pdfDoc.getForm()\n * if (form.hasXFA()) console.log('PDF has XFA data')\n * ```\n * @returns Whether or not this form has XFA data.\n */\n hasXFA(): boolean {\n return this.acroForm.dict.has(PDFName.of('XFA'));\n }\n\n /**\n * Disconnect the XFA data from this [[PDFForm]] (if any exists). This will\n * force readers to fallback to standard fields if the [[PDFDocument]]\n * contains any. For example:\n *\n * For example:\n * ```js\n * const form = pdfDoc.getForm()\n * form.deleteXFA()\n * ```\n */\n deleteXFA(): void {\n this.acroForm.dict.delete(PDFName.of('XFA'));\n }\n\n /**\n * Get all fields contained in this [[PDFForm]]. For example:\n * ```js\n * const form = pdfDoc.getForm()\n * const fields = form.getFields()\n * fields.forEach(field => {\n * const type = field.constructor.name\n * const name = field.getName()\n * console.log(`${type}: ${name}`)\n * })\n * ```\n * @returns An array of all fields in this form.\n */\n getFields(): PDFField[] {\n const allFields = this.acroForm.getAllFields();\n\n const fields: PDFField[] = [];\n for (let idx = 0, len = allFields.length; idx < len; idx++) {\n const [acroField, ref] = allFields[idx];\n const field = convertToPDFField(acroField, ref, this.doc);\n if (field) fields.push(field);\n }\n\n return fields;\n }\n\n /**\n * Get the field in this [[PDFForm]] with the given name. For example:\n * ```js\n * const form = pdfDoc.getForm()\n * const field = form.getFieldMaybe('Page1.Foo.Bar[0]')\n * if (field) console.log('Field exists!')\n * ```\n * @param name A fully qualified field name.\n * @returns The field with the specified name, if one exists.\n */\n getFieldMaybe(name: string): PDFField | undefined {\n assertIs(name, 'name', ['string']);\n const fields = this.getFields();\n for (let idx = 0, len = fields.length; idx < len; idx++) {\n const field = fields[idx];\n if (field.getName() === name) return field;\n }\n return undefined;\n }\n\n /**\n * Get the field in this [[PDFForm]] with the given name. For example:\n * ```js\n * const form = pdfDoc.getForm()\n * const field = form.getField('Page1.Foo.Bar[0]')\n * ```\n * If no field exists with the provided name, an error will be thrown.\n * @param name A fully qualified field name.\n * @returns The field with the specified name.\n */\n getField(name: string): PDFField {\n assertIs(name, 'name', ['string']);\n const field = this.getFieldMaybe(name);\n if (field) return field;\n throw new NoSuchFieldError(name);\n }\n\n /**\n * Get the button field in this [[PDFForm]] with the given name. For example:\n * ```js\n * const form = pdfDoc.getForm()\n * const button = form.getButton('Page1.Foo.Button[0]')\n * ```\n * An error will be thrown if no field exists with the provided name, or if\n * the field exists but is not a button.\n * @param name A fully qualified button name.\n * @returns The button with the specified name.\n */\n getButton(name: string): PDFButton {\n assertIs(name, 'name', ['string']);\n const field = this.getField(name);\n if (field instanceof PDFButton) return field;\n throw new UnexpectedFieldTypeError(name, PDFButton, field);\n }\n\n /**\n * Get the check box field in this [[PDFForm]] with the given name.\n * For example:\n * ```js\n * const form = pdfDoc.getForm()\n * const checkBox = form.getCheckBox('Page1.Foo.CheckBox[0]')\n * checkBox.check()\n * ```\n * An error will be thrown if no field exists with the provided name, or if\n * the field exists but is not a check box.\n * @param name A fully qualified check box name.\n * @returns The check box with the specified name.\n */\n getCheckBox(name: string): PDFCheckBox {\n assertIs(name, 'name', ['string']);\n const field = this.getField(name);\n if (field instanceof PDFCheckBox) return field;\n throw new UnexpectedFieldTypeError(name, PDFCheckBox, field);\n }\n\n /**\n * Get the dropdown field in this [[PDFForm]] with the given name.\n * For example:\n * ```js\n * const form = pdfDoc.getForm()\n * const dropdown = form.getDropdown('Page1.Foo.Dropdown[0]')\n * const options = dropdown.getOptions()\n * dropdown.select(options[0])\n * ```\n * An error will be thrown if no field exists with the provided name, or if\n * the field exists but is not a dropdown.\n * @param name A fully qualified dropdown name.\n * @returns The dropdown with the specified name.\n */\n getDropdown(name: string): PDFDropdown {\n assertIs(name, 'name', ['string']);\n const field = this.getField(name);\n if (field instanceof PDFDropdown) return field;\n throw new UnexpectedFieldTypeError(name, PDFDropdown, field);\n }\n\n /**\n * Get the option list field in this [[PDFForm]] with the given name.\n * For example:\n * ```js\n * const form = pdfDoc.getForm()\n * const optionList = form.getOptionList('Page1.Foo.OptionList[0]')\n * const options = optionList.getOptions()\n * optionList.select(options[0])\n * ```\n * An error will be thrown if no field exists with the provided name, or if\n * the field exists but is not an option list.\n * @param name A fully qualified option list name.\n * @returns The option list with the specified name.\n */\n getOptionList(name: string): PDFOptionList {\n assertIs(name, 'name', ['string']);\n const field = this.getField(name);\n if (field instanceof PDFOptionList) return field;\n throw new UnexpectedFieldTypeError(name, PDFOptionList, field);\n }\n\n /**\n * Get the radio group field in this [[PDFForm]] with the given name.\n * For example:\n * ```js\n * const form = pdfDoc.getForm()\n * const radioGroup = form.getRadioGroup('Page1.Foo.RadioGroup[0]')\n * const options = radioGroup.getOptions()\n * radioGroup.select(options[0])\n * ```\n * An error will be thrown if no field exists with the provided name, or if\n * the field exists but is not a radio group.\n * @param name A fully qualified radio group name.\n * @returns The radio group with the specified name.\n */\n getRadioGroup(name: string): PDFRadioGroup {\n assertIs(name, 'name', ['string']);\n const field = this.getField(name);\n if (field instanceof PDFRadioGroup) return field;\n throw new UnexpectedFieldTypeError(name, PDFRadioGroup, field);\n }\n\n /**\n * Get the signature field in this [[PDFForm]] with the given name.\n * For example:\n * ```js\n * const form = pdfDoc.getForm()\n * const signature = form.getSignature('Page1.Foo.Signature[0]')\n * ```\n * An error will be thrown if no field exists with the provided name, or if\n * the field exists but is not a signature.\n * @param name A fully qualified signature name.\n * @returns The signature with the specified name.\n */\n getSignature(name: string): PDFSignature {\n assertIs(name, 'name', ['string']);\n const field = this.getField(name);\n if (field instanceof PDFSignature) return field;\n throw new UnexpectedFieldTypeError(name, PDFSignature, field);\n }\n\n /**\n * Get the text field in this [[PDFForm]] with the given name.\n * For example:\n * ```js\n * const form = pdfDoc.getForm()\n * const textField = form.getTextField('Page1.Foo.TextField[0]')\n * textField.setText('Are you designed to act or to be acted upon?')\n * ```\n * An error will be thrown if no field exists with the provided name, or if\n * the field exists but is not a text field.\n * @param name A fully qualified text field name.\n * @returns The text field with the specified name.\n */\n getTextField(name: string): PDFTextField {\n assertIs(name, 'name', ['string']);\n const field = this.getField(name);\n if (field instanceof PDFTextField) return field;\n throw new UnexpectedFieldTypeError(name, PDFTextField, field);\n }\n\n /**\n * Create a new button field in this [[PDFForm]] with the given name.\n * For example:\n * ```js\n * const font = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const page = pdfDoc.addPage()\n *\n * const form = pdfDoc.getForm()\n * const button = form.createButton('cool.new.button')\n *\n * button.addToPage('Do Stuff', font, page)\n * ```\n * An error will be thrown if a field already exists with the provided name.\n * @param name The fully qualified name for the new button.\n * @returns The new button field.\n */\n createButton(name: string): PDFButton {\n assertIs(name, 'name', ['string']);\n\n const nameParts = splitFieldName(name);\n const parent = this.findOrCreateNonTerminals(nameParts.nonTerminal);\n\n const button = PDFAcroPushButton.create(this.doc.context);\n button.setPartialName(nameParts.terminal);\n\n addFieldToParent(parent, [button, button.ref], nameParts.terminal);\n\n return PDFButton.of(button, button.ref, this.doc);\n }\n\n /**\n * Create a new check box field in this [[PDFForm]] with the given name.\n * For example:\n * ```js\n * const font = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const page = pdfDoc.addPage()\n *\n * const form = pdfDoc.getForm()\n * const checkBox = form.createCheckBox('cool.new.checkBox')\n *\n * checkBox.addToPage(page)\n * ```\n * An error will be thrown if a field already exists with the provided name.\n * @param name The fully qualified name for the new check box.\n * @returns The new check box field.\n */\n createCheckBox(name: string): PDFCheckBox {\n assertIs(name, 'name', ['string']);\n\n const nameParts = splitFieldName(name);\n const parent = this.findOrCreateNonTerminals(nameParts.nonTerminal);\n\n const checkBox = PDFAcroCheckBox.create(this.doc.context);\n checkBox.setPartialName(nameParts.terminal);\n\n addFieldToParent(parent, [checkBox, checkBox.ref], nameParts.terminal);\n\n return PDFCheckBox.of(checkBox, checkBox.ref, this.doc);\n }\n\n /**\n * Create a new dropdown field in this [[PDFForm]] with the given name.\n * For example:\n * ```js\n * const font = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const page = pdfDoc.addPage()\n *\n * const form = pdfDoc.getForm()\n * const dropdown = form.createDropdown('cool.new.dropdown')\n *\n * dropdown.addToPage(font, page)\n * ```\n * An error will be thrown if a field already exists with the provided name.\n * @param name The fully qualified name for the new dropdown.\n * @returns The new dropdown field.\n */\n createDropdown(name: string): PDFDropdown {\n assertIs(name, 'name', ['string']);\n\n const nameParts = splitFieldName(name);\n const parent = this.findOrCreateNonTerminals(nameParts.nonTerminal);\n\n const comboBox = PDFAcroComboBox.create(this.doc.context);\n comboBox.setPartialName(nameParts.terminal);\n\n addFieldToParent(parent, [comboBox, comboBox.ref], nameParts.terminal);\n\n return PDFDropdown.of(comboBox, comboBox.ref, this.doc);\n }\n\n /**\n * Create a new option list field in this [[PDFForm]] with the given name.\n * For example:\n * ```js\n * const font = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const page = pdfDoc.addPage()\n *\n * const form = pdfDoc.getForm()\n * const optionList = form.createOptionList('cool.new.optionList')\n *\n * optionList.addToPage(font, page)\n * ```\n * An error will be thrown if a field already exists with the provided name.\n * @param name The fully qualified name for the new option list.\n * @returns The new option list field.\n */\n createOptionList(name: string): PDFOptionList {\n assertIs(name, 'name', ['string']);\n\n const nameParts = splitFieldName(name);\n const parent = this.findOrCreateNonTerminals(nameParts.nonTerminal);\n\n const listBox = PDFAcroListBox.create(this.doc.context);\n listBox.setPartialName(nameParts.terminal);\n\n addFieldToParent(parent, [listBox, listBox.ref], nameParts.terminal);\n\n return PDFOptionList.of(listBox, listBox.ref, this.doc);\n }\n\n /**\n * Create a new radio group field in this [[PDFForm]] with the given name.\n * For example:\n * ```js\n * const font = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const page = pdfDoc.addPage()\n *\n * const form = pdfDoc.getForm()\n * const radioGroup = form.createRadioGroup('cool.new.radioGroup')\n *\n * radioGroup.addOptionToPage('is-dog', page, { y: 0 })\n * radioGroup.addOptionToPage('is-cat', page, { y: 75 })\n * ```\n * An error will be thrown if a field already exists with the provided name.\n * @param name The fully qualified name for the new radio group.\n * @returns The new radio group field.\n */\n createRadioGroup(name: string): PDFRadioGroup {\n assertIs(name, 'name', ['string']);\n const nameParts = splitFieldName(name);\n\n const parent = this.findOrCreateNonTerminals(nameParts.nonTerminal);\n\n const radioButton = PDFAcroRadioButton.create(this.doc.context);\n radioButton.setPartialName(nameParts.terminal);\n\n addFieldToParent(\n parent,\n [radioButton, radioButton.ref],\n nameParts.terminal,\n );\n\n return PDFRadioGroup.of(radioButton, radioButton.ref, this.doc);\n }\n\n /**\n * Create a new text field in this [[PDFForm]] with the given name.\n * For example:\n * ```js\n * const font = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const page = pdfDoc.addPage()\n *\n * const form = pdfDoc.getForm()\n * const textField = form.createTextField('cool.new.textField')\n *\n * textField.addToPage(font, page)\n * ```\n * An error will be thrown if a field already exists with the provided name.\n * @param name The fully qualified name for the new radio group.\n * @returns The new radio group field.\n */\n createTextField(name: string): PDFTextField {\n assertIs(name, 'name', ['string']);\n const nameParts = splitFieldName(name);\n\n const parent = this.findOrCreateNonTerminals(nameParts.nonTerminal);\n\n const text = PDFAcroText.create(this.doc.context);\n text.setPartialName(nameParts.terminal);\n\n addFieldToParent(parent, [text, text.ref], nameParts.terminal);\n\n return PDFTextField.of(text, text.ref, this.doc);\n }\n\n /**\n * Flatten all fields in this [[PDFForm]].\n *\n * Flattening a form field will take the current appearance for each of that\n * field's widgets and make them part of their page's content stream. All form\n * fields and annotations associated are then removed. Note that once a form\n * has been flattened its fields can no longer be accessed or edited.\n *\n * This operation is often used after filling form fields to ensure a\n * consistent appearance across different PDF readers and/or printers.\n * Another common use case is to copy a template document with form fields\n * into another document. In this scenario you would load the template\n * document, fill its fields, flatten it, and then copy its pages into the\n * recipient document - the filled fields will be copied over.\n *\n * For example:\n * ```js\n * const form = pdfDoc.getForm();\n * form.flatten();\n * ```\n */\n flatten(options: FlattenOptions = { updateFieldAppearances: true }) {\n if (options.updateFieldAppearances) {\n this.updateFieldAppearances();\n }\n\n const fields = this.getFields();\n\n for (let i = 0, lenFields = fields.length; i < lenFields; i++) {\n const field = fields[i];\n const widgets = field.acroField.getWidgets();\n\n for (let j = 0, lenWidgets = widgets.length; j < lenWidgets; j++) {\n const widget = widgets[j];\n const page = this.findWidgetPage(widget);\n const widgetRef = this.findWidgetAppearanceRef(field, widget);\n\n const xObjectKey = page.node.newXObject('FlatWidget', widgetRef);\n\n const rectangle = widget.getRectangle();\n const operators = [\n pushGraphicsState(),\n translate(rectangle.x, rectangle.y),\n ...rotateInPlace({ ...rectangle, rotation: 0 }),\n drawObject(xObjectKey),\n popGraphicsState(),\n ].filter(Boolean) as PDFOperator[];\n\n page.pushOperators(...operators);\n }\n\n this.removeField(field);\n }\n }\n\n /**\n * Remove a field from this [[PDFForm]].\n *\n * For example:\n * ```js\n * const form = pdfDoc.getForm();\n * const ageField = form.getFields().find(x => x.getName() === 'Age');\n * form.removeField(ageField);\n * ```\n */\n removeField(field: PDFField) {\n const widgets = field.acroField.getWidgets();\n const pages: Set = new Set();\n\n for (let i = 0, len = widgets.length; i < len; i++) {\n const widget = widgets[i];\n const widgetRef = this.findWidgetAppearanceRef(field, widget);\n\n const page = this.findWidgetPage(widget);\n pages.add(page);\n\n page.node.removeAnnot(widgetRef);\n }\n\n pages.forEach((page) => page.node.removeAnnot(field.ref));\n this.acroForm.removeField(field.acroField);\n const fieldKids = field.acroField.normalizedEntries().Kids;\n const kidsCount = fieldKids.size();\n for (let childIndex = 0; childIndex < kidsCount; childIndex++) {\n const child = fieldKids.get(childIndex);\n if (child instanceof PDFRef) {\n this.doc.context.delete(child);\n }\n }\n this.doc.context.delete(field.ref);\n }\n\n /**\n * Update the appearance streams for all widgets of all fields in this\n * [[PDFForm]]. Appearance streams will only be created for a widget if it\n * does not have any existing appearance streams, or the field's value has\n * changed (e.g. by calling [[PDFTextField.setText]] or\n * [[PDFDropdown.select]]).\n *\n * For example:\n * ```js\n * const courier = await pdfDoc.embedFont(StandardFonts.Courier)\n * const form = pdfDoc.getForm()\n * form.updateFieldAppearances(courier)\n * ```\n *\n * **IMPORTANT:** The default value for the `font` parameter is\n * [[StandardFonts.Helvetica]]. Note that this is a WinAnsi font. This means\n * that encoding errors will be thrown if any fields contain text with\n * characters outside the WinAnsi character set (the latin alphabet).\n *\n * Embedding a custom font and passing that as the `font`\n * parameter allows you to generate appearance streams with non WinAnsi\n * characters (assuming your custom font supports them).\n *\n * > **NOTE:** The [[PDFDocument.save]] method will call this method to\n * > update appearances automatically if a form was accessed via the\n * > [[PDFDocument.getForm]] method prior to saving.\n *\n * @param font Optionally, the font to use when creating new appearances.\n */\n updateFieldAppearances(font?: PDFFont) {\n assertOrUndefined(font, 'font', [[PDFFont, 'PDFFont']]);\n\n font = font ?? this.getDefaultFont();\n\n const fields = this.getFields();\n\n for (let idx = 0, len = fields.length; idx < len; idx++) {\n const field = fields[idx];\n if (field.needsAppearancesUpdate()) {\n field.defaultUpdateAppearances(font);\n }\n }\n }\n\n /**\n * Mark a field as dirty. This will cause its appearance streams to be\n * updated by [[PDFForm.updateFieldAppearances]].\n * ```js\n * const form = pdfDoc.getForm()\n * const field = form.getField('foo.bar')\n * form.markFieldAsDirty(field.ref)\n * ```\n * @param fieldRef The reference to the field that should be marked.\n */\n markFieldAsDirty(fieldRef: PDFRef) {\n assertOrUndefined(fieldRef, 'fieldRef', [[PDFRef, 'PDFRef']]);\n this.dirtyFields.add(fieldRef);\n }\n\n /**\n * Mark a field as dirty. This will cause its appearance streams to not be\n * updated by [[PDFForm.updateFieldAppearances]].\n * ```js\n * const form = pdfDoc.getForm()\n * const field = form.getField('foo.bar')\n * form.markFieldAsClean(field.ref)\n * ```\n * @param fieldRef The reference to the field that should be marked.\n */\n markFieldAsClean(fieldRef: PDFRef) {\n assertOrUndefined(fieldRef, 'fieldRef', [[PDFRef, 'PDFRef']]);\n this.dirtyFields.delete(fieldRef);\n }\n\n /**\n * Returns `true` is the specified field has been marked as dirty.\n * ```js\n * const form = pdfDoc.getForm()\n * const field = form.getField('foo.bar')\n * if (form.fieldIsDirty(field.ref)) console.log('Field is dirty')\n * ```\n * @param fieldRef The reference to the field that should be checked.\n * @returns Whether or not the specified field is dirty.\n */\n fieldIsDirty(fieldRef: PDFRef): boolean {\n assertOrUndefined(fieldRef, 'fieldRef', [[PDFRef, 'PDFRef']]);\n return this.dirtyFields.has(fieldRef);\n }\n\n getDefaultFont() {\n return this.defaultFontCache.access();\n }\n\n private findWidgetPage(widget: PDFWidgetAnnotation): PDFPage {\n const pageRef = widget.P();\n let page = this.doc.getPages().find((x) => x.ref === pageRef);\n if (page === undefined) {\n const widgetRef = this.doc.context.getObjectRef(widget.dict);\n if (widgetRef === undefined) {\n throw new Error('Could not find PDFRef for PDFObject');\n }\n\n page = this.doc.findPageForAnnotationRef(widgetRef);\n\n if (page === undefined) {\n throw new Error(`Could not find page for PDFRef ${widgetRef}`);\n }\n }\n\n return page;\n }\n\n private findWidgetAppearanceRef(\n field: PDFField,\n widget: PDFWidgetAnnotation,\n ): PDFRef {\n let refOrDict = widget.getNormalAppearance();\n\n if (\n refOrDict instanceof PDFDict &&\n (field instanceof PDFCheckBox || field instanceof PDFRadioGroup)\n ) {\n const value = field.acroField.getValue();\n const ref = refOrDict.get(value) ?? refOrDict.get(PDFName.of('Off'));\n\n if (ref instanceof PDFRef) {\n refOrDict = ref;\n }\n }\n\n if (!(refOrDict instanceof PDFRef)) {\n const name = field.getName();\n throw new Error(`Failed to extract appearance ref for: ${name}`);\n }\n\n return refOrDict;\n }\n\n private findOrCreateNonTerminals(partialNames: string[]) {\n let nonTerminal: [PDFAcroForm] | [PDFAcroNonTerminal, PDFRef] = [\n this.acroForm,\n ];\n for (let idx = 0, len = partialNames.length; idx < len; idx++) {\n const namePart = partialNames[idx];\n if (!namePart) throw new InvalidFieldNamePartError(namePart);\n const [parent, parentRef] = nonTerminal;\n const res = this.findNonTerminal(namePart, parent);\n\n if (res) {\n nonTerminal = res;\n } else {\n const node = PDFAcroNonTerminal.create(this.doc.context);\n node.setPartialName(namePart);\n node.setParent(parentRef);\n const nodeRef = this.doc.context.register(node.dict);\n parent.addField(nodeRef);\n nonTerminal = [node, nodeRef];\n }\n }\n return nonTerminal;\n }\n\n private findNonTerminal(\n partialName: string,\n parent: PDFAcroForm | PDFAcroNonTerminal,\n ): [PDFAcroNonTerminal, PDFRef] | undefined {\n const fields =\n parent instanceof PDFAcroForm\n ? this.acroForm.getFields()\n : createPDFAcroFields(parent.Kids());\n\n for (let idx = 0, len = fields.length; idx < len; idx++) {\n const [field, ref] = fields[idx];\n if (field.getPartialName() === partialName) {\n if (field instanceof PDFAcroNonTerminal) return [field, ref];\n throw new FieldAlreadyExistsError(partialName);\n }\n }\n\n return undefined;\n }\n\n private embedDefaultFont = (): PDFFont =>\n this.doc.embedStandardFont(StandardFonts.Helvetica);\n}\n\nconst convertToPDFField = (\n field: PDFAcroField,\n ref: PDFRef,\n doc: PDFDocument,\n): PDFField | undefined => {\n if (field instanceof PDFAcroPushButton) return PDFButton.of(field, ref, doc);\n if (field instanceof PDFAcroCheckBox) return PDFCheckBox.of(field, ref, doc);\n if (field instanceof PDFAcroComboBox) return PDFDropdown.of(field, ref, doc);\n if (field instanceof PDFAcroListBox) return PDFOptionList.of(field, ref, doc);\n if (field instanceof PDFAcroText) return PDFTextField.of(field, ref, doc);\n if (field instanceof PDFAcroRadioButton) {\n return PDFRadioGroup.of(field, ref, doc);\n }\n if (field instanceof PDFAcroSignature) {\n return PDFSignature.of(field, ref, doc);\n }\n return undefined;\n};\n\nconst splitFieldName = (fullyQualifiedName: string) => {\n if (fullyQualifiedName.length === 0) {\n throw new Error('PDF field names must not be empty strings');\n }\n\n const parts = fullyQualifiedName.split('.');\n\n for (let idx = 0, len = parts.length; idx < len; idx++) {\n if (parts[idx] === '') {\n throw new Error(\n `Periods in PDF field names must be separated by at least one character: \"${fullyQualifiedName}\"`,\n );\n }\n }\n\n if (parts.length === 1) return { nonTerminal: [], terminal: parts[0] };\n\n return {\n nonTerminal: parts.slice(0, parts.length - 1),\n terminal: parts[parts.length - 1],\n };\n};\n\nconst addFieldToParent = (\n [parent, parentRef]: [PDFAcroForm] | [PDFAcroNonTerminal, PDFRef],\n [field, fieldRef]: [PDFAcroField, PDFRef],\n partialName: string,\n) => {\n const entries = parent.normalizedEntries();\n const fields = createPDFAcroFields(\n 'Kids' in entries ? entries.Kids : entries.Fields,\n );\n for (let idx = 0, len = fields.length; idx < len; idx++) {\n if (fields[idx][0].getPartialName() === partialName) {\n throw new FieldAlreadyExistsError(partialName);\n }\n }\n parent.addField(fieldRef);\n field.setParent(parentRef);\n};\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFPage from 'src/api/PDFPage';\nimport PDFFont from 'src/api/PDFFont';\nimport PDFField, {\n FieldAppearanceOptions,\n assertFieldAppearanceOptions,\n} from 'src/api/form/PDFField';\nimport {\n AppearanceProviderFor,\n normalizeAppearance,\n defaultOptionListAppearanceProvider,\n} from 'src/api/form/appearances';\nimport { rgb } from 'src/api/colors';\nimport { degrees } from 'src/api/rotations';\n\nimport {\n PDFRef,\n PDFHexString,\n PDFString,\n PDFStream,\n PDFAcroListBox,\n AcroChoiceFlags,\n PDFWidgetAnnotation,\n} from 'src/core';\nimport {\n assertIs,\n assertIsSubset,\n assertOrUndefined,\n assertPositive,\n} from 'src/utils';\n\n/**\n * Represents an option list field of a [[PDFForm]].\n *\n * [[PDFOptionList]] fields are interactive lists of options. The purpose of an\n * option list is to enable users to select one or more options from a set of\n * possible options. Users are able to see the full set of options without\n * first having to click on the field (though scrolling may be necessary).\n * Clicking an option in the list will cause it to be selected and displayed\n * with a highlighted background. Some option lists allow users to select\n * more than one option (see [[PDFOptionList.isMultiselect]]).\n */\nexport default class PDFOptionList extends PDFField {\n /**\n * > **NOTE:** You probably don't want to call this method directly. Instead,\n * > consider using the [[PDFForm.getOptionList]] method, which will create\n * > an instance of [[PDFOptionList]] for you.\n *\n * Create an instance of [[PDFOptionList]] from an existing acroListBox and\n * ref\n *\n * @param acroComboBox The underlying `PDFAcroListBox` for this option list.\n * @param ref The unique reference for this option list.\n * @param doc The document to which this option list will belong.\n */\n static of = (acroListBox: PDFAcroListBox, ref: PDFRef, doc: PDFDocument) =>\n new PDFOptionList(acroListBox, ref, doc);\n\n /** The low-level PDFAcroListBox wrapped by this option list. */\n readonly acroField: PDFAcroListBox;\n\n private constructor(\n acroListBox: PDFAcroListBox,\n ref: PDFRef,\n doc: PDFDocument,\n ) {\n super(acroListBox, ref, doc);\n\n assertIs(acroListBox, 'acroListBox', [[PDFAcroListBox, 'PDFAcroListBox']]);\n\n this.acroField = acroListBox;\n }\n\n /**\n * Get the list of available options for this option list. These options will\n * be displayed to users who view this option list in a PDF reader.\n * For example:\n * ```js\n * const optionList = form.getOptionList('some.optionList.field')\n * const options = optionList.getOptions()\n * console.log('Option List options:', options)\n * ```\n * @returns The options for this option list.\n */\n getOptions(): string[] {\n const rawOptions = this.acroField.getOptions();\n\n const options = new Array(rawOptions.length);\n for (let idx = 0, len = options.length; idx < len; idx++) {\n const { display, value } = rawOptions[idx];\n options[idx] = (display ?? value).decodeText();\n }\n\n return options;\n }\n\n /**\n * Get the selected options for this option list. These are the values that\n * were selected by a human user via a PDF reader, or programatically via\n * software.\n * For example:\n * ```js\n * const optionList = form.getOptionList('some.optionList.field')\n * const selections = optionList.getSelected()\n * console.log('Option List selections:', selections)\n * ```\n * @returns The selected options for this option list.\n */\n getSelected(): string[] {\n const values = this.acroField.getValues();\n\n const selected = new Array(values.length);\n for (let idx = 0, len = values.length; idx < len; idx++) {\n selected[idx] = values[idx].decodeText();\n }\n\n return selected;\n }\n\n /**\n * Set the list of options that are available for this option list. These are\n * the values that will be available for users to select when they view this\n * option list in a PDF reader. Note that preexisting options for this\n * option list will be removed. Only the values passed as `options` will be\n * available to select.\n *\n * For example:\n * ```js\n * const optionList = form.getOptionList('planets.optionList')\n * optionList.setOptions(['Earth', 'Mars', 'Pluto', 'Venus'])\n * ```\n *\n * This method will mark this option list as dirty, causing its appearance\n * streams to be updated when either [[PDFDocument.save]] or\n * [[PDFForm.updateFieldAppearances]] is called. The updated streams will\n * display the options this field contains inside the widgets of this text\n * field (with selected options highlighted).\n *\n * **IMPORTANT:** The default font used to update appearance streams is\n * [[StandardFonts.Helvetica]]. Note that this is a WinAnsi font. This means\n * that encoding errors will be thrown if this field contains any options\n * with characters outside the WinAnsi character set (the latin alphabet).\n *\n * Embedding a custom font and passing it to\n * [[PDFForm.updateFieldAppearances]] or [[PDFOptionList.updateAppearances]]\n * allows you to generate appearance streams with characters outside the\n * latin alphabet (assuming the custom font supports them).\n *\n * @param options The options that should be available in this option list.\n */\n setOptions(options: string[]) {\n assertIs(options, 'options', [Array]);\n\n this.markAsDirty();\n const optionObjects = new Array<{ value: PDFHexString }>(options.length);\n for (let idx = 0, len = options.length; idx < len; idx++) {\n optionObjects[idx] = { value: PDFHexString.fromText(options[idx]) };\n }\n this.acroField.setOptions(optionObjects);\n }\n\n /**\n * Add to the list of options that are available for this option list. Users\n * will be able to select these values in a PDF reader. In addition to the\n * values passed as `options`, any preexisting options for this option list\n * will still be available for users to select.\n * For example:\n * ```js\n * const optionList = form.getOptionList('rockets.optionList')\n * optionList.addOptions(['Saturn IV', 'Falcon Heavy'])\n * ```\n * This method will mark this option list as dirty. See\n * [[PDFOptionList.setOptions]] for more details about what this means.\n * @param options New options that should be available in this option list.\n */\n addOptions(options: string | string[]) {\n assertIs(options, 'options', ['string', Array]);\n\n this.markAsDirty();\n\n const optionsArr = Array.isArray(options) ? options : [options];\n\n const existingOptions: {\n value: PDFString | PDFHexString;\n display?: PDFString | PDFHexString;\n }[] = this.acroField.getOptions();\n\n const newOptions = new Array<{ value: PDFHexString }>(optionsArr.length);\n for (let idx = 0, len = optionsArr.length; idx < len; idx++) {\n newOptions[idx] = { value: PDFHexString.fromText(optionsArr[idx]) };\n }\n\n this.acroField.setOptions(existingOptions.concat(newOptions));\n }\n\n /**\n * Select one or more values for this option list. This operation is analogous\n * to a human user opening the option list in a PDF reader and clicking on one\n * or more values to select them. This method will update the underlying state\n * of the option list to indicate which values have been selected. PDF\n * libraries and readers will be able to extract these values from the saved\n * document and determine which values were selected.\n * For example:\n * ```js\n * const optionList = form.getOptionList('best.superheroes.optionList')\n * optionList.select(['One Punch Man', 'Iron Man'])\n * ```\n * This method will mark this option list as dirty. See\n * [[PDFOptionList.setOptions]] for more details about what this means.\n * @param options The options to be selected.\n * @param merge Whether or not existing selections should be preserved.\n */\n select(options: string | string[], merge = false) {\n assertIs(options, 'options', ['string', Array]);\n assertIs(merge, 'merge', ['boolean']);\n\n const optionsArr = Array.isArray(options) ? options : [options];\n\n const validOptions = this.getOptions();\n assertIsSubset(optionsArr, 'option', validOptions);\n\n this.markAsDirty();\n\n if (optionsArr.length > 1 || (optionsArr.length === 1 && merge)) {\n this.enableMultiselect();\n }\n\n const values = new Array(optionsArr.length);\n for (let idx = 0, len = optionsArr.length; idx < len; idx++) {\n values[idx] = PDFHexString.fromText(optionsArr[idx]);\n }\n\n if (merge) {\n const existingValues = this.acroField.getValues();\n this.acroField.setValues(existingValues.concat(values));\n } else {\n this.acroField.setValues(values);\n }\n }\n\n /**\n * Clear all selected values for this option list. This operation is\n * equivalent to selecting an empty list. This method will update the\n * underlying state of the option list to indicate that no values have been\n * selected.\n * For example:\n * ```js\n * const optionList = form.getOptionList('some.optionList.field')\n * optionList.clear()\n * ```\n * This method will mark this option list as dirty. See\n * [[PDFOptionList.setOptions]] for more details about what this means.\n */\n clear() {\n this.markAsDirty();\n this.acroField.setValues([]);\n }\n\n /**\n * Set the font size for the text in this field. There needs to be a\n * default appearance string (DA) set with a font value specified\n * for this to work. For example:\n * ```js\n * const optionList = form.getOptionList('some.optionList.field')\n * optionList.setFontSize(4);\n * ```\n * @param fontSize The font size to set the font to.\n */\n\n /**\n * Set the font size for this field. Larger font sizes will result in larger\n * text being displayed when PDF readers render this option list. Font sizes\n * may be integer or floating point numbers. Supplying a negative font size\n * will cause this method to throw an error.\n *\n * For example:\n * ```js\n * const optionList = form.getOptionList('some.optionList.field')\n * optionList.setFontSize(4)\n * optionList.setFontSize(15.7)\n * ```\n *\n * > This method depends upon the existence of a default appearance\n * > (`/DA`) string. If this field does not have a default appearance string,\n * > or that string does not contain a font size (via the `Tf` operator),\n * > then this method will throw an error.\n *\n * @param fontSize The font size to be used when rendering text in this field.\n */\n setFontSize(fontSize: number) {\n assertPositive(fontSize, 'fontSize');\n this.acroField.setFontSize(fontSize);\n this.markAsDirty();\n }\n\n /**\n * Returns `true` if the options of this option list are always displayed\n * in alphabetical order, irrespective of the order in which the options\n * were added to the option list. See [[PDFOptionList.enableSorting]] and\n * [[PDFOptionList.disableSorting]]. For example:\n * ```js\n * const optionList = form.getOptionList('some.optionList.field')\n * if (optionList.isSorted()) console.log('Sorting is enabled')\n * ```\n * @returns Whether or not this option list is sorted.\n */\n isSorted(): boolean {\n return this.acroField.hasFlag(AcroChoiceFlags.Sort);\n }\n\n /**\n * Always display the options of this option list in alphabetical order,\n * irrespective of the order in which the options were added to this option\n * list.\n * For example:\n * ```js\n * const optionList = form.getOptionList('some.optionList.field')\n * optionList.enableSorting()\n * ```\n */\n enableSorting() {\n this.acroField.setFlagTo(AcroChoiceFlags.Sort, true);\n }\n\n /**\n * Do not always display the options of this option list in alphabetical\n * order. Instead, display the options in whichever order they were added\n * to this option list. For example:\n * ```js\n * const optionList = form.getOptionList('some.optionList.field')\n * optionList.disableSorting()\n * ```\n */\n disableSorting() {\n this.acroField.setFlagTo(AcroChoiceFlags.Sort, false);\n }\n\n /**\n * Returns `true` if multiple options can be selected from this option list.\n * See [[PDFOptionList.enableMultiselect]] and\n * [[PDFOptionList.disableMultiselect]]. For example:\n * ```js\n * const optionList = form.getOptionList('some.optionList.field')\n * if (optionList.isMultiselect()) console.log('Multiselect is enabled')\n * ```\n * @returns Whether or not multiple options can be selected.\n */\n isMultiselect(): boolean {\n return this.acroField.hasFlag(AcroChoiceFlags.MultiSelect);\n }\n\n /**\n * Allow users to select more than one option from this option list.\n * For example:\n * ```js\n * const optionList = form.getOptionList('some.optionList.field')\n * optionList.enableMultiselect()\n * ```\n */\n enableMultiselect() {\n this.acroField.setFlagTo(AcroChoiceFlags.MultiSelect, true);\n }\n\n /**\n * Do not allow users to select more than one option from this option list.\n * For example:\n * ```js\n * const optionList = form.getOptionList('some.optionList.field')\n * optionList.disableMultiselect()\n * ```\n */\n disableMultiselect() {\n this.acroField.setFlagTo(AcroChoiceFlags.MultiSelect, false);\n }\n\n /**\n * Returns `true` if the option selected by a user is stored, or \"committed\",\n * when the user clicks the option. The alternative is that the user's\n * selection is stored when the user leaves this option list field (by\n * clicking outside of it - on another field, for example). See\n * [[PDFOptionList.enableSelectOnClick]] and\n * [[PDFOptionList.disableSelectOnClick]]. For example:\n * ```js\n * const optionList = form.getOptionList('some.optionList.field')\n * if (optionList.isSelectOnClick()) console.log('Select on click is enabled')\n * ```\n * @returns Whether or not options are selected immediately after they are\n * clicked.\n */\n isSelectOnClick(): boolean {\n return this.acroField.hasFlag(AcroChoiceFlags.CommitOnSelChange);\n }\n\n /**\n * Store the option selected by a user immediately after the user clicks the\n * option. Do not wait for the user to leave this option list field (by\n * clicking outside of it - on another field, for example). For example:\n * ```js\n * const optionList = form.getOptionList('some.optionList.field')\n * optionList.enableSelectOnClick()\n * ```\n */\n enableSelectOnClick() {\n this.acroField.setFlagTo(AcroChoiceFlags.CommitOnSelChange, true);\n }\n\n /**\n * Wait to store the option selected by a user until they leave this option\n * list field (by clicking outside of it - on another field, for example).\n * For example:\n * ```js\n * const optionList = form.getOptionList('some.optionList.field')\n * optionList.disableSelectOnClick()\n * ```\n */\n disableSelectOnClick() {\n this.acroField.setFlagTo(AcroChoiceFlags.CommitOnSelChange, false);\n }\n\n /**\n * Show this option list on the specified page. For example:\n * ```js\n * const ubuntuFont = await pdfDoc.embedFont(ubuntuFontBytes)\n * const page = pdfDoc.addPage()\n *\n * const form = pdfDoc.getForm()\n * const optionList = form.createOptionList('best.gundams')\n * optionList.setOptions(['Exia', 'Dynames', 'Kyrios', 'Virtue'])\n * optionList.select(['Exia', 'Virtue'])\n *\n * optionList.addToPage(page, {\n * x: 50,\n * y: 75,\n * width: 200,\n * height: 100,\n * textColor: rgb(1, 0, 0),\n * backgroundColor: rgb(0, 1, 0),\n * borderColor: rgb(0, 0, 1),\n * borderWidth: 2,\n * rotate: degrees(90),\n * font: ubuntuFont,\n * })\n * ```\n * This will create a new widget for this option list field.\n * @param page The page to which this option list widget should be added.\n * @param options The options to be used when adding this option list widget.\n */\n addToPage(page: PDFPage, options?: FieldAppearanceOptions) {\n assertIs(page, 'page', [[PDFPage, 'PDFPage']]);\n assertFieldAppearanceOptions(options);\n\n if (!options) options = {};\n\n if (!('textColor' in options)) options.textColor = rgb(0, 0, 0);\n if (!('backgroundColor' in options)) options.backgroundColor = rgb(1, 1, 1);\n if (!('borderColor' in options)) options.borderColor = rgb(0, 0, 0);\n if (!('borderWidth' in options)) options.borderWidth = 1;\n\n // Create a widget for this option list\n const widget = this.createWidget({\n x: options.x ?? 0,\n y: options.y ?? 0,\n width: options.width ?? 200,\n height: options.height ?? 100,\n textColor: options.textColor,\n backgroundColor: options.backgroundColor,\n borderColor: options.borderColor,\n borderWidth: options.borderWidth ?? 0,\n rotate: options.rotate ?? degrees(0),\n hidden: options.hidden,\n page: page.ref,\n });\n const widgetRef = this.doc.context.register(widget.dict);\n\n // Add widget to this field\n this.acroField.addWidget(widgetRef);\n\n // Set appearance streams for widget\n const font = options.font ?? this.doc.getForm().getDefaultFont();\n this.updateWidgetAppearance(widget, font);\n\n // Add widget to the given page\n page.node.addAnnot(widgetRef);\n }\n\n /**\n * Returns `true` if this option list has been marked as dirty, or if any of\n * this option list's widgets do not have an appearance stream. For example:\n * ```js\n * const optionList = form.getOptionList('some.optionList.field')\n * if (optionList.needsAppearancesUpdate()) console.log('Needs update')\n * ```\n * @returns Whether or not this option list needs an appearance update.\n */\n needsAppearancesUpdate(): boolean {\n if (this.isDirty()) return true;\n\n const widgets = this.acroField.getWidgets();\n for (let idx = 0, len = widgets.length; idx < len; idx++) {\n const widget = widgets[idx];\n const hasAppearances =\n widget.getAppearances()?.normal instanceof PDFStream;\n if (!hasAppearances) return true;\n }\n\n return false;\n }\n\n /**\n * Update the appearance streams for each of this option list's widgets using\n * the default appearance provider for option lists. For example:\n * ```js\n * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const optionList = form.getOptionList('some.optionList.field')\n * optionList.defaultUpdateAppearances(helvetica)\n * ```\n * @param font The font to be used for creating the appearance streams.\n */\n defaultUpdateAppearances(font: PDFFont) {\n assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n this.updateAppearances(font);\n }\n\n /**\n * Update the appearance streams for each of this option list's widgets using\n * the given appearance provider. If no `provider` is passed, the default\n * appearance provider for option lists will be used. For example:\n * ```js\n * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const optionList = form.getOptionList('some.optionList.field')\n * optionList.updateAppearances(helvetica, (field, widget, font) => {\n * ...\n * return drawOptionList(...)\n * })\n * ```\n * @param font The font to be used for creating the appearance streams.\n * @param provider Optionally, the appearance provider to be used for\n * generating the contents of the appearance streams.\n */\n updateAppearances(\n font: PDFFont,\n provider?: AppearanceProviderFor,\n ) {\n assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n assertOrUndefined(provider, 'provider', [Function]);\n\n const widgets = this.acroField.getWidgets();\n for (let idx = 0, len = widgets.length; idx < len; idx++) {\n const widget = widgets[idx];\n this.updateWidgetAppearance(widget, font, provider);\n }\n this.markAsClean();\n }\n\n // getOption(index: number): string {}\n // getSelectedIndices(): number[] {}\n // removeOptions(option: string | string[]) {}\n // removeIndices(option: number[]) {}\n // deselect(options: string | string[]) {}\n // deselectIndices(optionIndices: number[]) {}\n\n private updateWidgetAppearance(\n widget: PDFWidgetAnnotation,\n font: PDFFont,\n provider?: AppearanceProviderFor,\n ) {\n const apProvider = provider ?? defaultOptionListAppearanceProvider;\n const appearances = normalizeAppearance(apProvider(this, widget, font));\n this.updateWidgetAppearanceWithFont(widget, font, appearances);\n }\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFPage from 'src/api/PDFPage';\nimport PDFField, {\n FieldAppearanceOptions,\n assertFieldAppearanceOptions,\n} from 'src/api/form/PDFField';\nimport {\n AppearanceProviderFor,\n normalizeAppearance,\n defaultRadioGroupAppearanceProvider,\n} from 'src/api/form/appearances';\nimport { rgb } from 'src/api/colors';\nimport { degrees } from 'src/api/rotations';\n\nimport {\n PDFName,\n PDFRef,\n PDFHexString,\n PDFDict,\n PDFWidgetAnnotation,\n PDFAcroRadioButton,\n AcroButtonFlags,\n} from 'src/core';\nimport { assertIs, assertOrUndefined, assertIsOneOf } from 'src/utils';\n\n/**\n * Represents a radio group field of a [[PDFForm]].\n *\n * [[PDFRadioGroup]] fields are collections of radio buttons. The purpose of a\n * radio group is to enable users to select one option from a set of mutually\n * exclusive choices. Each choice in a radio group is represented by a radio\n * button. Radio buttons each have two states: `on` and `off`. At most one\n * radio button in a group may be in the `on` state at any time. Users can\n * click on a radio button to select it (and thereby automatically deselect any\n * other radio button that might have already been selected). Some radio\n * groups allow users to toggle a selected radio button `off` by clicking on\n * it (see [[PDFRadioGroup.isOffToggleable]]).\n *\n * Note that some radio groups allow multiple radio buttons to be in the `on`\n * state at the same type **if** they represent the same underlying value (see\n * [[PDFRadioGroup.isMutuallyExclusive]]).\n */\nexport default class PDFRadioGroup extends PDFField {\n /**\n * > **NOTE:** You probably don't want to call this method directly. Instead,\n * > consider using the [[PDFForm.getOptionList]] method, which will create an\n * > instance of [[PDFOptionList]] for you.\n *\n * Create an instance of [[PDFOptionList]] from an existing acroRadioButton\n * and ref\n *\n * @param acroRadioButton The underlying `PDFAcroRadioButton` for this\n * radio group.\n * @param ref The unique reference for this radio group.\n * @param doc The document to which this radio group will belong.\n */\n static of = (\n acroRadioButton: PDFAcroRadioButton,\n ref: PDFRef,\n doc: PDFDocument,\n ) => new PDFRadioGroup(acroRadioButton, ref, doc);\n\n /** The low-level PDFAcroRadioButton wrapped by this radio group. */\n readonly acroField: PDFAcroRadioButton;\n\n private constructor(\n acroRadioButton: PDFAcroRadioButton,\n ref: PDFRef,\n doc: PDFDocument,\n ) {\n super(acroRadioButton, ref, doc);\n\n assertIs(acroRadioButton, 'acroRadioButton', [\n [PDFAcroRadioButton, 'PDFAcroRadioButton'],\n ]);\n\n this.acroField = acroRadioButton;\n }\n\n /**\n * Get the list of available options for this radio group. Each option is\n * represented by a radio button. These radio buttons are displayed at\n * various locations in the document, potentially on different pages (though\n * typically they are stacked horizontally or vertically on the same page).\n * For example:\n * ```js\n * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n * const options = radioGroup.getOptions()\n * console.log('Radio Group options:', options)\n * ```\n * @returns The options for this radio group.\n */\n getOptions(): string[] {\n const exportValues = this.acroField.getExportValues();\n if (exportValues) {\n const exportOptions = new Array(exportValues.length);\n for (let idx = 0, len = exportValues.length; idx < len; idx++) {\n exportOptions[idx] = exportValues[idx].decodeText();\n }\n return exportOptions;\n }\n\n const onValues = this.acroField.getOnValues();\n const onOptions = new Array(onValues.length);\n for (let idx = 0, len = onOptions.length; idx < len; idx++) {\n onOptions[idx] = onValues[idx].decodeText();\n }\n return onOptions;\n }\n\n /**\n * Get the selected option for this radio group. The selected option is\n * represented by the radio button in this group that is turned on. At most\n * one radio button in a group can be selected. If no buttons in this group\n * are selected, `undefined` is returned.\n * For example:\n * ```js\n * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n * const selected = radioGroup.getSelected()\n * console.log('Selected radio button:', selected)\n * ```\n * @returns The selected option for this radio group.\n */\n getSelected(): string | undefined {\n const value = this.acroField.getValue();\n if (value === PDFName.of('Off')) return undefined;\n const exportValues = this.acroField.getExportValues();\n if (exportValues) {\n const onValues = this.acroField.getOnValues();\n for (let idx = 0, len = onValues.length; idx < len; idx++) {\n if (onValues[idx] === value) return exportValues[idx].decodeText();\n }\n }\n return value.decodeText();\n }\n\n // // TODO: Figure out why this seems to crash Acrobat. Maybe it's because we\n // // aren't removing the widget reference from the page's Annots?\n // removeOption(option: string) {\n // assertIs(option, 'option', ['string']);\n // // TODO: Assert is valid `option`!\n\n // const onValues = this.acroField.getOnValues();\n // const exportValues = this.acroField.getExportValues();\n // if (exportValues) {\n // for (let idx = 0, len = exportValues.length; idx < len; idx++) {\n // if (exportValues[idx].decodeText() === option) {\n // this.acroField.removeWidget(idx);\n // this.acroField.removeExportValue(idx);\n // }\n // }\n // } else {\n // for (let idx = 0, len = onValues.length; idx < len; idx++) {\n // const value = onValues[idx];\n // if (value.decodeText() === option) {\n // this.acroField.removeWidget(idx);\n // this.acroField.removeExportValue(idx);\n // }\n // }\n // }\n // }\n\n /**\n * Select an option for this radio group. This operation is analogous to a\n * human user clicking one of the radio buttons in this group via a PDF\n * reader to toggle it on. This method will update the underlying state of\n * the radio group to indicate which option has been selected. PDF libraries\n * and readers will be able to extract this value from the saved document and\n * determine which option was selected.\n *\n * For example:\n * ```js\n * const radioGroup = form.getRadioGroup('best.superhero.radioGroup')\n * radioGroup.select('One Punch Man')\n * ```\n *\n * This method will mark this radio group as dirty, causing its appearance\n * streams to be updated when either [[PDFDocument.save]] or\n * [[PDFForm.updateFieldAppearances]] is called. The updated appearance\n * streams will display a dot inside the widget of this check box field\n * that represents the selected option.\n *\n * @param option The option to be selected.\n */\n select(option: string) {\n assertIs(option, 'option', ['string']);\n\n const validOptions = this.getOptions();\n assertIsOneOf(option, 'option', validOptions);\n\n this.markAsDirty();\n\n const onValues = this.acroField.getOnValues();\n const exportValues = this.acroField.getExportValues();\n if (exportValues) {\n for (let idx = 0, len = exportValues.length; idx < len; idx++) {\n if (exportValues[idx].decodeText() === option) {\n this.acroField.setValue(onValues[idx]);\n }\n }\n } else {\n for (let idx = 0, len = onValues.length; idx < len; idx++) {\n const value = onValues[idx];\n if (value.decodeText() === option) this.acroField.setValue(value);\n }\n }\n }\n\n /**\n * Clear any selected option for this dropdown. This will result in all\n * radio buttons in this group being toggled off. This method will update\n * the underlying state of the dropdown to indicate that no radio buttons\n * have been selected.\n * For example:\n * ```js\n * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n * radioGroup.clear()\n * ```\n * This method will mark this radio group as dirty. See\n * [[PDFRadioGroup.select]] for more details about what this means.\n */\n clear() {\n this.markAsDirty();\n this.acroField.setValue(PDFName.of('Off'));\n }\n\n /**\n * Returns `true` if users can click on radio buttons in this group to toggle\n * them off. The alternative is that once a user clicks on a radio button\n * to select it, the only way to deselect it is by selecting on another radio\n * button in the group. See [[PDFRadioGroup.enableOffToggling]] and\n * [[PDFRadioGroup.disableOffToggling]]. For example:\n * ```js\n * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n * if (radioGroup.isOffToggleable()) console.log('Off toggling is enabled')\n * ```\n */\n isOffToggleable() {\n return !this.acroField.hasFlag(AcroButtonFlags.NoToggleToOff);\n }\n\n /**\n * Allow users to click on selected radio buttons in this group to toggle\n * them off. For example:\n * ```js\n * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n * radioGroup.enableOffToggling()\n * ```\n * > **NOTE:** This feature is documented in the PDF specification\n * > (Table 226). However, most PDF readers do not respect this option and\n * > prevent users from toggling radio buttons off even when it is enabled.\n * > At the time of this writing (9/6/2020) Mac's Preview software did\n * > respect the option. Adobe Acrobat, Foxit Reader, and Google Chrome did\n * > not.\n */\n enableOffToggling() {\n this.acroField.setFlagTo(AcroButtonFlags.NoToggleToOff, false);\n }\n\n /**\n * Prevent users from clicking on selected radio buttons in this group to\n * toggle them off. Clicking on a selected radio button will have no effect.\n * The only way to deselect a selected radio button is to click on a\n * different radio button in the group. For example:\n * ```js\n * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n * radioGroup.disableOffToggling()\n * ```\n */\n disableOffToggling() {\n this.acroField.setFlagTo(AcroButtonFlags.NoToggleToOff, true);\n }\n\n /**\n * Returns `true` if the radio buttons in this group are mutually exclusive.\n * This means that when the user selects a radio button, only that specific\n * button will be turned on. Even if other radio buttons in the group\n * represent the same value, they will not be enabled. The alternative to\n * this is that clicking a radio button will select that button along with\n * any other radio buttons in the group that share the same value. See\n * [[PDFRadioGroup.enableMutualExclusion]] and\n * [[PDFRadioGroup.disableMutualExclusion]].\n * For example:\n * ```js\n * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n * if (radioGroup.isMutuallyExclusive()) console.log('Mutual exclusion is enabled')\n * ```\n */\n isMutuallyExclusive() {\n return !this.acroField.hasFlag(AcroButtonFlags.RadiosInUnison);\n }\n\n /**\n * When the user clicks a radio button in this group it will be selected. In\n * addition, any other radio buttons in this group that share the same\n * underlying value will also be selected. For example:\n * ```js\n * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n * radioGroup.enableMutualExclusion()\n * ```\n * Note that this option must be enabled prior to adding options to the\n * radio group. It does not currently apply retroactively to existing\n * radio buttons in the group.\n */\n enableMutualExclusion() {\n this.acroField.setFlagTo(AcroButtonFlags.RadiosInUnison, false);\n }\n\n /**\n * When the user clicks a radio button in this group only it will be selected.\n * No other radio buttons in the group will be selected, even if they share\n * the same underlying value. For example:\n * ```js\n * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n * radioGroup.disableMutualExclusion()\n * ```\n * Note that this option must be disabled prior to adding options to the\n * radio group. It does not currently apply retroactively to existing\n * radio buttons in the group.\n */\n disableMutualExclusion() {\n this.acroField.setFlagTo(AcroButtonFlags.RadiosInUnison, true);\n }\n\n /**\n * Add a new radio button to this group on the specified page. For example:\n * ```js\n * const page = pdfDoc.addPage()\n *\n * const form = pdfDoc.getForm()\n * const radioGroup = form.createRadioGroup('best.gundam')\n *\n * const options = {\n * x: 50,\n * width: 25,\n * height: 25,\n * textColor: rgb(1, 0, 0),\n * backgroundColor: rgb(0, 1, 0),\n * borderColor: rgb(0, 0, 1),\n * borderWidth: 2,\n * rotate: degrees(90),\n * }\n *\n * radioGroup.addOptionToPage('Exia', page, { ...options, y: 50 })\n * radioGroup.addOptionToPage('Dynames', page, { ...options, y: 110 })\n * ```\n * This will create a new radio button widget for this radio group field.\n * @param option The option that the radio button widget represents.\n * @param page The page to which the radio button widget should be added.\n * @param options The options to be used when adding the radio button widget.\n */\n addOptionToPage(\n option: string,\n page: PDFPage,\n options?: FieldAppearanceOptions,\n ) {\n assertIs(option, 'option', ['string']);\n assertIs(page, 'page', [[PDFPage, 'PDFPage']]);\n assertFieldAppearanceOptions(options);\n\n // Create a widget for this radio button\n const widget = this.createWidget({\n x: options?.x ?? 0,\n y: options?.y ?? 0,\n width: options?.width ?? 50,\n height: options?.height ?? 50,\n textColor: options?.textColor ?? rgb(0, 0, 0),\n backgroundColor: options?.backgroundColor ?? rgb(1, 1, 1),\n borderColor: options?.borderColor ?? rgb(0, 0, 0),\n borderWidth: options?.borderWidth ?? 1,\n rotate: options?.rotate ?? degrees(0),\n hidden: options?.hidden,\n page: page.ref,\n });\n const widgetRef = this.doc.context.register(widget.dict);\n\n // Add widget to this field\n const apStateValue = this.acroField.addWidgetWithOpt(\n widgetRef,\n PDFHexString.fromText(option),\n !this.isMutuallyExclusive(),\n );\n\n // Set appearance streams for widget\n widget.setAppearanceState(PDFName.of('Off'));\n this.updateWidgetAppearance(widget, apStateValue);\n\n // Add widget to the given page\n page.node.addAnnot(widgetRef);\n }\n\n /**\n * Returns `true` if any of this group's radio button widgets do not have an\n * appearance stream for their current state. For example:\n * ```js\n * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n * if (radioGroup.needsAppearancesUpdate()) console.log('Needs update')\n * ```\n * @returns Whether or not this radio group needs an appearance update.\n */\n needsAppearancesUpdate(): boolean {\n const widgets = this.acroField.getWidgets();\n for (let idx = 0, len = widgets.length; idx < len; idx++) {\n const widget = widgets[idx];\n const state = widget.getAppearanceState();\n const normal = widget.getAppearances()?.normal;\n\n if (!(normal instanceof PDFDict)) return true;\n if (state && !normal.has(state)) return true;\n }\n\n return false;\n }\n\n /**\n * Update the appearance streams for each of this group's radio button widgets\n * using the default appearance provider for radio groups. For example:\n * ```js\n * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n * radioGroup.defaultUpdateAppearances()\n * ```\n */\n defaultUpdateAppearances() {\n this.updateAppearances();\n }\n\n // rg.updateAppearances((field: any, widget: any) => {\n // assert(field === rg);\n // assert(widget instanceof PDFWidgetAnnotation);\n // return { on: [...rectangle, ...circle], off: [...rectangle, ...circle] };\n // });\n\n /**\n * Update the appearance streams for each of this group's radio button widgets\n * using the given appearance provider. If no `provider` is passed, the\n * default appearance provider for radio groups will be used. For example:\n * ```js\n * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n * radioGroup.updateAppearances((field, widget) => {\n * ...\n * return {\n * normal: { on: drawRadioButton(...), off: drawRadioButton(...) },\n * down: { on: drawRadioButton(...), off: drawRadioButton(...) },\n * }\n * })\n * ```\n * @param provider Optionally, the appearance provider to be used for\n * generating the contents of the appearance streams.\n */\n updateAppearances(provider?: AppearanceProviderFor) {\n assertOrUndefined(provider, 'provider', [Function]);\n\n const widgets = this.acroField.getWidgets();\n for (let idx = 0, len = widgets.length; idx < len; idx++) {\n const widget = widgets[idx];\n const onValue = widget.getOnValue();\n if (!onValue) continue;\n this.updateWidgetAppearance(widget, onValue, provider);\n }\n }\n\n private updateWidgetAppearance(\n widget: PDFWidgetAnnotation,\n onValue: PDFName,\n provider?: AppearanceProviderFor,\n ) {\n const apProvider = provider ?? defaultRadioGroupAppearanceProvider;\n const appearances = normalizeAppearance(apProvider(this, widget));\n this.updateOnOffWidgetAppearance(widget, onValue, appearances);\n }\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFField from 'src/api/form/PDFField';\n\nimport { PDFRef, PDFAcroSignature } from 'src/core';\nimport { assertIs } from 'src/utils';\n\n/**\n * Represents a signature field of a [[PDFForm]].\n *\n * [[PDFSignature]] fields are digital signatures. `pdf-lib` does not\n * currently provide any specialized APIs for creating digital signatures or\n * reading the contents of existing digital signatures.\n */\nexport default class PDFSignature extends PDFField {\n /**\n * > **NOTE:** You probably don't want to call this method directly. Instead,\n * > consider using the [[PDFForm.getSignature]] method, which will create an\n * > instance of [[PDFSignature]] for you.\n *\n * Create an instance of [[PDFSignature]] from an existing acroSignature and\n * ref\n *\n * @param acroSignature The underlying `PDFAcroSignature` for this signature.\n * @param ref The unique reference for this signature.\n * @param doc The document to which this signature will belong.\n */\n static of = (\n acroSignature: PDFAcroSignature,\n ref: PDFRef,\n doc: PDFDocument,\n ) => new PDFSignature(acroSignature, ref, doc);\n\n /** The low-level PDFAcroSignature wrapped by this signature. */\n readonly acroField: PDFAcroSignature;\n\n private constructor(\n acroSignature: PDFAcroSignature,\n ref: PDFRef,\n doc: PDFDocument,\n ) {\n super(acroSignature, ref, doc);\n\n assertIs(acroSignature, 'acroSignature', [\n [PDFAcroSignature, 'PDFAcroSignature'],\n ]);\n\n this.acroField = acroSignature;\n }\n\n needsAppearancesUpdate() {\n return false;\n }\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFPage from 'src/api/PDFPage';\nimport PDFFont from 'src/api/PDFFont';\nimport PDFImage from 'src/api/PDFImage';\nimport PDFField, {\n FieldAppearanceOptions,\n assertFieldAppearanceOptions,\n} from 'src/api/form/PDFField';\nimport {\n AppearanceProviderFor,\n normalizeAppearance,\n defaultTextFieldAppearanceProvider,\n} from 'src/api/form/appearances';\nimport { rgb } from 'src/api/colors';\nimport { degrees } from 'src/api/rotations';\nimport {\n RichTextFieldReadError,\n ExceededMaxLengthError,\n InvalidMaxLengthError,\n} from 'src/api/errors';\nimport { ImageAlignment } from 'src/api/image/alignment';\nimport { TextAlignment } from 'src/api/text/alignment';\n\nimport {\n PDFHexString,\n PDFRef,\n PDFStream,\n PDFAcroText,\n AcroTextFlags,\n PDFWidgetAnnotation,\n} from 'src/core';\nimport {\n assertIs,\n assertIsOneOf,\n assertOrUndefined,\n assertPositive,\n assertRangeOrUndefined,\n} from 'src/utils';\n\n/**\n * Represents a text field of a [[PDFForm]].\n *\n * [[PDFTextField]] fields are boxes that display text entered by the user. The\n * purpose of a text field is to enable users to enter text or view text values\n * in the document prefilled by software. Users can click on a text field and\n * input text via their keyboard. Some text fields allow multiple lines of text\n * to be entered (see [[PDFTextField.isMultiline]]).\n */\nexport default class PDFTextField extends PDFField {\n /**\n * > **NOTE:** You probably don't want to call this method directly. Instead,\n * > consider using the [[PDFForm.getTextField]] method, which will create an\n * > instance of [[PDFTextField]] for you.\n *\n * Create an instance of [[PDFTextField]] from an existing acroText and ref\n *\n * @param acroText The underlying `PDFAcroText` for this text field.\n * @param ref The unique reference for this text field.\n * @param doc The document to which this text field will belong.\n */\n static of = (acroText: PDFAcroText, ref: PDFRef, doc: PDFDocument) =>\n new PDFTextField(acroText, ref, doc);\n\n /** The low-level PDFAcroText wrapped by this text field. */\n readonly acroField: PDFAcroText;\n\n private constructor(acroText: PDFAcroText, ref: PDFRef, doc: PDFDocument) {\n super(acroText, ref, doc);\n\n assertIs(acroText, 'acroText', [[PDFAcroText, 'PDFAcroText']]);\n\n this.acroField = acroText;\n }\n\n /**\n * Get the text that this field contains. This text is visible to users who\n * view this field in a PDF reader.\n *\n * For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * const text = textField.getText()\n * console.log('Text field contents:', text)\n * ```\n *\n * Note that if this text field contains no underlying value, `undefined`\n * will be returned. Text fields may also contain an underlying value that\n * is simply an empty string (`''`). This detail is largely irrelevant for\n * most applications. In general, you'll want to treat both cases the same\n * way and simply consider the text field to be empty. In either case, the\n * text field will appear empty to users when viewed in a PDF reader.\n *\n * An error will be thrown if this is a rich text field. `pdf-lib` does not\n * support reading rich text fields. Nor do most PDF readers and writers.\n * Rich text fields are based on XFA (XML Forms Architecture). Relatively few\n * PDFs use rich text fields or XFA. Unlike PDF itself, XFA is not an ISO\n * standard. XFA has been deprecated in PDF 2.0:\n * * https://en.wikipedia.org/wiki/XFA\n * * http://blog.pdfshareforms.com/pdf-2-0-release-bid-farewell-xfa-forms/\n *\n * @returns The text contained in this text field.\n */\n getText(): string | undefined {\n const value = this.acroField.getValue();\n if (!value && this.isRichFormatted()) {\n throw new RichTextFieldReadError(this.getName());\n }\n return value?.decodeText();\n }\n\n /**\n * Set the text for this field. This operation is analogous to a human user\n * clicking on the text field in a PDF reader and typing in text via their\n * keyboard. This method will update the underlying state of the text field\n * to indicate what text has been set. PDF libraries and readers will be able\n * to extract these values from the saved document and determine what text\n * was set.\n *\n * For example:\n * ```js\n * const textField = form.getTextField('best.superhero.text.field')\n * textField.setText('One Punch Man')\n * ```\n *\n * This method will mark this text field as dirty, causing its appearance\n * streams to be updated when either [[PDFDocument.save]] or\n * [[PDFForm.updateFieldAppearances]] is called. The updated streams will\n * display the text this field contains inside the widgets of this text\n * field.\n *\n * **IMPORTANT:** The default font used to update appearance streams is\n * [[StandardFonts.Helvetica]]. Note that this is a WinAnsi font. This means\n * that encoding errors will be thrown if this field contains text outside\n * the WinAnsi character set (the latin alphabet).\n *\n * Embedding a custom font and passing it to\n * [[PDFForm.updateFieldAppearances]] or [[PDFTextField.updateAppearances]]\n * allows you to generate appearance streams with characters outside the\n * latin alphabet (assuming the custom font supports them).\n *\n * If this is a rich text field, it will be converted to a standard text\n * field in order to set the text. `pdf-lib` does not support writing rich\n * text strings. Nor do most PDF readers and writers. See\n * [[PDFTextField.getText]] for more information about rich text fields and\n * their deprecation in PDF 2.0.\n *\n * @param text The text this field should contain.\n */\n setText(text: string | undefined) {\n assertOrUndefined(text, 'text', ['string']);\n\n const maxLength = this.getMaxLength();\n if (maxLength !== undefined && text && text.length > maxLength) {\n throw new ExceededMaxLengthError(text.length, maxLength, this.getName());\n }\n\n this.markAsDirty();\n this.disableRichFormatting();\n\n if (text) {\n this.acroField.setValue(PDFHexString.fromText(text));\n } else {\n this.acroField.removeValue();\n }\n }\n\n /**\n * Get the alignment for this text field. This value represents the\n * justification of the text when it is displayed to the user in PDF readers.\n * There are three possible alignments: left, center, and right. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * const alignment = textField.getAlignment()\n * if (alignment === TextAlignment.Left) console.log('Text is left justified')\n * if (alignment === TextAlignment.Center) console.log('Text is centered')\n * if (alignment === TextAlignment.Right) console.log('Text is right justified')\n * ```\n * @returns The alignment of this text field.\n */\n getAlignment(): TextAlignment {\n const quadding = this.acroField.getQuadding();\n\n // prettier-ignore\n return (\n quadding === 0 ? TextAlignment.Left\n : quadding === 1 ? TextAlignment.Center\n : quadding === 2 ? TextAlignment.Right\n : TextAlignment.Left\n );\n }\n\n /**\n * Set the alignment for this text field. This will determine the\n * justification of the text when it is displayed to the user in PDF readers.\n * There are three possible alignments: left, center, and right. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n *\n * // Text will be left justified when displayed\n * textField.setAlignment(TextAlignment.Left)\n *\n * // Text will be centered when displayed\n * textField.setAlignment(TextAlignment.Center)\n *\n * // Text will be right justified when displayed\n * textField.setAlignment(TextAlignment.Right)\n * ```\n * This method will mark this text field as dirty. See\n * [[PDFTextField.setText]] for more details about what this means.\n * @param alignment The alignment for this text field.\n */\n setAlignment(alignment: TextAlignment) {\n assertIsOneOf(alignment, 'alignment', TextAlignment);\n this.markAsDirty();\n this.acroField.setQuadding(alignment);\n }\n\n /**\n * Get the maximum length of this field. This value represents the maximum\n * number of characters that can be typed into this field by the user. If\n * this field does not have a maximum length, `undefined` is returned.\n * For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * const maxLength = textField.getMaxLength()\n * if (maxLength === undefined) console.log('No max length')\n * else console.log(`Max length is ${maxLength}`)\n * ```\n * @returns The maximum number of characters allowed in this field, or\n * `undefined` if no limit exists.\n */\n getMaxLength(): number | undefined {\n return this.acroField.getMaxLength();\n }\n\n /**\n * Set the maximum length of this field. This limits the number of characters\n * that can be typed into this field by the user. This also limits the length\n * of the string that can be passed to [[PDFTextField.setText]]. This limit\n * can be removed by passing `undefined` as `maxLength`. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n *\n * // Allow between 0 and 5 characters to be entered\n * textField.setMaxLength(5)\n *\n * // Allow any number of characters to be entered\n * textField.setMaxLength(undefined)\n * ```\n * This method will mark this text field as dirty. See\n * [[PDFTextField.setText]] for more details about what this means.\n * @param maxLength The maximum number of characters allowed in this field, or\n * `undefined` to remove the limit.\n */\n setMaxLength(maxLength?: number) {\n assertRangeOrUndefined(maxLength, 'maxLength', 0, Number.MAX_SAFE_INTEGER);\n\n this.markAsDirty();\n\n if (maxLength === undefined) {\n this.acroField.removeMaxLength();\n } else {\n const text = this.getText();\n if (text && text.length > maxLength) {\n throw new InvalidMaxLengthError(text.length, maxLength, this.getName());\n }\n this.acroField.setMaxLength(maxLength);\n }\n }\n\n /**\n * Remove the maximum length for this text field. This allows any number of\n * characters to be typed into this field by the user. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.removeMaxLength()\n * ```\n * Calling this method is equivalent to passing `undefined` to\n * [[PDFTextField.setMaxLength]].\n */\n removeMaxLength() {\n this.markAsDirty();\n this.acroField.removeMaxLength();\n }\n\n /**\n * Display an image inside the bounds of this text field's widgets. For example:\n * ```js\n * const pngImage = await pdfDoc.embedPng(...)\n * const textField = form.getTextField('some.text.field')\n * textField.setImage(pngImage)\n * ```\n * This will update the appearances streams for each of this text field's widgets.\n * @param image The image that should be displayed.\n */\n setImage(image: PDFImage) {\n const fieldAlignment = this.getAlignment();\n\n // prettier-ignore\n const alignment = \n fieldAlignment === TextAlignment.Center ? ImageAlignment.Center\n : fieldAlignment === TextAlignment.Right ? ImageAlignment.Right\n : ImageAlignment.Left;\n\n const widgets = this.acroField.getWidgets();\n for (let idx = 0, len = widgets.length; idx < len; idx++) {\n const widget = widgets[idx];\n const streamRef = this.createImageAppearanceStream(\n widget,\n image,\n alignment,\n );\n this.updateWidgetAppearances(widget, { normal: streamRef });\n }\n\n this.markAsClean();\n }\n\n /**\n * Set the font size for this field. Larger font sizes will result in larger\n * text being displayed when PDF readers render this text field. Font sizes\n * may be integer or floating point numbers. Supplying a negative font size\n * will cause this method to throw an error.\n *\n * For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.setFontSize(4)\n * textField.setFontSize(15.7)\n * ```\n *\n * > This method depends upon the existence of a default appearance\n * > (`/DA`) string. If this field does not have a default appearance string,\n * > or that string does not contain a font size (via the `Tf` operator),\n * > then this method will throw an error.\n *\n * @param fontSize The font size to be used when rendering text in this field.\n */\n setFontSize(fontSize: number) {\n assertPositive(fontSize, 'fontSize');\n this.acroField.setFontSize(fontSize);\n this.markAsDirty();\n }\n\n /**\n * Returns `true` if each line of text is shown on a new line when this\n * field is displayed in a PDF reader. The alternative is that all lines of\n * text are merged onto a single line when displayed. See\n * [[PDFTextField.enableMultiline]] and [[PDFTextField.disableMultiline]].\n * For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * if (textField.isMultiline()) console.log('Multiline is enabled')\n * ```\n * @returns Whether or not this is a multiline text field.\n */\n isMultiline(): boolean {\n return this.acroField.hasFlag(AcroTextFlags.Multiline);\n }\n\n /**\n * Display each line of text on a new line when this field is displayed in a\n * PDF reader. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.enableMultiline()\n * ```\n * This method will mark this text field as dirty. See\n * [[PDFTextField.setText]] for more details about what this means.\n */\n enableMultiline() {\n this.markAsDirty();\n this.acroField.setFlagTo(AcroTextFlags.Multiline, true);\n }\n\n /**\n * Display each line of text on the same line when this field is displayed\n * in a PDF reader. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.disableMultiline()\n * ```\n * This method will mark this text field as dirty. See\n * [[PDFTextField.setText]] for more details about what this means.\n */\n disableMultiline() {\n this.markAsDirty();\n this.acroField.setFlagTo(AcroTextFlags.Multiline, false);\n }\n\n /**\n * Returns `true` if this is a password text field. This means that the field\n * is intended for storing a secure password. See\n * [[PDFTextField.enablePassword]] and [[PDFTextField.disablePassword]].\n * For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * if (textField.isPassword()) console.log('Password is enabled')\n * ```\n * @returns Whether or not this is a password text field.\n */\n isPassword(): boolean {\n return this.acroField.hasFlag(AcroTextFlags.Password);\n }\n\n /**\n * Indicate that this text field is intended for storing a secure password.\n * For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.enablePassword()\n * ```\n * Values entered into password text fields should not be displayed on the\n * screen by PDF readers. Most PDF readers will display the value as\n * asterisks or bullets. PDF readers should never store values entered by the\n * user into password text fields. Similarly, applications should not\n * write data to a password text field.\n *\n * **Please note that this method does not cause entered values to be\n * encrypted or secured in any way! It simply sets a flag that PDF software\n * and readers can access to determine the _purpose_ of this field.**\n */\n enablePassword() {\n this.acroField.setFlagTo(AcroTextFlags.Password, true);\n }\n\n /**\n * Indicate that this text field is **not** intended for storing a secure\n * password. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.disablePassword()\n * ```\n */\n disablePassword() {\n this.acroField.setFlagTo(AcroTextFlags.Password, false);\n }\n\n /**\n * Returns `true` if the contents of this text field represent a file path.\n * See [[PDFTextField.enableFileSelection]] and\n * [[PDFTextField.disableFileSelection]]. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * if (textField.isFileSelector()) console.log('Is a file selector')\n * ```\n * @returns Whether or not this field should contain file paths.\n */\n isFileSelector(): boolean {\n return this.acroField.hasFlag(AcroTextFlags.FileSelect);\n }\n\n /**\n * Indicate that this text field is intended to store a file path. The\n * contents of the file stored at that path should be submitted as the value\n * of the field. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.enableFileSelection()\n * ```\n */\n enableFileSelection() {\n this.acroField.setFlagTo(AcroTextFlags.FileSelect, true);\n }\n\n /**\n * Indicate that this text field is **not** intended to store a file path.\n * For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.disableFileSelection()\n * ```\n */\n disableFileSelection() {\n this.acroField.setFlagTo(AcroTextFlags.FileSelect, false);\n }\n\n /**\n * Returns `true` if the text entered in this field should be spell checked\n * by PDF readers. See [[PDFTextField.enableSpellChecking]] and\n * [[PDFTextField.disableSpellChecking]]. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * if (textField.isSpellChecked()) console.log('Spell checking is enabled')\n * ```\n * @returns Whether or not this field should be spell checked.\n */\n isSpellChecked(): boolean {\n return !this.acroField.hasFlag(AcroTextFlags.DoNotSpellCheck);\n }\n\n /**\n * Allow PDF readers to spell check the text entered in this field.\n * For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.enableSpellChecking()\n * ```\n */\n enableSpellChecking() {\n this.acroField.setFlagTo(AcroTextFlags.DoNotSpellCheck, false);\n }\n\n /**\n * Do not allow PDF readers to spell check the text entered in this field.\n * For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.disableSpellChecking()\n * ```\n */\n disableSpellChecking() {\n this.acroField.setFlagTo(AcroTextFlags.DoNotSpellCheck, true);\n }\n\n /**\n * Returns `true` if PDF readers should allow the user to scroll the text\n * field when its contents do not fit within the field's view bounds. See\n * [[PDFTextField.enableScrolling]] and [[PDFTextField.disableScrolling]].\n * For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * if (textField.isScrollable()) console.log('Scrolling is enabled')\n * ```\n * @returns Whether or not the field is scrollable in PDF readers.\n */\n isScrollable(): boolean {\n return !this.acroField.hasFlag(AcroTextFlags.DoNotScroll);\n }\n\n /**\n * Allow PDF readers to present a scroll bar to the user when the contents\n * of this text field do not fit within its view bounds. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.enableScrolling()\n * ```\n * A horizontal scroll bar should be shown for singleline fields. A vertical\n * scroll bar should be shown for multiline fields.\n */\n enableScrolling() {\n this.acroField.setFlagTo(AcroTextFlags.DoNotScroll, false);\n }\n\n /**\n * Do not allow PDF readers to present a scroll bar to the user when the\n * contents of this text field do not fit within its view bounds. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.disableScrolling()\n * ```\n */\n disableScrolling() {\n this.acroField.setFlagTo(AcroTextFlags.DoNotScroll, true);\n }\n\n /**\n * Returns `true` if this is a combed text field. This means that the field\n * is split into `n` equal size cells with one character in each (where `n`\n * is equal to the max length of the text field). The result is that all\n * characters in this field are displayed an equal distance apart from one\n * another. See [[PDFTextField.enableCombing]] and\n * [[PDFTextField.disableCombing]]. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * if (textField.isCombed()) console.log('Combing is enabled')\n * ```\n * Note that in order for a text field to be combed, the following must be\n * true (in addition to enabling combing):\n * * It must not be a multiline field (see [[PDFTextField.isMultiline]])\n * * It must not be a password field (see [[PDFTextField.isPassword]])\n * * It must not be a file selector field (see [[PDFTextField.isFileSelector]])\n * * It must have a max length defined (see [[PDFTextField.setMaxLength]])\n * @returns Whether or not this field is combed.\n */\n isCombed(): boolean {\n return (\n this.acroField.hasFlag(AcroTextFlags.Comb) &&\n !this.isMultiline() &&\n !this.isPassword() &&\n !this.isFileSelector() &&\n this.getMaxLength() !== undefined\n );\n }\n\n /**\n * Split this field into `n` equal size cells with one character in each\n * (where `n` is equal to the max length of the text field). This will cause\n * all characters in the field to be displayed an equal distance apart from\n * one another. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.enableCombing()\n * ```\n *\n * In addition to calling this method, text fields must have a max length\n * defined in order to be combed (see [[PDFTextField.setMaxLength]]).\n *\n * This method will also call the following three methods internally:\n * * [[PDFTextField.disableMultiline]]\n * * [[PDFTextField.disablePassword]]\n * * [[PDFTextField.disableFileSelection]]\n *\n * This method will mark this text field as dirty. See\n * [[PDFTextField.setText]] for more details about what this means.\n */\n enableCombing() {\n if (this.getMaxLength() === undefined) {\n const msg = `PDFTextFields must have a max length in order to be combed`;\n console.warn(msg);\n }\n\n this.markAsDirty();\n\n this.disableMultiline();\n this.disablePassword();\n this.disableFileSelection();\n\n this.acroField.setFlagTo(AcroTextFlags.Comb, true);\n }\n\n /**\n * Turn off combing for this text field. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.disableCombing()\n * ```\n * See [[PDFTextField.isCombed]] and [[PDFTextField.enableCombing]] for more\n * information about what combing is.\n *\n * This method will mark this text field as dirty. See\n * [[PDFTextField.setText]] for more details about what this means.\n */\n disableCombing() {\n this.markAsDirty();\n this.acroField.setFlagTo(AcroTextFlags.Comb, false);\n }\n\n /**\n * Returns `true` if this text field contains rich text. See\n * [[PDFTextField.enableRichFormatting]] and\n * [[PDFTextField.disableRichFormatting]]. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * if (textField.isRichFormatted()) console.log('Rich formatting enabled')\n * ```\n * @returns Whether or not this field contains rich text.\n */\n isRichFormatted(): boolean {\n return this.acroField.hasFlag(AcroTextFlags.RichText);\n }\n\n /**\n * Indicate that this field contains XFA data - or rich text. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.enableRichFormatting()\n * ```\n * Note that `pdf-lib` does not support reading or writing rich text fields.\n * Nor do most PDF readers and writers. Rich text fields are based on XFA\n * (XML Forms Architecture). Relatively few PDFs use rich text fields or XFA.\n * Unlike PDF itself, XFA is not an ISO standard. XFA has been deprecated in\n * PDF 2.0:\n * * https://en.wikipedia.org/wiki/XFA\n * * http://blog.pdfshareforms.com/pdf-2-0-release-bid-farewell-xfa-forms/\n */\n enableRichFormatting() {\n this.acroField.setFlagTo(AcroTextFlags.RichText, true);\n }\n\n /**\n * Indicate that this is a standard text field that does not XFA data (rich\n * text). For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * textField.disableRichFormatting()\n * ```\n */\n disableRichFormatting() {\n this.acroField.setFlagTo(AcroTextFlags.RichText, false);\n }\n\n /**\n * Show this text field on the specified page. For example:\n * ```js\n * const ubuntuFont = await pdfDoc.embedFont(ubuntuFontBytes)\n * const page = pdfDoc.addPage()\n *\n * const form = pdfDoc.getForm()\n * const textField = form.createTextField('best.gundam')\n * textField.setText('Exia')\n *\n * textField.addToPage(page, {\n * x: 50,\n * y: 75,\n * width: 200,\n * height: 100,\n * textColor: rgb(1, 0, 0),\n * backgroundColor: rgb(0, 1, 0),\n * borderColor: rgb(0, 0, 1),\n * borderWidth: 2,\n * rotate: degrees(90),\n * font: ubuntuFont,\n * })\n * ```\n * This will create a new widget for this text field.\n * @param page The page to which this text field widget should be added.\n * @param options The options to be used when adding this text field widget.\n */\n addToPage(page: PDFPage, options?: FieldAppearanceOptions) {\n assertIs(page, 'page', [[PDFPage, 'PDFPage']]);\n assertFieldAppearanceOptions(options);\n\n if (!options) options = {};\n\n if (!('textColor' in options)) options.textColor = rgb(0, 0, 0);\n if (!('backgroundColor' in options)) options.backgroundColor = rgb(1, 1, 1);\n if (!('borderColor' in options)) options.borderColor = rgb(0, 0, 0);\n if (!('borderWidth' in options)) options.borderWidth = 1;\n\n // Create a widget for this text field\n const widget = this.createWidget({\n x: options.x ?? 0,\n y: options.y ?? 0,\n width: options.width ?? 200,\n height: options.height ?? 50,\n textColor: options.textColor,\n backgroundColor: options.backgroundColor,\n borderColor: options.borderColor,\n borderWidth: options.borderWidth ?? 0,\n rotate: options.rotate ?? degrees(0),\n hidden: options.hidden,\n page: page.ref,\n });\n const widgetRef = this.doc.context.register(widget.dict);\n\n // Add widget to this field\n this.acroField.addWidget(widgetRef);\n\n // Set appearance streams for widget\n const font = options.font ?? this.doc.getForm().getDefaultFont();\n this.updateWidgetAppearance(widget, font);\n\n // Add widget to the given page\n page.node.addAnnot(widgetRef);\n }\n\n /**\n * Returns `true` if this text field has been marked as dirty, or if any of\n * this text field's widgets do not have an appearance stream. For example:\n * ```js\n * const textField = form.getTextField('some.text.field')\n * if (textField.needsAppearancesUpdate()) console.log('Needs update')\n * ```\n * @returns Whether or not this text field needs an appearance update.\n */\n needsAppearancesUpdate(): boolean {\n if (this.isDirty()) return true;\n\n const widgets = this.acroField.getWidgets();\n for (let idx = 0, len = widgets.length; idx < len; idx++) {\n const widget = widgets[idx];\n const hasAppearances =\n widget.getAppearances()?.normal instanceof PDFStream;\n if (!hasAppearances) return true;\n }\n\n return false;\n }\n\n /**\n * Update the appearance streams for each of this text field's widgets using\n * the default appearance provider for text fields. For example:\n * ```js\n * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const textField = form.getTextField('some.text.field')\n * textField.defaultUpdateAppearances(helvetica)\n * ```\n * @param font The font to be used for creating the appearance streams.\n */\n defaultUpdateAppearances(font: PDFFont) {\n assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n this.updateAppearances(font);\n }\n\n /**\n * Update the appearance streams for each of this text field's widgets using\n * the given appearance provider. If no `provider` is passed, the default\n * appearance provider for text fields will be used. For example:\n * ```js\n * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const textField = form.getTextField('some.text.field')\n * textField.updateAppearances(helvetica, (field, widget, font) => {\n * ...\n * return drawTextField(...)\n * })\n * ```\n * @param font The font to be used for creating the appearance streams.\n * @param provider Optionally, the appearance provider to be used for\n * generating the contents of the appearance streams.\n */\n updateAppearances(\n font: PDFFont,\n provider?: AppearanceProviderFor,\n ) {\n assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n assertOrUndefined(provider, 'provider', [Function]);\n\n const widgets = this.acroField.getWidgets();\n for (let idx = 0, len = widgets.length; idx < len; idx++) {\n const widget = widgets[idx];\n this.updateWidgetAppearance(widget, font, provider);\n }\n this.markAsClean();\n }\n\n private updateWidgetAppearance(\n widget: PDFWidgetAnnotation,\n font: PDFFont,\n provider?: AppearanceProviderFor,\n ) {\n const apProvider = provider ?? defaultTextFieldAppearanceProvider;\n const appearances = normalizeAppearance(apProvider(this, widget, font));\n this.updateWidgetAppearanceWithFont(widget, font, appearances);\n }\n}\n","import { PDFOperator, PDFWidgetAnnotation } from 'src/core';\nimport PDFFont from 'src/api/PDFFont';\nimport PDFButton from 'src/api/form/PDFButton';\nimport PDFCheckBox from 'src/api/form/PDFCheckBox';\nimport PDFDropdown from 'src/api/form/PDFDropdown';\nimport PDFField from 'src/api/form/PDFField';\nimport PDFOptionList from 'src/api/form/PDFOptionList';\nimport PDFRadioGroup from 'src/api/form/PDFRadioGroup';\nimport PDFSignature from 'src/api/form/PDFSignature';\nimport PDFTextField from 'src/api/form/PDFTextField';\nimport {\n drawCheckBox,\n rotateInPlace,\n drawRadioButton,\n drawButton,\n drawTextField,\n drawOptionList,\n} from 'src/api/operations';\nimport {\n rgb,\n componentsToColor,\n setFillingColor,\n grayscale,\n cmyk,\n Color,\n} from 'src/api/colors';\nimport { reduceRotation, adjustDimsForRotation } from 'src/api/rotations';\nimport {\n layoutMultilineText,\n layoutCombedText,\n TextPosition,\n layoutSinglelineText,\n} from 'src/api/text/layout';\nimport { TextAlignment } from 'src/api/text/alignment';\nimport { setFontAndSize } from 'src/api/operators';\nimport { findLastMatch } from 'src/utils';\n\n/*********************** Appearance Provider Types ****************************/\n\ntype CheckBoxAppearanceProvider = (\n checkBox: PDFCheckBox,\n widget: PDFWidgetAnnotation,\n) => AppearanceOrMapping<{\n on: PDFOperator[];\n off: PDFOperator[];\n}>;\n\ntype RadioGroupAppearanceProvider = (\n radioGroup: PDFRadioGroup,\n widget: PDFWidgetAnnotation,\n) => AppearanceOrMapping<{\n on: PDFOperator[];\n off: PDFOperator[];\n}>;\n\ntype ButtonAppearanceProvider = (\n button: PDFButton,\n widget: PDFWidgetAnnotation,\n font: PDFFont,\n) => AppearanceOrMapping;\n\ntype DropdownAppearanceProvider = (\n dropdown: PDFDropdown,\n widget: PDFWidgetAnnotation,\n font: PDFFont,\n) => AppearanceOrMapping;\n\ntype OptionListAppearanceProvider = (\n optionList: PDFOptionList,\n widget: PDFWidgetAnnotation,\n font: PDFFont,\n) => AppearanceOrMapping;\n\ntype TextFieldAppearanceProvider = (\n textField: PDFTextField,\n widget: PDFWidgetAnnotation,\n font: PDFFont,\n) => AppearanceOrMapping;\n\ntype SignatureAppearanceProvider = (\n signature: PDFSignature,\n widget: PDFWidgetAnnotation,\n font: PDFFont,\n) => AppearanceOrMapping;\n\n/******************* Appearance Provider Utility Types ************************/\n\nexport type AppearanceMapping = { normal: T; rollover?: T; down?: T };\n\ntype AppearanceOrMapping = T | AppearanceMapping;\n\n// prettier-ignore\nexport type AppearanceProviderFor = \n T extends PDFCheckBox ? CheckBoxAppearanceProvider\n: T extends PDFRadioGroup ? RadioGroupAppearanceProvider\n: T extends PDFButton ? ButtonAppearanceProvider\n: T extends PDFDropdown ? DropdownAppearanceProvider\n: T extends PDFOptionList ? OptionListAppearanceProvider\n: T extends PDFTextField ? TextFieldAppearanceProvider\n: T extends PDFSignature ? SignatureAppearanceProvider\n: never;\n\n/********************* Appearance Provider Functions **************************/\n\nexport const normalizeAppearance = (\n appearance: T | AppearanceMapping,\n): AppearanceMapping => {\n if ('normal' in appearance) return appearance;\n return { normal: appearance };\n};\n\n// Examples:\n// `/Helv 12 Tf` -> ['/Helv 12 Tf', 'Helv', '12']\n// `/HeBo 8.00 Tf` -> ['/HeBo 8 Tf', 'HeBo', '8.00']\nconst tfRegex = /\\/([^\\0\\t\\n\\f\\r\\ ]+)[\\0\\t\\n\\f\\r\\ ]+(\\d*\\.\\d+|\\d+)[\\0\\t\\n\\f\\r\\ ]+Tf/;\n\nconst getDefaultFontSize = (field: {\n getDefaultAppearance(): string | undefined;\n}) => {\n const da = field.getDefaultAppearance() ?? '';\n const daMatch = findLastMatch(da, tfRegex).match ?? [];\n const defaultFontSize = Number(daMatch[2]);\n return isFinite(defaultFontSize) ? defaultFontSize : undefined;\n};\n\n// Examples:\n// `0.3 g` -> ['0.3', 'g']\n// `0.3 1 .3 rg` -> ['0.3', '1', '.3', 'rg']\n// `0.3 1 .3 0 k` -> ['0.3', '1', '.3', '0', 'k']\nconst colorRegex = /(\\d*\\.\\d+|\\d+)[\\0\\t\\n\\f\\r\\ ]*(\\d*\\.\\d+|\\d+)?[\\0\\t\\n\\f\\r\\ ]*(\\d*\\.\\d+|\\d+)?[\\0\\t\\n\\f\\r\\ ]*(\\d*\\.\\d+|\\d+)?[\\0\\t\\n\\f\\r\\ ]+(g|rg|k)/;\n\nconst getDefaultColor = (field: {\n getDefaultAppearance(): string | undefined;\n}) => {\n const da = field.getDefaultAppearance() ?? '';\n const daMatch = findLastMatch(da, colorRegex).match;\n\n const [, c1, c2, c3, c4, colorSpace] = daMatch ?? [];\n\n if (colorSpace === 'g' && c1) {\n return grayscale(Number(c1));\n }\n if (colorSpace === 'rg' && c1 && c2 && c3) {\n return rgb(Number(c1), Number(c2), Number(c3));\n }\n if (colorSpace === 'k' && c1 && c2 && c3 && c4) {\n return cmyk(Number(c1), Number(c2), Number(c3), Number(c4));\n }\n\n return undefined;\n};\n\nconst updateDefaultAppearance = (\n field: { setDefaultAppearance(appearance: string): void },\n color: Color,\n font?: PDFFont,\n fontSize: number = 0,\n) => {\n const da = [\n setFillingColor(color).toString(),\n setFontAndSize(font?.name ?? 'dummy__noop', fontSize).toString(),\n ].join('\\n');\n field.setDefaultAppearance(da);\n};\n\nexport const defaultCheckBoxAppearanceProvider: AppearanceProviderFor = (\n checkBox,\n widget,\n) => {\n // The `/DA` entry can be at the widget or field level - so we handle both\n const widgetColor = getDefaultColor(widget);\n const fieldColor = getDefaultColor(checkBox.acroField);\n\n const rectangle = widget.getRectangle();\n const ap = widget.getAppearanceCharacteristics();\n const bs = widget.getBorderStyle();\n\n const borderWidth = bs?.getWidth() ?? 0;\n const rotation = reduceRotation(ap?.getRotation());\n const { width, height } = adjustDimsForRotation(rectangle, rotation);\n\n const rotate = rotateInPlace({ ...rectangle, rotation });\n\n const black = rgb(0, 0, 0);\n const borderColor = componentsToColor(ap?.getBorderColor()) ?? black;\n const normalBackgroundColor = componentsToColor(ap?.getBackgroundColor());\n const downBackgroundColor = componentsToColor(ap?.getBackgroundColor(), 0.8);\n\n // Update color\n const textColor = widgetColor ?? fieldColor ?? black;\n if (widgetColor) {\n updateDefaultAppearance(widget, textColor);\n } else {\n updateDefaultAppearance(checkBox.acroField, textColor);\n }\n\n const options = {\n x: 0 + borderWidth / 2,\n y: 0 + borderWidth / 2,\n width: width - borderWidth,\n height: height - borderWidth,\n thickness: 1.5,\n borderWidth,\n borderColor,\n markColor: textColor,\n };\n\n return {\n normal: {\n on: [\n ...rotate,\n ...drawCheckBox({\n ...options,\n color: normalBackgroundColor,\n filled: true,\n }),\n ],\n off: [\n ...rotate,\n ...drawCheckBox({\n ...options,\n color: normalBackgroundColor,\n filled: false,\n }),\n ],\n },\n down: {\n on: [\n ...rotate,\n ...drawCheckBox({\n ...options,\n color: downBackgroundColor,\n filled: true,\n }),\n ],\n off: [\n ...rotate,\n ...drawCheckBox({\n ...options,\n color: downBackgroundColor,\n filled: false,\n }),\n ],\n },\n };\n};\n\nexport const defaultRadioGroupAppearanceProvider: AppearanceProviderFor = (\n radioGroup,\n widget,\n) => {\n // The `/DA` entry can be at the widget or field level - so we handle both\n const widgetColor = getDefaultColor(widget);\n const fieldColor = getDefaultColor(radioGroup.acroField);\n\n const rectangle = widget.getRectangle();\n const ap = widget.getAppearanceCharacteristics();\n const bs = widget.getBorderStyle();\n\n const borderWidth = bs?.getWidth() ?? 0;\n const rotation = reduceRotation(ap?.getRotation());\n const { width, height } = adjustDimsForRotation(rectangle, rotation);\n\n const rotate = rotateInPlace({ ...rectangle, rotation });\n\n const black = rgb(0, 0, 0);\n const borderColor = componentsToColor(ap?.getBorderColor()) ?? black;\n const normalBackgroundColor = componentsToColor(ap?.getBackgroundColor());\n const downBackgroundColor = componentsToColor(ap?.getBackgroundColor(), 0.8);\n\n // Update color\n const textColor = widgetColor ?? fieldColor ?? black;\n if (widgetColor) {\n updateDefaultAppearance(widget, textColor);\n } else {\n updateDefaultAppearance(radioGroup.acroField, textColor);\n }\n\n const options = {\n x: width / 2,\n y: height / 2,\n width: width - borderWidth,\n height: height - borderWidth,\n borderWidth,\n borderColor,\n dotColor: textColor,\n };\n\n return {\n normal: {\n on: [\n ...rotate,\n ...drawRadioButton({\n ...options,\n color: normalBackgroundColor,\n filled: true,\n }),\n ],\n off: [\n ...rotate,\n ...drawRadioButton({\n ...options,\n color: normalBackgroundColor,\n filled: false,\n }),\n ],\n },\n down: {\n on: [\n ...rotate,\n ...drawRadioButton({\n ...options,\n color: downBackgroundColor,\n filled: true,\n }),\n ],\n off: [\n ...rotate,\n ...drawRadioButton({\n ...options,\n color: downBackgroundColor,\n filled: false,\n }),\n ],\n },\n };\n};\n\nexport const defaultButtonAppearanceProvider: AppearanceProviderFor = (\n button,\n widget,\n font,\n) => {\n // The `/DA` entry can be at the widget or field level - so we handle both\n const widgetColor = getDefaultColor(widget);\n const fieldColor = getDefaultColor(button.acroField);\n const widgetFontSize = getDefaultFontSize(widget);\n const fieldFontSize = getDefaultFontSize(button.acroField);\n\n const rectangle = widget.getRectangle();\n const ap = widget.getAppearanceCharacteristics();\n const bs = widget.getBorderStyle();\n const captions = ap?.getCaptions();\n const normalText = captions?.normal ?? '';\n const downText = captions?.down ?? normalText ?? '';\n\n const borderWidth = bs?.getWidth() ?? 0;\n const rotation = reduceRotation(ap?.getRotation());\n const { width, height } = adjustDimsForRotation(rectangle, rotation);\n\n const rotate = rotateInPlace({ ...rectangle, rotation });\n\n const black = rgb(0, 0, 0);\n\n const borderColor = componentsToColor(ap?.getBorderColor());\n const normalBackgroundColor = componentsToColor(ap?.getBackgroundColor());\n const downBackgroundColor = componentsToColor(ap?.getBackgroundColor(), 0.8);\n\n const bounds = {\n x: borderWidth,\n y: borderWidth,\n width: width - borderWidth * 2,\n height: height - borderWidth * 2,\n };\n const normalLayout = layoutSinglelineText(normalText, {\n alignment: TextAlignment.Center,\n fontSize: widgetFontSize ?? fieldFontSize,\n font,\n bounds,\n });\n const downLayout = layoutSinglelineText(downText, {\n alignment: TextAlignment.Center,\n fontSize: widgetFontSize ?? fieldFontSize,\n font,\n bounds,\n });\n\n // Update font size and color\n const fontSize = Math.min(normalLayout.fontSize, downLayout.fontSize);\n const textColor = widgetColor ?? fieldColor ?? black;\n if (widgetColor || widgetFontSize !== undefined) {\n updateDefaultAppearance(widget, textColor, font, fontSize);\n } else {\n updateDefaultAppearance(button.acroField, textColor, font, fontSize);\n }\n\n const options = {\n x: 0 + borderWidth / 2,\n y: 0 + borderWidth / 2,\n width: width - borderWidth,\n height: height - borderWidth,\n borderWidth,\n borderColor,\n textColor,\n font: font.name,\n fontSize,\n };\n\n return {\n normal: [\n ...rotate,\n ...drawButton({\n ...options,\n color: normalBackgroundColor,\n textLines: [normalLayout.line],\n }),\n ],\n down: [\n ...rotate,\n ...drawButton({\n ...options,\n color: downBackgroundColor,\n textLines: [downLayout.line],\n }),\n ],\n };\n};\n\nexport const defaultTextFieldAppearanceProvider: AppearanceProviderFor = (\n textField,\n widget,\n font,\n) => {\n // The `/DA` entry can be at the widget or field level - so we handle both\n const widgetColor = getDefaultColor(widget);\n const fieldColor = getDefaultColor(textField.acroField);\n const widgetFontSize = getDefaultFontSize(widget);\n const fieldFontSize = getDefaultFontSize(textField.acroField);\n\n const rectangle = widget.getRectangle();\n const ap = widget.getAppearanceCharacteristics();\n const bs = widget.getBorderStyle();\n const text = textField.getText() ?? '';\n\n const borderWidth = bs?.getWidth() ?? 0;\n const rotation = reduceRotation(ap?.getRotation());\n const { width, height } = adjustDimsForRotation(rectangle, rotation);\n\n const rotate = rotateInPlace({ ...rectangle, rotation });\n\n const black = rgb(0, 0, 0);\n\n const borderColor = componentsToColor(ap?.getBorderColor());\n const normalBackgroundColor = componentsToColor(ap?.getBackgroundColor());\n\n let textLines: TextPosition[];\n let fontSize: number;\n\n const padding = textField.isCombed() ? 0 : 1;\n const bounds = {\n x: borderWidth + padding,\n y: borderWidth + padding,\n width: width - (borderWidth + padding) * 2,\n height: height - (borderWidth + padding) * 2,\n };\n if (textField.isMultiline()) {\n const layout = layoutMultilineText(text, {\n alignment: textField.getAlignment(),\n fontSize: widgetFontSize ?? fieldFontSize,\n font,\n bounds,\n });\n textLines = layout.lines;\n fontSize = layout.fontSize;\n } else if (textField.isCombed()) {\n const layout = layoutCombedText(text, {\n fontSize: widgetFontSize ?? fieldFontSize,\n font,\n bounds,\n cellCount: textField.getMaxLength() ?? 0,\n });\n textLines = layout.cells;\n fontSize = layout.fontSize;\n } else {\n const layout = layoutSinglelineText(text, {\n alignment: textField.getAlignment(),\n fontSize: widgetFontSize ?? fieldFontSize,\n font,\n bounds,\n });\n textLines = [layout.line];\n fontSize = layout.fontSize;\n }\n\n // Update font size and color\n const textColor = widgetColor ?? fieldColor ?? black;\n if (widgetColor || widgetFontSize !== undefined) {\n updateDefaultAppearance(widget, textColor, font, fontSize);\n } else {\n updateDefaultAppearance(textField.acroField, textColor, font, fontSize);\n }\n\n const options = {\n x: 0 + borderWidth / 2,\n y: 0 + borderWidth / 2,\n width: width - borderWidth,\n height: height - borderWidth,\n borderWidth: borderWidth ?? 0,\n borderColor,\n textColor,\n font: font.name,\n fontSize,\n color: normalBackgroundColor,\n textLines,\n padding,\n };\n\n return [...rotate, ...drawTextField(options)];\n};\n\nexport const defaultDropdownAppearanceProvider: AppearanceProviderFor = (\n dropdown,\n widget,\n font,\n) => {\n // The `/DA` entry can be at the widget or field level - so we handle both\n const widgetColor = getDefaultColor(widget);\n const fieldColor = getDefaultColor(dropdown.acroField);\n const widgetFontSize = getDefaultFontSize(widget);\n const fieldFontSize = getDefaultFontSize(dropdown.acroField);\n\n const rectangle = widget.getRectangle();\n const ap = widget.getAppearanceCharacteristics();\n const bs = widget.getBorderStyle();\n const text = dropdown.getSelected()[0] ?? '';\n\n const borderWidth = bs?.getWidth() ?? 0;\n const rotation = reduceRotation(ap?.getRotation());\n const { width, height } = adjustDimsForRotation(rectangle, rotation);\n\n const rotate = rotateInPlace({ ...rectangle, rotation });\n\n const black = rgb(0, 0, 0);\n\n const borderColor = componentsToColor(ap?.getBorderColor());\n const normalBackgroundColor = componentsToColor(ap?.getBackgroundColor());\n\n const padding = 1;\n const bounds = {\n x: borderWidth + padding,\n y: borderWidth + padding,\n width: width - (borderWidth + padding) * 2,\n height: height - (borderWidth + padding) * 2,\n };\n const { line, fontSize } = layoutSinglelineText(text, {\n alignment: TextAlignment.Left,\n fontSize: widgetFontSize ?? fieldFontSize,\n font,\n bounds,\n });\n\n // Update font size and color\n const textColor = widgetColor ?? fieldColor ?? black;\n if (widgetColor || widgetFontSize !== undefined) {\n updateDefaultAppearance(widget, textColor, font, fontSize);\n } else {\n updateDefaultAppearance(dropdown.acroField, textColor, font, fontSize);\n }\n\n const options = {\n x: 0 + borderWidth / 2,\n y: 0 + borderWidth / 2,\n width: width - borderWidth,\n height: height - borderWidth,\n borderWidth: borderWidth ?? 0,\n borderColor,\n textColor,\n font: font.name,\n fontSize,\n color: normalBackgroundColor,\n textLines: [line],\n padding,\n };\n\n return [...rotate, ...drawTextField(options)];\n};\n\nexport const defaultOptionListAppearanceProvider: AppearanceProviderFor = (\n optionList,\n widget,\n font,\n) => {\n // The `/DA` entry can be at the widget or field level - so we handle both\n const widgetColor = getDefaultColor(widget);\n const fieldColor = getDefaultColor(optionList.acroField);\n const widgetFontSize = getDefaultFontSize(widget);\n const fieldFontSize = getDefaultFontSize(optionList.acroField);\n\n const rectangle = widget.getRectangle();\n const ap = widget.getAppearanceCharacteristics();\n const bs = widget.getBorderStyle();\n\n const borderWidth = bs?.getWidth() ?? 0;\n const rotation = reduceRotation(ap?.getRotation());\n const { width, height } = adjustDimsForRotation(rectangle, rotation);\n\n const rotate = rotateInPlace({ ...rectangle, rotation });\n\n const black = rgb(0, 0, 0);\n\n const borderColor = componentsToColor(ap?.getBorderColor());\n const normalBackgroundColor = componentsToColor(ap?.getBackgroundColor());\n\n const options = optionList.getOptions();\n const selected = optionList.getSelected();\n\n if (optionList.isSorted()) options.sort();\n\n let text = '';\n for (let idx = 0, len = options.length; idx < len; idx++) {\n text += options[idx];\n if (idx < len - 1) text += '\\n';\n }\n\n const padding = 1;\n const bounds = {\n x: borderWidth + padding,\n y: borderWidth + padding,\n width: width - (borderWidth + padding) * 2,\n height: height - (borderWidth + padding) * 2,\n };\n const { lines, fontSize, lineHeight } = layoutMultilineText(text, {\n alignment: TextAlignment.Left,\n fontSize: widgetFontSize ?? fieldFontSize,\n font,\n bounds,\n });\n\n const selectedLines: number[] = [];\n for (let idx = 0, len = lines.length; idx < len; idx++) {\n const line = lines[idx];\n if (selected.includes(line.text)) selectedLines.push(idx);\n }\n\n const blue = rgb(153 / 255, 193 / 255, 218 / 255);\n\n // Update font size and color\n const textColor = widgetColor ?? fieldColor ?? black;\n if (widgetColor || widgetFontSize !== undefined) {\n updateDefaultAppearance(widget, textColor, font, fontSize);\n } else {\n updateDefaultAppearance(optionList.acroField, textColor, font, fontSize);\n }\n\n return [\n ...rotate,\n ...drawOptionList({\n x: 0 + borderWidth / 2,\n y: 0 + borderWidth / 2,\n width: width - borderWidth,\n height: height - borderWidth,\n borderWidth: borderWidth ?? 0,\n borderColor,\n textColor,\n font: font.name,\n fontSize,\n color: normalBackgroundColor,\n textLines: lines,\n lineHeight,\n selectedColor: blue,\n selectedLines,\n padding,\n }),\n ];\n};\n","export enum ImageAlignment {\n Left = 0,\n Center = 1,\n Right = 2,\n}\n"],"names":["ColorTypes","grayscale","gray","assertRange","type","Grayscale","rgb","red","green","blue","RGB","cmyk","cyan","magenta","yellow","key","CMYK","setFillingColor","color","setFillingGrayscaleColor","setFillingRgbColor","setFillingCmykColor","error","JSON","stringify","setStrokingColor","setStrokingGrayscaleColor","setStrokingRgbColor","setStrokingCmykColor","componentsToColor","comps","scale","length","undefined","colorToComponents","EncryptedPDFError","_super","call","__extends","Error","FontkitNotRegisteredError","ForeignPageError","RemovePageFromEmptyDocumentError","NoSuchFieldError","name","msg","UnexpectedFieldTypeError","expected","actual","_b","_a","constructor","FieldAlreadyExistsError","MissingOnValueCheckError","onValue","InvalidFieldNamePartError","namePart","RichTextFieldReadError","FieldExistsAsNonTerminalError","fieldName","CombedTextLayoutError","lineLength","cellCount","ExceededMaxLengthError","textLength","maxLength","InvalidMaxLengthError","PDFButton","acroPushButton","ref","doc","_this","assertIs","PDFAcroPushButton","acroField","prototype","setImage","image","alignment","ImageAlignment","Center","widgets","this","getWidgets","idx","len","widget","streamRef","createImageAppearanceStream","updateWidgetAppearances","normal","markAsClean","setFontSize","fontSize","assertPositive","markAsDirty","addToPage","text","page","options","assertOrUndefined","PDFPage","assertFieldAppearanceOptions","createWidget","x","borderWidth","y","_c","_d","width","_e","height","_f","textColor","_g","backgroundColor","_h","borderColor","_j","rotate","_k","degrees","caption","hidden","widgetRef","context","register","dict","addWidget","font","_l","getForm","getDefaultFont","updateWidgetAppearance","node","addAnnot","needsAppearancesUpdate","isDirty","getAppearances","PDFStream","defaultUpdateAppearances","PDFFont","updateAppearances","provider","Function","apProvider","defaultButtonAppearanceProvider","appearances","normalizeAppearance","updateWidgetAppearanceWithFont","of","PDFField","PDFCheckBox","acroCheckBox","PDFAcroCheckBox","check","getOnValue","PDFName","setValue","uncheck","isChecked","getValue","setAppearanceState","state","getAppearanceState","PDFDict","has","defaultCheckBoxAppearanceProvider","updateOnOffWidgetAppearance","PDFDropdown","acroComboBox","PDFAcroComboBox","getOptions","rawOptions","Array","display","value","decodeText","getSelected","values","getValues","selected","setOptions","optionObjects","PDFHexString","fromText","addOptions","optionsArr","isArray","existingOptions","newOptions","concat","select","merge","validOptions","find","option","includes","enableEditing","enableMultiselect","existingValues","setValues","clear","isEditable","hasFlag","AcroChoiceFlags","Edit","setFlagTo","disableEditing","isSorted","Sort","enableSorting","disableSorting","isMultiselect","MultiSelect","disableMultiselect","isSpellChecked","DoNotSpellCheck","enableSpellChecking","disableSpellChecking","isSelectOnClick","CommitOnSelChange","enableSelectOnClick","disableSelectOnClick","defaultDropdownAppearanceProvider","Object","PDFAcroTerminal","PDFRef","PDFDocument","getName","getFullyQualifiedName","isReadOnly","AcroFieldFlags","ReadOnly","enableReadOnly","disableReadOnly","isRequired","Required","enableRequired","disableRequired","isExported","NoExport","enableExporting","disableExporting","MethodNotImplementedError","_font","markFieldAsDirty","markFieldAsClean","fieldIsDirty","degreesAngle","toDegrees","Boolean","pageRef","assertMultiple","PDFWidgetAnnotation","create","rect","rotateRectangle","setRectangle","setP","ac","getOrCreateAppearanceCharacteristics","setBackgroundColor","setRotation","setCaptions","setBorderColor","bs","getOrCreateBorderStyle","setWidth","AnnotationFlags","Print","Hidden","Invisible","newDa","getDefaultAppearance","toString","setDefaultAppearance","rollover","down","createAppearanceStream","createAppearanceDict","setNormalAppearance","setRolloverAppearance","removeRolloverAppearance","setDownAppearance","removeDownAppearance","appearance","getRectangle","Resources","Font","stream","formXObject","BBox","obj","Matrix","rectangle","ap","getAppearanceCharacteristics","getBorderStyle","getWidth","rotation","reduceRotation","getRotation","rotateInPlace","__assign","adj","adjustDimsForRotation","imageDims","scaleToFit","xSkew","ySkew","Right","imageName","addRandomSuffix","__spreadArrays","drawImage","XObject","onStreamRef","on","offStreamRef","off","appearanceDict","set","PDFForm","acroForm","embedDefaultFont","embedStandardFont","StandardFonts","Helvetica","PDFAcroForm","dirtyFields","Set","defaultFontCache","Cache","populatedBy","hasXFA","deleteXFA","delete","getFields","allFields","getAllFields","fields","field","convertToPDFField","push","getFieldMaybe","getField","getButton","getCheckBox","getDropdown","getOptionList","PDFOptionList","getRadioGroup","PDFRadioGroup","getSignature","PDFSignature","getTextField","PDFTextField","createButton","nameParts","splitFieldName","parent","findOrCreateNonTerminals","nonTerminal","button","setPartialName","terminal","addFieldToParent","createCheckBox","checkBox","createDropdown","comboBox","createOptionList","listBox","PDFAcroListBox","createRadioGroup","radioButton","PDFAcroRadioButton","createTextField","PDFAcroText","flatten","updateFieldAppearances","i","lenFields","j","lenWidgets","findWidgetPage","findWidgetAppearanceRef","xObjectKey","newXObject","operators","pushGraphicsState","translate","drawObject","popGraphicsState","filter","pushOperators","apply","removeField","pages","add","removeAnnot","forEach","fieldKids","normalizedEntries","Kids","kidsCount","size","childIndex","child","get","fieldRef","access","P","getPages","getObjectRef","findPageForAnnotationRef","refOrDict","getNormalAppearance","name_1","partialNames","parent_1","parentRef","res","findNonTerminal","PDFAcroNonTerminal","setParent","nodeRef","addField","partialName","createPDFAcroFields","getPartialName","PDFAcroSignature","fullyQualifiedName","parts","split","slice","entries","Fields","acroListBox","assertIsSubset","defaultOptionListAppearanceProvider","acroRadioButton","exportValues","getExportValues","exportOptions","onValues","getOnValues","onOptions","assertIsOneOf","isOffToggleable","AcroButtonFlags","NoToggleToOff","enableOffToggling","disableOffToggling","isMutuallyExclusive","RadiosInUnison","enableMutualExclusion","disableMutualExclusion","addOptionToPage","apStateValue","addWidgetWithOpt","defaultRadioGroupAppearanceProvider","acroSignature","acroText","getText","isRichFormatted","setText","getMaxLength","disableRichFormatting","removeValue","getAlignment","quadding","getQuadding","TextAlignment","Left","setAlignment","setQuadding","setMaxLength","assertRangeOrUndefined","Number","MAX_SAFE_INTEGER","removeMaxLength","fieldAlignment","isMultiline","AcroTextFlags","Multiline","enableMultiline","disableMultiline","isPassword","Password","enablePassword","disablePassword","isFileSelector","FileSelect","enableFileSelection","disableFileSelection","isScrollable","DoNotScroll","enableScrolling","disableScrolling","isCombed","Comb","enableCombing","disableCombing","RichText","enableRichFormatting","defaultTextFieldAppearanceProvider","tfRegex","getDefaultFontSize","da","daMatch","findLastMatch","match","defaultFontSize","isFinite","colorRegex","getDefaultColor","c1","c2","c3","c4","colorSpace","updateDefaultAppearance","setFontAndSize","join","widgetColor","fieldColor","black","getBorderColor","normalBackgroundColor","getBackgroundColor","downBackgroundColor","thickness","markColor","drawCheckBox","filled","radioGroup","dotColor","drawRadioButton","widgetFontSize","fieldFontSize","captions","getCaptions","normalText","downText","bounds","normalLayout","layoutSinglelineText","downLayout","Math","min","drawButton","textLines","line","textField","padding","layout","layoutMultilineText","lines","layoutCombedText","cells","drawTextField","dropdown","optionList","sort","lineHeight","selectedLines","drawOptionList","selectedColor"],"sourceRoot":""}