first commit
This commit is contained in:
138
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFButton.d.ts
generated
vendored
Normal file
138
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFButton.d.ts
generated
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
import PDFDocument from "../PDFDocument";
|
||||
import PDFPage from "../PDFPage";
|
||||
import PDFFont from "../PDFFont";
|
||||
import PDFImage from "../PDFImage";
|
||||
import { ImageAlignment } from "../image/alignment";
|
||||
import { AppearanceProviderFor } from "./appearances";
|
||||
import PDFField, { FieldAppearanceOptions } from "./PDFField";
|
||||
import { PDFRef, PDFAcroPushButton } from "../../core";
|
||||
/**
|
||||
* Represents a button field of a [[PDFForm]].
|
||||
*
|
||||
* [[PDFButton]] fields are interactive controls that users can click with their
|
||||
* mouse. This type of [[PDFField]] is not stateful. The purpose of a button
|
||||
* is to perform an action when the user clicks on it, such as opening a print
|
||||
* modal or resetting the form. Buttons are typically rectangular in shape and
|
||||
* have a text label describing the action that they perform when clicked.
|
||||
*/
|
||||
export default class PDFButton extends PDFField {
|
||||
/**
|
||||
* > **NOTE:** You probably don't want to call this method directly. Instead,
|
||||
* > consider using the [[PDFForm.getButton]] method, which will create an
|
||||
* > instance of [[PDFButton]] for you.
|
||||
*
|
||||
* Create an instance of [[PDFButton]] from an existing acroPushButton and ref
|
||||
*
|
||||
* @param acroPushButton The underlying `PDFAcroPushButton` for this button.
|
||||
* @param ref The unique reference for this button.
|
||||
* @param doc The document to which this button will belong.
|
||||
*/
|
||||
static of: (acroPushButton: PDFAcroPushButton, ref: PDFRef, doc: PDFDocument) => PDFButton;
|
||||
/** The low-level PDFAcroPushButton wrapped by this button. */
|
||||
readonly acroField: PDFAcroPushButton;
|
||||
private constructor();
|
||||
/**
|
||||
* Display an image inside the bounds of this button's widgets. For example:
|
||||
* ```js
|
||||
* const pngImage = await pdfDoc.embedPng(...)
|
||||
* const button = form.getButton('some.button.field')
|
||||
* button.setImage(pngImage, ImageAlignment.Center)
|
||||
* ```
|
||||
* This will update the appearances streams for each of this button's widgets.
|
||||
* @param image The image that should be displayed.
|
||||
* @param alignment The alignment of the image.
|
||||
*/
|
||||
setImage(image: PDFImage, alignment?: ImageAlignment): void;
|
||||
/**
|
||||
* Set the font size for this field. Larger font sizes will result in larger
|
||||
* text being displayed when PDF readers render this button. Font sizes may
|
||||
* be integer or floating point numbers. Supplying a negative font size will
|
||||
* cause this method to throw an error.
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const button = form.getButton('some.button.field')
|
||||
* button.setFontSize(4)
|
||||
* button.setFontSize(15.7)
|
||||
* ```
|
||||
*
|
||||
* > This method depends upon the existence of a default appearance
|
||||
* > (`/DA`) string. If this field does not have a default appearance string,
|
||||
* > or that string does not contain a font size (via the `Tf` operator),
|
||||
* > then this method will throw an error.
|
||||
*
|
||||
* @param fontSize The font size to be used when rendering text in this field.
|
||||
*/
|
||||
setFontSize(fontSize: number): void;
|
||||
/**
|
||||
* Show this button on the specified page with the given text. For example:
|
||||
* ```js
|
||||
* const ubuntuFont = await pdfDoc.embedFont(ubuntuFontBytes)
|
||||
* const page = pdfDoc.addPage()
|
||||
*
|
||||
* const form = pdfDoc.getForm()
|
||||
* const button = form.createButton('some.button.field')
|
||||
*
|
||||
* button.addToPage('Do Stuff', page, {
|
||||
* x: 50,
|
||||
* y: 75,
|
||||
* width: 200,
|
||||
* height: 100,
|
||||
* textColor: rgb(1, 0, 0),
|
||||
* backgroundColor: rgb(0, 1, 0),
|
||||
* borderColor: rgb(0, 0, 1),
|
||||
* borderWidth: 2,
|
||||
* rotate: degrees(90),
|
||||
* font: ubuntuFont,
|
||||
* })
|
||||
* ```
|
||||
* This will create a new widget for this button field.
|
||||
* @param text The text to be displayed for this button widget.
|
||||
* @param page The page to which this button widget should be added.
|
||||
* @param options The options to be used when adding this button widget.
|
||||
*/
|
||||
addToPage(text: string, page: PDFPage, options?: FieldAppearanceOptions): void;
|
||||
/**
|
||||
* Returns `true` if this button has been marked as dirty, or if any of this
|
||||
* button's widgets do not have an appearance stream. For example:
|
||||
* ```js
|
||||
* const button = form.getButton('some.button.field')
|
||||
* if (button.needsAppearancesUpdate()) console.log('Needs update')
|
||||
* ```
|
||||
* @returns Whether or not this button needs an appearance update.
|
||||
*/
|
||||
needsAppearancesUpdate(): boolean;
|
||||
/**
|
||||
* Update the appearance streams for each of this button's widgets using
|
||||
* the default appearance provider for buttons. For example:
|
||||
* ```js
|
||||
* const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)
|
||||
* const button = form.getButton('some.button.field')
|
||||
* button.defaultUpdateAppearances(helvetica)
|
||||
* ```
|
||||
* @param font The font to be used for creating the appearance streams.
|
||||
*/
|
||||
defaultUpdateAppearances(font: PDFFont): void;
|
||||
/**
|
||||
* Update the appearance streams for each of this button's widgets using
|
||||
* the given appearance provider. If no `provider` is passed, the default
|
||||
* appearance provider for buttons will be used. For example:
|
||||
* ```js
|
||||
* const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)
|
||||
* const button = form.getButton('some.button.field')
|
||||
* button.updateAppearances(helvetica, (field, widget, font) => {
|
||||
* ...
|
||||
* return {
|
||||
* normal: drawButton(...),
|
||||
* down: drawButton(...),
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
* @param font The font to be used for creating the appearance streams.
|
||||
* @param provider Optionally, the appearance provider to be used for
|
||||
* generating the contents of the appearance streams.
|
||||
*/
|
||||
updateAppearances(font: PDFFont, provider?: AppearanceProviderFor<PDFButton>): void;
|
||||
private updateWidgetAppearance;
|
||||
}
|
||||
//# sourceMappingURL=PDFButton.d.ts.map
|
||||
143
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFCheckBox.d.ts
generated
vendored
Normal file
143
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFCheckBox.d.ts
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
import PDFDocument from "../PDFDocument";
|
||||
import PDFPage from "../PDFPage";
|
||||
import { AppearanceProviderFor } from "./appearances";
|
||||
import PDFField, { FieldAppearanceOptions } from "./PDFField";
|
||||
import { PDFRef, PDFAcroCheckBox } from "../../core";
|
||||
/**
|
||||
* Represents a check box field of a [[PDFForm]].
|
||||
*
|
||||
* [[PDFCheckBox]] fields are interactive boxes that users can click with their
|
||||
* mouse. This type of [[PDFField]] has two states: `on` and `off`. The purpose
|
||||
* of a check box is to enable users to select from one or more options, where
|
||||
* each option is represented by a single check box. Check boxes are typically
|
||||
* square in shape and display a check mark when they are in the `on` state.
|
||||
*/
|
||||
export default class PDFCheckBox extends PDFField {
|
||||
/**
|
||||
* > **NOTE:** You probably don't want to call this method directly. Instead,
|
||||
* > consider using the [[PDFForm.getCheckBox]] method, which will create an
|
||||
* > instance of [[PDFCheckBox]] for you.
|
||||
*
|
||||
* Create an instance of [[PDFCheckBox]] from an existing acroCheckBox and ref
|
||||
*
|
||||
* @param acroCheckBox The underlying `PDFAcroCheckBox` for this check box.
|
||||
* @param ref The unique reference for this check box.
|
||||
* @param doc The document to which this check box will belong.
|
||||
*/
|
||||
static of: (acroCheckBox: PDFAcroCheckBox, ref: PDFRef, doc: PDFDocument) => PDFCheckBox;
|
||||
/** The low-level PDFAcroCheckBox wrapped by this check box. */
|
||||
readonly acroField: PDFAcroCheckBox;
|
||||
private constructor();
|
||||
/**
|
||||
* Mark this check box. This operation is analogous to a human user clicking
|
||||
* a check box to fill it in a PDF reader. This method will update the
|
||||
* underlying state of the check box field to indicate it has been selected.
|
||||
* PDF libraries and readers will be able to extract this value from the
|
||||
* saved document and determine that it was selected.
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const checkBox = form.getCheckBox('some.checkBox.field')
|
||||
* checkBox.check()
|
||||
* ```
|
||||
*
|
||||
* This method will mark this check box as dirty, causing its appearance
|
||||
* streams to be updated when either [[PDFDocument.save]] or
|
||||
* [[PDFForm.updateFieldAppearances]] is called. The updated appearance
|
||||
* streams will display a check mark inside the widgets of this check box
|
||||
* field.
|
||||
*/
|
||||
check(): void;
|
||||
/**
|
||||
* Clears this check box. This operation is analogous to a human user clicking
|
||||
* a check box to unmark it in a PDF reader. This method will update the
|
||||
* underlying state of the check box field to indicate it has been deselected.
|
||||
* PDF libraries and readers will be able to extract this value from the
|
||||
* saved document and determine that it was not selected.
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const checkBox = form.getCheckBox('some.checkBox.field')
|
||||
* checkBox.uncheck()
|
||||
* ```
|
||||
*
|
||||
* This method will mark this check box as dirty. See [[PDFCheckBox.check]]
|
||||
* for more details about what this means.
|
||||
*/
|
||||
uncheck(): void;
|
||||
/**
|
||||
* Returns `true` if this check box is selected (either by a human user via
|
||||
* a PDF reader, or else programmatically via software). For example:
|
||||
* ```js
|
||||
* const checkBox = form.getCheckBox('some.checkBox.field')
|
||||
* if (checkBox.isChecked()) console.log('check box is selected')
|
||||
* ```
|
||||
* @returns Whether or not this check box is selected.
|
||||
*/
|
||||
isChecked(): boolean;
|
||||
/**
|
||||
* Show this check box on the specified page. For example:
|
||||
* ```js
|
||||
* const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)
|
||||
* const page = pdfDoc.addPage()
|
||||
*
|
||||
* const form = pdfDoc.getForm()
|
||||
* const checkBox = form.createCheckBox('some.checkBox.field')
|
||||
*
|
||||
* checkBox.addToPage(page, {
|
||||
* x: 50,
|
||||
* y: 75,
|
||||
* width: 25,
|
||||
* height: 25,
|
||||
* textColor: rgb(1, 0, 0),
|
||||
* backgroundColor: rgb(0, 1, 0),
|
||||
* borderColor: rgb(0, 0, 1),
|
||||
* borderWidth: 2,
|
||||
* rotate: degrees(90),
|
||||
* })
|
||||
* ```
|
||||
* This will create a new widget for this check box field.
|
||||
* @param page The page to which this check box widget should be added.
|
||||
* @param options The options to be used when adding this check box widget.
|
||||
*/
|
||||
addToPage(page: PDFPage, options?: FieldAppearanceOptions): void;
|
||||
/**
|
||||
* Returns `true` if any of this check box's widgets do not have an
|
||||
* appearance stream for its current state. For example:
|
||||
* ```js
|
||||
* const checkBox = form.getCheckBox('some.checkBox.field')
|
||||
* if (checkBox.needsAppearancesUpdate()) console.log('Needs update')
|
||||
* ```
|
||||
* @returns Whether or not this check box needs an appearance update.
|
||||
*/
|
||||
needsAppearancesUpdate(): boolean;
|
||||
/**
|
||||
* Update the appearance streams for each of this check box's widgets using
|
||||
* the default appearance provider for check boxes. For example:
|
||||
* ```js
|
||||
* const checkBox = form.getCheckBox('some.checkBox.field')
|
||||
* checkBox.defaultUpdateAppearances()
|
||||
* ```
|
||||
*/
|
||||
defaultUpdateAppearances(): void;
|
||||
/**
|
||||
* Update the appearance streams for each of this check box's widgets using
|
||||
* the given appearance provider. If no `provider` is passed, the default
|
||||
* appearance provider for check boxs will be used. For example:
|
||||
* ```js
|
||||
* const checkBox = form.getCheckBox('some.checkBox.field')
|
||||
* checkBox.updateAppearances((field, widget) => {
|
||||
* ...
|
||||
* return {
|
||||
* normal: { on: drawCheckBox(...), off: drawCheckBox(...) },
|
||||
* down: { on: drawCheckBox(...), off: drawCheckBox(...) },
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
* @param provider Optionally, the appearance provider to be used for
|
||||
* generating the contents of the appearance streams.
|
||||
*/
|
||||
updateAppearances(provider?: AppearanceProviderFor<PDFCheckBox>): void;
|
||||
private updateWidgetAppearance;
|
||||
}
|
||||
//# sourceMappingURL=PDFCheckBox.d.ts.map
|
||||
403
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFDropdown.d.ts
generated
vendored
Normal file
403
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFDropdown.d.ts
generated
vendored
Normal file
@@ -0,0 +1,403 @@
|
||||
import PDFDocument from "../PDFDocument";
|
||||
import PDFPage from "../PDFPage";
|
||||
import PDFFont from "../PDFFont";
|
||||
import PDFField, { FieldAppearanceOptions } from "./PDFField";
|
||||
import { AppearanceProviderFor } from "./appearances";
|
||||
import { PDFRef, PDFAcroComboBox } from "../../core";
|
||||
/**
|
||||
* Represents a dropdown field of a [[PDFForm]].
|
||||
*
|
||||
* [[PDFDropdown]] fields are interactive text boxes that display a single
|
||||
* element (the currently selected value). The purpose of a dropdown is to
|
||||
* enable users to select a single option from a set of possible options. Users
|
||||
* can click on a dropdown to view the full list of options it provides.
|
||||
* Clicking on an option in the list will cause it to be selected and displayed
|
||||
* in the dropdown's text box. Some dropdowns allow users to enter text
|
||||
* directly into the box from their keyboard, rather than only being allowed to
|
||||
* choose an option from the list (see [[PDFDropdown.isEditable]]).
|
||||
*/
|
||||
export default class PDFDropdown extends PDFField {
|
||||
/**
|
||||
* > **NOTE:** You probably don't want to call this method directly. Instead,
|
||||
* > consider using the [[PDFForm.getDropdown]] method, which will create an
|
||||
* > instance of [[PDFDropdown]] for you.
|
||||
*
|
||||
* Create an instance of [[PDFDropdown]] from an existing acroComboBox and ref
|
||||
*
|
||||
* @param acroComboBox The underlying `PDFAcroComboBox` for this dropdown.
|
||||
* @param ref The unique reference for this dropdown.
|
||||
* @param doc The document to which this dropdown will belong.
|
||||
*/
|
||||
static of: (acroComboBox: PDFAcroComboBox, ref: PDFRef, doc: PDFDocument) => PDFDropdown;
|
||||
/** The low-level PDFAcroComboBox wrapped by this dropdown. */
|
||||
readonly acroField: PDFAcroComboBox;
|
||||
private constructor();
|
||||
/**
|
||||
* Get the list of available options for this dropdown. These options will be
|
||||
* displayed to users who click on this dropdown in a PDF reader.
|
||||
* For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* const options = dropdown.getOptions()
|
||||
* console.log('Dropdown options:', options)
|
||||
* ```
|
||||
* @returns The options for this dropdown.
|
||||
*/
|
||||
getOptions(): string[];
|
||||
/**
|
||||
* Get the selected options for this dropdown. These are the values that were
|
||||
* selected by a human user via a PDF reader, or programatically via
|
||||
* software.
|
||||
* For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* const selections = dropdown.getSelected()
|
||||
* console.log('Dropdown selections:', selections)
|
||||
* ```
|
||||
* > **NOTE:** Note that PDF readers only display one selected option when
|
||||
* > rendering dropdowns. However, the PDF specification does allow for
|
||||
* > multiple values to be selected in a dropdown. As such, the `pdf-lib`
|
||||
* > API supports this. However, in most cases the array returned by this
|
||||
* > method will contain only a single element (or no elements).
|
||||
* @returns The selected options in this dropdown.
|
||||
*/
|
||||
getSelected(): string[];
|
||||
/**
|
||||
* Set the list of options that are available for this dropdown. These are
|
||||
* the values that will be available for users to select when they view this
|
||||
* dropdown in a PDF reader. Note that preexisting options for this dropdown
|
||||
* will be removed. Only the values passed as `options` will be available to
|
||||
* select.
|
||||
* For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('planets.dropdown')
|
||||
* dropdown.setOptions(['Earth', 'Mars', 'Pluto', 'Venus'])
|
||||
* ```
|
||||
* @param options The options that should be available in this dropdown.
|
||||
*/
|
||||
setOptions(options: string[]): void;
|
||||
/**
|
||||
* Add to the list of options that are available for this dropdown. Users
|
||||
* will be able to select these values in a PDF reader. In addition to the
|
||||
* values passed as `options`, any preexisting options for this dropdown will
|
||||
* still be available for users to select.
|
||||
* For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('rockets.dropdown')
|
||||
* dropdown.addOptions(['Saturn IV', 'Falcon Heavy'])
|
||||
* ```
|
||||
* @param options New options that should be available in this dropdown.
|
||||
*/
|
||||
addOptions(options: string | string[]): void;
|
||||
/**
|
||||
* Select one or more values for this dropdown. This operation is analogous
|
||||
* to a human user opening the dropdown in a PDF reader and clicking on a
|
||||
* value to select it. This method will update the underlying state of the
|
||||
* dropdown to indicate which values have been selected. PDF libraries and
|
||||
* readers will be able to extract these values from the saved document and
|
||||
* determine which values were selected.
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('best.superhero.dropdown')
|
||||
* dropdown.select('One Punch Man')
|
||||
* ```
|
||||
*
|
||||
* This method will mark this dropdown as dirty, causing its appearance
|
||||
* streams to be updated when either [[PDFDocument.save]] or
|
||||
* [[PDFForm.updateFieldAppearances]] is called. The updated streams will
|
||||
* display the selected option inside the widgets of this dropdown.
|
||||
*
|
||||
* **IMPORTANT:** The default font used to update appearance streams is
|
||||
* [[StandardFonts.Helvetica]]. Note that this is a WinAnsi font. This means
|
||||
* that encoding errors will be thrown if the selected option for this field
|
||||
* contains characters outside the WinAnsi character set (the latin alphabet).
|
||||
*
|
||||
* Embedding a custom font and passing it to
|
||||
* [[PDFForm.updateFieldAppearances]] or [[PDFDropdown.updateAppearances]]
|
||||
* allows you to generate appearance streams with characters outside the
|
||||
* latin alphabet (assuming the custom font supports them).
|
||||
*
|
||||
* Selecting an option that does not exist in this dropdown's option list
|
||||
* (see [[PDFDropdown.getOptions]]) will enable editing on this dropdown
|
||||
* (see [[PDFDropdown.enableEditing]]).
|
||||
*
|
||||
* > **NOTE:** PDF readers only display one selected option when rendering
|
||||
* > dropdowns. However, the PDF specification does allow for multiple values
|
||||
* > to be selected in a dropdown. As such, the `pdf-lib` API supports this.
|
||||
* > However, it is not recommended to select more than one value with this
|
||||
* > method, as only one will be visible. [[PDFOptionList]] fields are better
|
||||
* > suited for displaying multiple selected values.
|
||||
*
|
||||
* @param options The options to be selected.
|
||||
* @param merge Whether or not existing selections should be preserved.
|
||||
*/
|
||||
select(options: string | string[], merge?: boolean): void;
|
||||
/**
|
||||
* Clear all selected values for this dropdown. This operation is equivalent
|
||||
* to selecting an empty list. This method will update the underlying state
|
||||
* of the dropdown to indicate that no values have been selected.
|
||||
* For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* dropdown.clear()
|
||||
* ```
|
||||
* This method will mark this text field as dirty. See [[PDFDropdown.select]]
|
||||
* for more details about what this means.
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* Set the font size for this field. Larger font sizes will result in larger
|
||||
* text being displayed when PDF readers render this dropdown. Font sizes may
|
||||
* be integer or floating point numbers. Supplying a negative font size will
|
||||
* cause this method to throw an error.
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* dropdown.setFontSize(4)
|
||||
* dropdown.setFontSize(15.7)
|
||||
* ```
|
||||
*
|
||||
* > This method depends upon the existence of a default appearance
|
||||
* > (`/DA`) string. If this field does not have a default appearance string,
|
||||
* > or that string does not contain a font size (via the `Tf` operator),
|
||||
* > then this method will throw an error.
|
||||
*
|
||||
* @param fontSize The font size to be used when rendering text in this field.
|
||||
*/
|
||||
setFontSize(fontSize: number): void;
|
||||
/**
|
||||
* Returns `true` if users are allowed to edit the selected value of this
|
||||
* dropdown directly and are not constrained by the list of available
|
||||
* options. See [[PDFDropdown.enableEditing]] and
|
||||
* [[PDFDropdown.disableEditing]]. For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* if (dropdown.isEditable()) console.log('Editing is enabled')
|
||||
* ```
|
||||
* @returns Whether or not this dropdown is editable.
|
||||
*/
|
||||
isEditable(): boolean;
|
||||
/**
|
||||
* Allow users to edit the selected value of this dropdown in PDF readers
|
||||
* with their keyboard. This means that the selected value of this dropdown
|
||||
* will not be constrained by the list of available options. However, if this
|
||||
* dropdown has any available options, users will still be allowed to select
|
||||
* from that list.
|
||||
* For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* dropdown.enableEditing()
|
||||
* ```
|
||||
*/
|
||||
enableEditing(): void;
|
||||
/**
|
||||
* Do not allow users to edit the selected value of this dropdown in PDF
|
||||
* readers with their keyboard. This will constrain the selected value of
|
||||
* this dropdown to the list of available options. Users will only be able
|
||||
* to select an option from that list.
|
||||
* For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* dropdown.disableEditing()
|
||||
* ```
|
||||
*/
|
||||
disableEditing(): void;
|
||||
/**
|
||||
* Returns `true` if the option list of this dropdown is always displayed
|
||||
* in alphabetical order, irrespective of the order in which the options
|
||||
* were added to the dropdown. See [[PDFDropdown.enableSorting]] and
|
||||
* [[PDFDropdown.disableSorting]]. For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* if (dropdown.isSorted()) console.log('Sorting is enabled')
|
||||
* ```
|
||||
* @returns Whether or not this dropdown's options are sorted.
|
||||
*/
|
||||
isSorted(): boolean;
|
||||
/**
|
||||
* Always display the option list of this dropdown in alphabetical order,
|
||||
* irrespective of the order in which the options were added to this dropdown.
|
||||
* For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* dropdown.enableSorting()
|
||||
* ```
|
||||
*/
|
||||
enableSorting(): void;
|
||||
/**
|
||||
* Do not always display the option list of this dropdown in alphabetical
|
||||
* order. Instead, display the options in whichever order they were added
|
||||
* to the list. For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* dropdown.disableSorting()
|
||||
* ```
|
||||
*/
|
||||
disableSorting(): void;
|
||||
/**
|
||||
* Returns `true` if multiple options can be selected from this dropdown's
|
||||
* option list. See [[PDFDropdown.enableMultiselect]] and
|
||||
* [[PDFDropdown.disableMultiselect]]. For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* if (dropdown.isMultiselect()) console.log('Multiselect is enabled')
|
||||
* ```
|
||||
* @returns Whether or not multiple options can be selected.
|
||||
*/
|
||||
isMultiselect(): boolean;
|
||||
/**
|
||||
* Allow users to select more than one option from this dropdown's option
|
||||
* list. For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* dropdown.enableMultiselect()
|
||||
* ```
|
||||
*/
|
||||
enableMultiselect(): void;
|
||||
/**
|
||||
* Do not allow users to select more than one option from this dropdown's
|
||||
* option list. For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* dropdown.disableMultiselect()
|
||||
* ```
|
||||
*/
|
||||
disableMultiselect(): void;
|
||||
/**
|
||||
* Returns `true` if the selected option should be spell checked by PDF
|
||||
* readers. Spell checking will only be performed if this dropdown allows
|
||||
* editing (see [[PDFDropdown.isEditable]]). See
|
||||
* [[PDFDropdown.enableSpellChecking]] and
|
||||
* [[PDFDropdown.disableSpellChecking]]. For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* if (dropdown.isSpellChecked()) console.log('Spell checking is enabled')
|
||||
* ```
|
||||
* @returns Whether or not this dropdown can be spell checked.
|
||||
*/
|
||||
isSpellChecked(): boolean;
|
||||
/**
|
||||
* Allow PDF readers to spell check the selected option of this dropdown.
|
||||
* For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* dropdown.enableSpellChecking()
|
||||
* ```
|
||||
*/
|
||||
enableSpellChecking(): void;
|
||||
/**
|
||||
* Do not allow PDF readers to spell check the selected option of this
|
||||
* dropdown. For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* dropdown.disableSpellChecking()
|
||||
* ```
|
||||
*/
|
||||
disableSpellChecking(): void;
|
||||
/**
|
||||
* Returns `true` if the option selected by a user is stored, or "committed",
|
||||
* when the user clicks the option. The alternative is that the user's
|
||||
* selection is stored when the user leaves this dropdown field (by clicking
|
||||
* outside of it - on another field, for example). See
|
||||
* [[PDFDropdown.enableSelectOnClick]] and
|
||||
* [[PDFDropdown.disableSelectOnClick]]. For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* if (dropdown.isSelectOnClick()) console.log('Select on click is enabled')
|
||||
* ```
|
||||
* @returns Whether or not options are selected immediately after they are
|
||||
* clicked.
|
||||
*/
|
||||
isSelectOnClick(): boolean;
|
||||
/**
|
||||
* Store the option selected by a user immediately after the user clicks the
|
||||
* option. Do not wait for the user to leave this dropdown field (by clicking
|
||||
* outside of it - on another field, for example). For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* dropdown.enableSelectOnClick()
|
||||
* ```
|
||||
*/
|
||||
enableSelectOnClick(): void;
|
||||
/**
|
||||
* Wait to store the option selected by a user until they leave this dropdown
|
||||
* field (by clicking outside of it - on another field, for example).
|
||||
* For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* dropdown.disableSelectOnClick()
|
||||
* ```
|
||||
*/
|
||||
disableSelectOnClick(): void;
|
||||
/**
|
||||
* Show this dropdown on the specified page. For example:
|
||||
* ```js
|
||||
* const ubuntuFont = await pdfDoc.embedFont(ubuntuFontBytes)
|
||||
* const page = pdfDoc.addPage()
|
||||
*
|
||||
* const form = pdfDoc.getForm()
|
||||
* const dropdown = form.createDropdown('best.gundam')
|
||||
* dropdown.setOptions(['Exia', 'Dynames'])
|
||||
* dropdown.select('Exia')
|
||||
*
|
||||
* dropdown.addToPage(page, {
|
||||
* x: 50,
|
||||
* y: 75,
|
||||
* width: 200,
|
||||
* height: 100,
|
||||
* textColor: rgb(1, 0, 0),
|
||||
* backgroundColor: rgb(0, 1, 0),
|
||||
* borderColor: rgb(0, 0, 1),
|
||||
* borderWidth: 2,
|
||||
* rotate: degrees(90),
|
||||
* font: ubuntuFont,
|
||||
* })
|
||||
* ```
|
||||
* This will create a new widget for this dropdown field.
|
||||
* @param page The page to which this dropdown widget should be added.
|
||||
* @param options The options to be used when adding this dropdown widget.
|
||||
*/
|
||||
addToPage(page: PDFPage, options?: FieldAppearanceOptions): void;
|
||||
/**
|
||||
* Returns `true` if this dropdown has been marked as dirty, or if any of
|
||||
* this dropdown's widgets do not have an appearance stream. For example:
|
||||
* ```js
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* if (dropdown.needsAppearancesUpdate()) console.log('Needs update')
|
||||
* ```
|
||||
* @returns Whether or not this dropdown needs an appearance update.
|
||||
*/
|
||||
needsAppearancesUpdate(): boolean;
|
||||
/**
|
||||
* Update the appearance streams for each of this dropdown's widgets using
|
||||
* the default appearance provider for dropdowns. For example:
|
||||
* ```js
|
||||
* const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* dropdown.defaultUpdateAppearances(helvetica)
|
||||
* ```
|
||||
* @param font The font to be used for creating the appearance streams.
|
||||
*/
|
||||
defaultUpdateAppearances(font: PDFFont): void;
|
||||
/**
|
||||
* Update the appearance streams for each of this dropdown's widgets using
|
||||
* the given appearance provider. If no `provider` is passed, the default
|
||||
* appearance provider for dropdowns will be used. For example:
|
||||
* ```js
|
||||
* const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)
|
||||
* const dropdown = form.getDropdown('some.dropdown.field')
|
||||
* dropdown.updateAppearances(helvetica, (field, widget, font) => {
|
||||
* ...
|
||||
* return drawTextField(...)
|
||||
* })
|
||||
* ```
|
||||
* @param font The font to be used for creating the appearance streams.
|
||||
* @param provider Optionally, the appearance provider to be used for
|
||||
* generating the contents of the appearance streams.
|
||||
*/
|
||||
updateAppearances(font: PDFFont, provider?: AppearanceProviderFor<PDFDropdown>): void;
|
||||
private updateWidgetAppearance;
|
||||
}
|
||||
//# sourceMappingURL=PDFDropdown.d.ts.map
|
||||
204
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFField.d.ts
generated
vendored
Normal file
204
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFField.d.ts
generated
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
import PDFDocument from "../PDFDocument";
|
||||
import PDFFont from "../PDFFont";
|
||||
import { AppearanceMapping } from "./appearances";
|
||||
import { Color } from "../colors";
|
||||
import { Rotation } from "../rotations";
|
||||
import { PDFRef, PDFWidgetAnnotation, PDFOperator, PDFName, PDFDict, PDFAcroTerminal } from "../../core";
|
||||
import { ImageAlignment } from '../image';
|
||||
import PDFImage from '../PDFImage';
|
||||
export interface FieldAppearanceOptions {
|
||||
x?: number;
|
||||
y?: number;
|
||||
width?: number;
|
||||
height?: number;
|
||||
textColor?: Color;
|
||||
backgroundColor?: Color;
|
||||
borderColor?: Color;
|
||||
borderWidth?: number;
|
||||
rotate?: Rotation;
|
||||
font?: PDFFont;
|
||||
hidden?: boolean;
|
||||
}
|
||||
export declare const assertFieldAppearanceOptions: (options?: FieldAppearanceOptions | undefined) => void;
|
||||
/**
|
||||
* Represents a field of a [[PDFForm]].
|
||||
*
|
||||
* This class is effectively abstract. All fields in a [[PDFForm]] will
|
||||
* actually be an instance of a subclass of this class.
|
||||
*
|
||||
* Note that each field in a PDF is represented by a single field object.
|
||||
* However, a given field object may be rendered at multiple locations within
|
||||
* the document (across one or more pages). The rendering of a field is
|
||||
* controlled by its widgets. Each widget causes its field to be displayed at a
|
||||
* particular location in the document.
|
||||
*
|
||||
* Most of the time each field in a PDF has only a single widget, and thus is
|
||||
* only rendered once. However, if a field is rendered multiple times, it will
|
||||
* have multiple widgets - one for each location it is rendered.
|
||||
*
|
||||
* This abstraction of field objects and widgets is defined in the PDF
|
||||
* specification and dictates how PDF files store fields and where they are
|
||||
* to be rendered.
|
||||
*/
|
||||
export default class PDFField {
|
||||
/** The low-level PDFAcroTerminal wrapped by this field. */
|
||||
readonly acroField: PDFAcroTerminal;
|
||||
/** The unique reference assigned to this field within the document. */
|
||||
readonly ref: PDFRef;
|
||||
/** The document to which this field belongs. */
|
||||
readonly doc: PDFDocument;
|
||||
protected constructor(acroField: PDFAcroTerminal, ref: PDFRef, doc: PDFDocument);
|
||||
/**
|
||||
* Get the fully qualified name of this field. For example:
|
||||
* ```js
|
||||
* const fields = form.getFields()
|
||||
* fields.forEach(field => {
|
||||
* const name = field.getName()
|
||||
* console.log('Field name:', name)
|
||||
* })
|
||||
* ```
|
||||
* Note that PDF fields are structured as a tree. Each field is the
|
||||
* descendent of a series of ancestor nodes all the way up to the form node,
|
||||
* which is always the root of the tree. Each node in the tree (except for
|
||||
* the form node) has a partial name. Partial names can be composed of any
|
||||
* unicode characters except a period (`.`). The fully qualified name of a
|
||||
* field is composed of the partial names of all its ancestors joined
|
||||
* with periods. This means that splitting the fully qualified name on
|
||||
* periods and taking the last element of the resulting array will give you
|
||||
* the partial name of a specific field.
|
||||
* @returns The fully qualified name of this field.
|
||||
*/
|
||||
getName(): string;
|
||||
/**
|
||||
* Returns `true` if this field is read only. This means that PDF readers
|
||||
* will not allow users to interact with the field or change its value. See
|
||||
* [[PDFField.enableReadOnly]] and [[PDFField.disableReadOnly]].
|
||||
* For example:
|
||||
* ```js
|
||||
* const field = form.getField('some.field')
|
||||
* if (field.isReadOnly()) console.log('Read only is enabled')
|
||||
* ```
|
||||
* @returns Whether or not this is a read only field.
|
||||
*/
|
||||
isReadOnly(): boolean;
|
||||
/**
|
||||
* Prevent PDF readers from allowing users to interact with this field or
|
||||
* change its value. The field will not respond to mouse or keyboard input.
|
||||
* For example:
|
||||
* ```js
|
||||
* const field = form.getField('some.field')
|
||||
* field.enableReadOnly()
|
||||
* ```
|
||||
* Useful for fields whose values are computed, imported from a database, or
|
||||
* prefilled by software before being displayed to the user.
|
||||
*/
|
||||
enableReadOnly(): void;
|
||||
/**
|
||||
* Allow users to interact with this field and change its value in PDF
|
||||
* readers via mouse and keyboard input. For example:
|
||||
* ```js
|
||||
* const field = form.getField('some.field')
|
||||
* field.disableReadOnly()
|
||||
* ```
|
||||
*/
|
||||
disableReadOnly(): void;
|
||||
/**
|
||||
* Returns `true` if this field must have a value when the form is submitted.
|
||||
* See [[PDFField.enableRequired]] and [[PDFField.disableRequired]].
|
||||
* For example:
|
||||
* ```js
|
||||
* const field = form.getField('some.field')
|
||||
* if (field.isRequired()) console.log('Field is required')
|
||||
* ```
|
||||
* @returns Whether or not this field is required.
|
||||
*/
|
||||
isRequired(): boolean;
|
||||
/**
|
||||
* Require this field to have a value when the form is submitted.
|
||||
* For example:
|
||||
* ```js
|
||||
* const field = form.getField('some.field')
|
||||
* field.enableRequired()
|
||||
* ```
|
||||
*/
|
||||
enableRequired(): void;
|
||||
/**
|
||||
* Do not require this field to have a value when the form is submitted.
|
||||
* For example:
|
||||
* ```js
|
||||
* const field = form.getField('some.field')
|
||||
* field.disableRequired()
|
||||
* ```
|
||||
*/
|
||||
disableRequired(): void;
|
||||
/**
|
||||
* Returns `true` if this field's value should be exported when the form is
|
||||
* submitted. See [[PDFField.enableExporting]] and
|
||||
* [[PDFField.disableExporting]].
|
||||
* For example:
|
||||
* ```js
|
||||
* const field = form.getField('some.field')
|
||||
* if (field.isExported()) console.log('Exporting is enabled')
|
||||
* ```
|
||||
* @returns Whether or not this field's value should be exported.
|
||||
*/
|
||||
isExported(): boolean;
|
||||
/**
|
||||
* Indicate that this field's value should be exported when the form is
|
||||
* submitted in a PDF reader. For example:
|
||||
* ```js
|
||||
* const field = form.getField('some.field')
|
||||
* field.enableExporting()
|
||||
* ```
|
||||
*/
|
||||
enableExporting(): void;
|
||||
/**
|
||||
* Indicate that this field's value should **not** be exported when the form
|
||||
* is submitted in a PDF reader. For example:
|
||||
* ```js
|
||||
* const field = form.getField('some.field')
|
||||
* field.disableExporting()
|
||||
* ```
|
||||
*/
|
||||
disableExporting(): void;
|
||||
/** @ignore */
|
||||
needsAppearancesUpdate(): boolean;
|
||||
/** @ignore */
|
||||
defaultUpdateAppearances(_font: PDFFont): void;
|
||||
protected markAsDirty(): void;
|
||||
protected markAsClean(): void;
|
||||
protected isDirty(): boolean;
|
||||
protected createWidget(options: {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
textColor?: Color;
|
||||
backgroundColor?: Color;
|
||||
borderColor?: Color;
|
||||
borderWidth: number;
|
||||
rotate: Rotation;
|
||||
caption?: string;
|
||||
hidden?: boolean;
|
||||
page?: PDFRef;
|
||||
}): PDFWidgetAnnotation;
|
||||
protected updateWidgetAppearanceWithFont(widget: PDFWidgetAnnotation, font: PDFFont, { normal, rollover, down }: AppearanceMapping<PDFOperator[]>): void;
|
||||
protected updateOnOffWidgetAppearance(widget: PDFWidgetAnnotation, onValue: PDFName, { normal, rollover, down, }: AppearanceMapping<{
|
||||
on: PDFOperator[];
|
||||
off: PDFOperator[];
|
||||
}>): void;
|
||||
protected updateWidgetAppearances(widget: PDFWidgetAnnotation, { normal, rollover, down }: AppearanceMapping<PDFRef | PDFDict>): void;
|
||||
private createAppearanceStream;
|
||||
/**
|
||||
* Create a FormXObject of the supplied image and add it to context.
|
||||
* The FormXObject size is calculated based on the widget (including
|
||||
* the alignment).
|
||||
* @param widget The widget that should display the image.
|
||||
* @param alignment The alignment of the image.
|
||||
* @param image The image that should be displayed.
|
||||
* @returns The ref for the FormXObject that was added to the context.
|
||||
*/
|
||||
protected createImageAppearanceStream(widget: PDFWidgetAnnotation, image: PDFImage, alignment: ImageAlignment): PDFRef;
|
||||
private createAppearanceDict;
|
||||
}
|
||||
//# sourceMappingURL=PDFField.d.ts.map
|
||||
412
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFForm.d.ts
generated
vendored
Normal file
412
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFForm.d.ts
generated
vendored
Normal file
@@ -0,0 +1,412 @@
|
||||
import PDFDocument from "../PDFDocument";
|
||||
import PDFField from "./PDFField";
|
||||
import PDFButton from "./PDFButton";
|
||||
import PDFCheckBox from "./PDFCheckBox";
|
||||
import PDFDropdown from "./PDFDropdown";
|
||||
import PDFOptionList from "./PDFOptionList";
|
||||
import PDFRadioGroup from "./PDFRadioGroup";
|
||||
import PDFSignature from "./PDFSignature";
|
||||
import PDFTextField from "./PDFTextField";
|
||||
import PDFFont from "../PDFFont";
|
||||
import { PDFAcroForm, PDFRef } from "../../core";
|
||||
export interface FlattenOptions {
|
||||
updateFieldAppearances: boolean;
|
||||
}
|
||||
/**
|
||||
* Represents the interactive form of a [[PDFDocument]].
|
||||
*
|
||||
* Interactive forms (sometimes called _AcroForms_) are collections of fields
|
||||
* designed to gather information from a user. A PDF document may contains any
|
||||
* number of fields that appear on various pages, all of which make up a single,
|
||||
* global interactive form spanning the entire document. This means that
|
||||
* instances of [[PDFDocument]] shall contain at most one [[PDFForm]].
|
||||
*
|
||||
* The fields of an interactive form are represented by [[PDFField]] instances.
|
||||
*/
|
||||
export default class PDFForm {
|
||||
/**
|
||||
* > **NOTE:** You probably don't want to call this method directly. Instead,
|
||||
* > consider using the [[PDFDocument.getForm]] method, which will create an
|
||||
* > instance of [[PDFForm]] for you.
|
||||
*
|
||||
* Create an instance of [[PDFForm]] from an existing acroForm and embedder
|
||||
*
|
||||
* @param acroForm The underlying `PDFAcroForm` for this form.
|
||||
* @param doc The document to which the form will belong.
|
||||
*/
|
||||
static of: (acroForm: PDFAcroForm, doc: PDFDocument) => PDFForm;
|
||||
/** The low-level PDFAcroForm wrapped by this form. */
|
||||
readonly acroForm: PDFAcroForm;
|
||||
/** The document to which this form belongs. */
|
||||
readonly doc: PDFDocument;
|
||||
private readonly dirtyFields;
|
||||
private readonly defaultFontCache;
|
||||
private constructor();
|
||||
/**
|
||||
* Returns `true` if this [[PDFForm]] has XFA data. Most PDFs with form
|
||||
* fields do not use XFA as it is not widely supported by PDF readers.
|
||||
*
|
||||
* > `pdf-lib` does not support creation, modification, or reading of XFA
|
||||
* > fields.
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm()
|
||||
* if (form.hasXFA()) console.log('PDF has XFA data')
|
||||
* ```
|
||||
* @returns Whether or not this form has XFA data.
|
||||
*/
|
||||
hasXFA(): boolean;
|
||||
/**
|
||||
* Disconnect the XFA data from this [[PDFForm]] (if any exists). This will
|
||||
* force readers to fallback to standard fields if the [[PDFDocument]]
|
||||
* contains any. For example:
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm()
|
||||
* form.deleteXFA()
|
||||
* ```
|
||||
*/
|
||||
deleteXFA(): void;
|
||||
/**
|
||||
* Get all fields contained in this [[PDFForm]]. For example:
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm()
|
||||
* const fields = form.getFields()
|
||||
* fields.forEach(field => {
|
||||
* const type = field.constructor.name
|
||||
* const name = field.getName()
|
||||
* console.log(`${type}: ${name}`)
|
||||
* })
|
||||
* ```
|
||||
* @returns An array of all fields in this form.
|
||||
*/
|
||||
getFields(): PDFField[];
|
||||
/**
|
||||
* Get the field in this [[PDFForm]] with the given name. For example:
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm()
|
||||
* const field = form.getFieldMaybe('Page1.Foo.Bar[0]')
|
||||
* if (field) console.log('Field exists!')
|
||||
* ```
|
||||
* @param name A fully qualified field name.
|
||||
* @returns The field with the specified name, if one exists.
|
||||
*/
|
||||
getFieldMaybe(name: string): PDFField | undefined;
|
||||
/**
|
||||
* Get the field in this [[PDFForm]] with the given name. For example:
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm()
|
||||
* const field = form.getField('Page1.Foo.Bar[0]')
|
||||
* ```
|
||||
* If no field exists with the provided name, an error will be thrown.
|
||||
* @param name A fully qualified field name.
|
||||
* @returns The field with the specified name.
|
||||
*/
|
||||
getField(name: string): PDFField;
|
||||
/**
|
||||
* Get the button field in this [[PDFForm]] with the given name. For example:
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm()
|
||||
* const button = form.getButton('Page1.Foo.Button[0]')
|
||||
* ```
|
||||
* An error will be thrown if no field exists with the provided name, or if
|
||||
* the field exists but is not a button.
|
||||
* @param name A fully qualified button name.
|
||||
* @returns The button with the specified name.
|
||||
*/
|
||||
getButton(name: string): PDFButton;
|
||||
/**
|
||||
* Get the check box field in this [[PDFForm]] with the given name.
|
||||
* For example:
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm()
|
||||
* const checkBox = form.getCheckBox('Page1.Foo.CheckBox[0]')
|
||||
* checkBox.check()
|
||||
* ```
|
||||
* An error will be thrown if no field exists with the provided name, or if
|
||||
* the field exists but is not a check box.
|
||||
* @param name A fully qualified check box name.
|
||||
* @returns The check box with the specified name.
|
||||
*/
|
||||
getCheckBox(name: string): PDFCheckBox;
|
||||
/**
|
||||
* Get the dropdown field in this [[PDFForm]] with the given name.
|
||||
* For example:
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm()
|
||||
* const dropdown = form.getDropdown('Page1.Foo.Dropdown[0]')
|
||||
* const options = dropdown.getOptions()
|
||||
* dropdown.select(options[0])
|
||||
* ```
|
||||
* An error will be thrown if no field exists with the provided name, or if
|
||||
* the field exists but is not a dropdown.
|
||||
* @param name A fully qualified dropdown name.
|
||||
* @returns The dropdown with the specified name.
|
||||
*/
|
||||
getDropdown(name: string): PDFDropdown;
|
||||
/**
|
||||
* Get the option list field in this [[PDFForm]] with the given name.
|
||||
* For example:
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm()
|
||||
* const optionList = form.getOptionList('Page1.Foo.OptionList[0]')
|
||||
* const options = optionList.getOptions()
|
||||
* optionList.select(options[0])
|
||||
* ```
|
||||
* An error will be thrown if no field exists with the provided name, or if
|
||||
* the field exists but is not an option list.
|
||||
* @param name A fully qualified option list name.
|
||||
* @returns The option list with the specified name.
|
||||
*/
|
||||
getOptionList(name: string): PDFOptionList;
|
||||
/**
|
||||
* Get the radio group field in this [[PDFForm]] with the given name.
|
||||
* For example:
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm()
|
||||
* const radioGroup = form.getRadioGroup('Page1.Foo.RadioGroup[0]')
|
||||
* const options = radioGroup.getOptions()
|
||||
* radioGroup.select(options[0])
|
||||
* ```
|
||||
* An error will be thrown if no field exists with the provided name, or if
|
||||
* the field exists but is not a radio group.
|
||||
* @param name A fully qualified radio group name.
|
||||
* @returns The radio group with the specified name.
|
||||
*/
|
||||
getRadioGroup(name: string): PDFRadioGroup;
|
||||
/**
|
||||
* Get the signature field in this [[PDFForm]] with the given name.
|
||||
* For example:
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm()
|
||||
* const signature = form.getSignature('Page1.Foo.Signature[0]')
|
||||
* ```
|
||||
* An error will be thrown if no field exists with the provided name, or if
|
||||
* the field exists but is not a signature.
|
||||
* @param name A fully qualified signature name.
|
||||
* @returns The signature with the specified name.
|
||||
*/
|
||||
getSignature(name: string): PDFSignature;
|
||||
/**
|
||||
* Get the text field in this [[PDFForm]] with the given name.
|
||||
* For example:
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm()
|
||||
* const textField = form.getTextField('Page1.Foo.TextField[0]')
|
||||
* textField.setText('Are you designed to act or to be acted upon?')
|
||||
* ```
|
||||
* An error will be thrown if no field exists with the provided name, or if
|
||||
* the field exists but is not a text field.
|
||||
* @param name A fully qualified text field name.
|
||||
* @returns The text field with the specified name.
|
||||
*/
|
||||
getTextField(name: string): PDFTextField;
|
||||
/**
|
||||
* Create a new button field in this [[PDFForm]] with the given name.
|
||||
* For example:
|
||||
* ```js
|
||||
* const font = await pdfDoc.embedFont(StandardFonts.Helvetica)
|
||||
* const page = pdfDoc.addPage()
|
||||
*
|
||||
* const form = pdfDoc.getForm()
|
||||
* const button = form.createButton('cool.new.button')
|
||||
*
|
||||
* button.addToPage('Do Stuff', font, page)
|
||||
* ```
|
||||
* An error will be thrown if a field already exists with the provided name.
|
||||
* @param name The fully qualified name for the new button.
|
||||
* @returns The new button field.
|
||||
*/
|
||||
createButton(name: string): PDFButton;
|
||||
/**
|
||||
* Create a new check box field in this [[PDFForm]] with the given name.
|
||||
* For example:
|
||||
* ```js
|
||||
* const font = await pdfDoc.embedFont(StandardFonts.Helvetica)
|
||||
* const page = pdfDoc.addPage()
|
||||
*
|
||||
* const form = pdfDoc.getForm()
|
||||
* const checkBox = form.createCheckBox('cool.new.checkBox')
|
||||
*
|
||||
* checkBox.addToPage(page)
|
||||
* ```
|
||||
* An error will be thrown if a field already exists with the provided name.
|
||||
* @param name The fully qualified name for the new check box.
|
||||
* @returns The new check box field.
|
||||
*/
|
||||
createCheckBox(name: string): PDFCheckBox;
|
||||
/**
|
||||
* Create a new dropdown field in this [[PDFForm]] with the given name.
|
||||
* For example:
|
||||
* ```js
|
||||
* const font = await pdfDoc.embedFont(StandardFonts.Helvetica)
|
||||
* const page = pdfDoc.addPage()
|
||||
*
|
||||
* const form = pdfDoc.getForm()
|
||||
* const dropdown = form.createDropdown('cool.new.dropdown')
|
||||
*
|
||||
* dropdown.addToPage(font, page)
|
||||
* ```
|
||||
* An error will be thrown if a field already exists with the provided name.
|
||||
* @param name The fully qualified name for the new dropdown.
|
||||
* @returns The new dropdown field.
|
||||
*/
|
||||
createDropdown(name: string): PDFDropdown;
|
||||
/**
|
||||
* Create a new option list field in this [[PDFForm]] with the given name.
|
||||
* For example:
|
||||
* ```js
|
||||
* const font = await pdfDoc.embedFont(StandardFonts.Helvetica)
|
||||
* const page = pdfDoc.addPage()
|
||||
*
|
||||
* const form = pdfDoc.getForm()
|
||||
* const optionList = form.createOptionList('cool.new.optionList')
|
||||
*
|
||||
* optionList.addToPage(font, page)
|
||||
* ```
|
||||
* An error will be thrown if a field already exists with the provided name.
|
||||
* @param name The fully qualified name for the new option list.
|
||||
* @returns The new option list field.
|
||||
*/
|
||||
createOptionList(name: string): PDFOptionList;
|
||||
/**
|
||||
* Create a new radio group field in this [[PDFForm]] with the given name.
|
||||
* For example:
|
||||
* ```js
|
||||
* const font = await pdfDoc.embedFont(StandardFonts.Helvetica)
|
||||
* const page = pdfDoc.addPage()
|
||||
*
|
||||
* const form = pdfDoc.getForm()
|
||||
* const radioGroup = form.createRadioGroup('cool.new.radioGroup')
|
||||
*
|
||||
* radioGroup.addOptionToPage('is-dog', page, { y: 0 })
|
||||
* radioGroup.addOptionToPage('is-cat', page, { y: 75 })
|
||||
* ```
|
||||
* An error will be thrown if a field already exists with the provided name.
|
||||
* @param name The fully qualified name for the new radio group.
|
||||
* @returns The new radio group field.
|
||||
*/
|
||||
createRadioGroup(name: string): PDFRadioGroup;
|
||||
/**
|
||||
* Create a new text field in this [[PDFForm]] with the given name.
|
||||
* For example:
|
||||
* ```js
|
||||
* const font = await pdfDoc.embedFont(StandardFonts.Helvetica)
|
||||
* const page = pdfDoc.addPage()
|
||||
*
|
||||
* const form = pdfDoc.getForm()
|
||||
* const textField = form.createTextField('cool.new.textField')
|
||||
*
|
||||
* textField.addToPage(font, page)
|
||||
* ```
|
||||
* An error will be thrown if a field already exists with the provided name.
|
||||
* @param name The fully qualified name for the new radio group.
|
||||
* @returns The new radio group field.
|
||||
*/
|
||||
createTextField(name: string): PDFTextField;
|
||||
/**
|
||||
* Flatten all fields in this [[PDFForm]].
|
||||
*
|
||||
* Flattening a form field will take the current appearance for each of that
|
||||
* field's widgets and make them part of their page's content stream. All form
|
||||
* fields and annotations associated are then removed. Note that once a form
|
||||
* has been flattened its fields can no longer be accessed or edited.
|
||||
*
|
||||
* This operation is often used after filling form fields to ensure a
|
||||
* consistent appearance across different PDF readers and/or printers.
|
||||
* Another common use case is to copy a template document with form fields
|
||||
* into another document. In this scenario you would load the template
|
||||
* document, fill its fields, flatten it, and then copy its pages into the
|
||||
* recipient document - the filled fields will be copied over.
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm();
|
||||
* form.flatten();
|
||||
* ```
|
||||
*/
|
||||
flatten(options?: FlattenOptions): void;
|
||||
/**
|
||||
* Remove a field from this [[PDFForm]].
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm();
|
||||
* const ageField = form.getFields().find(x => x.getName() === 'Age');
|
||||
* form.removeField(ageField);
|
||||
* ```
|
||||
*/
|
||||
removeField(field: PDFField): void;
|
||||
/**
|
||||
* Update the appearance streams for all widgets of all fields in this
|
||||
* [[PDFForm]]. Appearance streams will only be created for a widget if it
|
||||
* does not have any existing appearance streams, or the field's value has
|
||||
* changed (e.g. by calling [[PDFTextField.setText]] or
|
||||
* [[PDFDropdown.select]]).
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const courier = await pdfDoc.embedFont(StandardFonts.Courier)
|
||||
* const form = pdfDoc.getForm()
|
||||
* form.updateFieldAppearances(courier)
|
||||
* ```
|
||||
*
|
||||
* **IMPORTANT:** The default value for the `font` parameter is
|
||||
* [[StandardFonts.Helvetica]]. Note that this is a WinAnsi font. This means
|
||||
* that encoding errors will be thrown if any fields contain text with
|
||||
* characters outside the WinAnsi character set (the latin alphabet).
|
||||
*
|
||||
* Embedding a custom font and passing that as the `font`
|
||||
* parameter allows you to generate appearance streams with non WinAnsi
|
||||
* characters (assuming your custom font supports them).
|
||||
*
|
||||
* > **NOTE:** The [[PDFDocument.save]] method will call this method to
|
||||
* > update appearances automatically if a form was accessed via the
|
||||
* > [[PDFDocument.getForm]] method prior to saving.
|
||||
*
|
||||
* @param font Optionally, the font to use when creating new appearances.
|
||||
*/
|
||||
updateFieldAppearances(font?: PDFFont): void;
|
||||
/**
|
||||
* Mark a field as dirty. This will cause its appearance streams to be
|
||||
* updated by [[PDFForm.updateFieldAppearances]].
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm()
|
||||
* const field = form.getField('foo.bar')
|
||||
* form.markFieldAsDirty(field.ref)
|
||||
* ```
|
||||
* @param fieldRef The reference to the field that should be marked.
|
||||
*/
|
||||
markFieldAsDirty(fieldRef: PDFRef): void;
|
||||
/**
|
||||
* Mark a field as dirty. This will cause its appearance streams to not be
|
||||
* updated by [[PDFForm.updateFieldAppearances]].
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm()
|
||||
* const field = form.getField('foo.bar')
|
||||
* form.markFieldAsClean(field.ref)
|
||||
* ```
|
||||
* @param fieldRef The reference to the field that should be marked.
|
||||
*/
|
||||
markFieldAsClean(fieldRef: PDFRef): void;
|
||||
/**
|
||||
* Returns `true` is the specified field has been marked as dirty.
|
||||
* ```js
|
||||
* const form = pdfDoc.getForm()
|
||||
* const field = form.getField('foo.bar')
|
||||
* if (form.fieldIsDirty(field.ref)) console.log('Field is dirty')
|
||||
* ```
|
||||
* @param fieldRef The reference to the field that should be checked.
|
||||
* @returns Whether or not the specified field is dirty.
|
||||
*/
|
||||
fieldIsDirty(fieldRef: PDFRef): boolean;
|
||||
getDefaultFont(): PDFFont;
|
||||
private findWidgetPage;
|
||||
private findWidgetAppearanceRef;
|
||||
private findOrCreateNonTerminals;
|
||||
private findNonTerminal;
|
||||
private embedDefaultFont;
|
||||
}
|
||||
//# sourceMappingURL=PDFForm.d.ts.map
|
||||
336
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFOptionList.d.ts
generated
vendored
Normal file
336
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFOptionList.d.ts
generated
vendored
Normal file
@@ -0,0 +1,336 @@
|
||||
import PDFDocument from "../PDFDocument";
|
||||
import PDFPage from "../PDFPage";
|
||||
import PDFFont from "../PDFFont";
|
||||
import PDFField, { FieldAppearanceOptions } from "./PDFField";
|
||||
import { AppearanceProviderFor } from "./appearances";
|
||||
import { PDFRef, PDFAcroListBox } from "../../core";
|
||||
/**
|
||||
* Represents an option list field of a [[PDFForm]].
|
||||
*
|
||||
* [[PDFOptionList]] fields are interactive lists of options. The purpose of an
|
||||
* option list is to enable users to select one or more options from a set of
|
||||
* possible options. Users are able to see the full set of options without
|
||||
* first having to click on the field (though scrolling may be necessary).
|
||||
* Clicking an option in the list will cause it to be selected and displayed
|
||||
* with a highlighted background. Some option lists allow users to select
|
||||
* more than one option (see [[PDFOptionList.isMultiselect]]).
|
||||
*/
|
||||
export default class PDFOptionList extends PDFField {
|
||||
/**
|
||||
* > **NOTE:** You probably don't want to call this method directly. Instead,
|
||||
* > consider using the [[PDFForm.getOptionList]] method, which will create
|
||||
* > an instance of [[PDFOptionList]] for you.
|
||||
*
|
||||
* Create an instance of [[PDFOptionList]] from an existing acroListBox and
|
||||
* ref
|
||||
*
|
||||
* @param acroComboBox The underlying `PDFAcroListBox` for this option list.
|
||||
* @param ref The unique reference for this option list.
|
||||
* @param doc The document to which this option list will belong.
|
||||
*/
|
||||
static of: (acroListBox: PDFAcroListBox, ref: PDFRef, doc: PDFDocument) => PDFOptionList;
|
||||
/** The low-level PDFAcroListBox wrapped by this option list. */
|
||||
readonly acroField: PDFAcroListBox;
|
||||
private constructor();
|
||||
/**
|
||||
* Get the list of available options for this option list. These options will
|
||||
* be displayed to users who view this option list in a PDF reader.
|
||||
* For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* const options = optionList.getOptions()
|
||||
* console.log('Option List options:', options)
|
||||
* ```
|
||||
* @returns The options for this option list.
|
||||
*/
|
||||
getOptions(): string[];
|
||||
/**
|
||||
* Get the selected options for this option list. These are the values that
|
||||
* were selected by a human user via a PDF reader, or programatically via
|
||||
* software.
|
||||
* For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* const selections = optionList.getSelected()
|
||||
* console.log('Option List selections:', selections)
|
||||
* ```
|
||||
* @returns The selected options for this option list.
|
||||
*/
|
||||
getSelected(): string[];
|
||||
/**
|
||||
* Set the list of options that are available for this option list. These are
|
||||
* the values that will be available for users to select when they view this
|
||||
* option list in a PDF reader. Note that preexisting options for this
|
||||
* option list will be removed. Only the values passed as `options` will be
|
||||
* available to select.
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('planets.optionList')
|
||||
* optionList.setOptions(['Earth', 'Mars', 'Pluto', 'Venus'])
|
||||
* ```
|
||||
*
|
||||
* This method will mark this option list as dirty, causing its appearance
|
||||
* streams to be updated when either [[PDFDocument.save]] or
|
||||
* [[PDFForm.updateFieldAppearances]] is called. The updated streams will
|
||||
* display the options this field contains inside the widgets of this text
|
||||
* field (with selected options highlighted).
|
||||
*
|
||||
* **IMPORTANT:** The default font used to update appearance streams is
|
||||
* [[StandardFonts.Helvetica]]. Note that this is a WinAnsi font. This means
|
||||
* that encoding errors will be thrown if this field contains any options
|
||||
* with characters outside the WinAnsi character set (the latin alphabet).
|
||||
*
|
||||
* Embedding a custom font and passing it to
|
||||
* [[PDFForm.updateFieldAppearances]] or [[PDFOptionList.updateAppearances]]
|
||||
* allows you to generate appearance streams with characters outside the
|
||||
* latin alphabet (assuming the custom font supports them).
|
||||
*
|
||||
* @param options The options that should be available in this option list.
|
||||
*/
|
||||
setOptions(options: string[]): void;
|
||||
/**
|
||||
* Add to the list of options that are available for this option list. Users
|
||||
* will be able to select these values in a PDF reader. In addition to the
|
||||
* values passed as `options`, any preexisting options for this option list
|
||||
* will still be available for users to select.
|
||||
* For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('rockets.optionList')
|
||||
* optionList.addOptions(['Saturn IV', 'Falcon Heavy'])
|
||||
* ```
|
||||
* This method will mark this option list as dirty. See
|
||||
* [[PDFOptionList.setOptions]] for more details about what this means.
|
||||
* @param options New options that should be available in this option list.
|
||||
*/
|
||||
addOptions(options: string | string[]): void;
|
||||
/**
|
||||
* Select one or more values for this option list. This operation is analogous
|
||||
* to a human user opening the option list in a PDF reader and clicking on one
|
||||
* or more values to select them. This method will update the underlying state
|
||||
* of the option list to indicate which values have been selected. PDF
|
||||
* libraries and readers will be able to extract these values from the saved
|
||||
* document and determine which values were selected.
|
||||
* For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('best.superheroes.optionList')
|
||||
* optionList.select(['One Punch Man', 'Iron Man'])
|
||||
* ```
|
||||
* This method will mark this option list as dirty. See
|
||||
* [[PDFOptionList.setOptions]] for more details about what this means.
|
||||
* @param options The options to be selected.
|
||||
* @param merge Whether or not existing selections should be preserved.
|
||||
*/
|
||||
select(options: string | string[], merge?: boolean): void;
|
||||
/**
|
||||
* Clear all selected values for this option list. This operation is
|
||||
* equivalent to selecting an empty list. This method will update the
|
||||
* underlying state of the option list to indicate that no values have been
|
||||
* selected.
|
||||
* For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* optionList.clear()
|
||||
* ```
|
||||
* This method will mark this option list as dirty. See
|
||||
* [[PDFOptionList.setOptions]] for more details about what this means.
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* Set the font size for the text in this field. There needs to be a
|
||||
* default appearance string (DA) set with a font value specified
|
||||
* for this to work. For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* optionList.setFontSize(4);
|
||||
* ```
|
||||
* @param fontSize The font size to set the font to.
|
||||
*/
|
||||
/**
|
||||
* Set the font size for this field. Larger font sizes will result in larger
|
||||
* text being displayed when PDF readers render this option list. Font sizes
|
||||
* may be integer or floating point numbers. Supplying a negative font size
|
||||
* will cause this method to throw an error.
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* optionList.setFontSize(4)
|
||||
* optionList.setFontSize(15.7)
|
||||
* ```
|
||||
*
|
||||
* > This method depends upon the existence of a default appearance
|
||||
* > (`/DA`) string. If this field does not have a default appearance string,
|
||||
* > or that string does not contain a font size (via the `Tf` operator),
|
||||
* > then this method will throw an error.
|
||||
*
|
||||
* @param fontSize The font size to be used when rendering text in this field.
|
||||
*/
|
||||
setFontSize(fontSize: number): void;
|
||||
/**
|
||||
* Returns `true` if the options of this option list are always displayed
|
||||
* in alphabetical order, irrespective of the order in which the options
|
||||
* were added to the option list. See [[PDFOptionList.enableSorting]] and
|
||||
* [[PDFOptionList.disableSorting]]. For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* if (optionList.isSorted()) console.log('Sorting is enabled')
|
||||
* ```
|
||||
* @returns Whether or not this option list is sorted.
|
||||
*/
|
||||
isSorted(): boolean;
|
||||
/**
|
||||
* Always display the options of this option list in alphabetical order,
|
||||
* irrespective of the order in which the options were added to this option
|
||||
* list.
|
||||
* For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* optionList.enableSorting()
|
||||
* ```
|
||||
*/
|
||||
enableSorting(): void;
|
||||
/**
|
||||
* Do not always display the options of this option list in alphabetical
|
||||
* order. Instead, display the options in whichever order they were added
|
||||
* to this option list. For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* optionList.disableSorting()
|
||||
* ```
|
||||
*/
|
||||
disableSorting(): void;
|
||||
/**
|
||||
* Returns `true` if multiple options can be selected from this option list.
|
||||
* See [[PDFOptionList.enableMultiselect]] and
|
||||
* [[PDFOptionList.disableMultiselect]]. For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* if (optionList.isMultiselect()) console.log('Multiselect is enabled')
|
||||
* ```
|
||||
* @returns Whether or not multiple options can be selected.
|
||||
*/
|
||||
isMultiselect(): boolean;
|
||||
/**
|
||||
* Allow users to select more than one option from this option list.
|
||||
* For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* optionList.enableMultiselect()
|
||||
* ```
|
||||
*/
|
||||
enableMultiselect(): void;
|
||||
/**
|
||||
* Do not allow users to select more than one option from this option list.
|
||||
* For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* optionList.disableMultiselect()
|
||||
* ```
|
||||
*/
|
||||
disableMultiselect(): void;
|
||||
/**
|
||||
* Returns `true` if the option selected by a user is stored, or "committed",
|
||||
* when the user clicks the option. The alternative is that the user's
|
||||
* selection is stored when the user leaves this option list field (by
|
||||
* clicking outside of it - on another field, for example). See
|
||||
* [[PDFOptionList.enableSelectOnClick]] and
|
||||
* [[PDFOptionList.disableSelectOnClick]]. For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* if (optionList.isSelectOnClick()) console.log('Select on click is enabled')
|
||||
* ```
|
||||
* @returns Whether or not options are selected immediately after they are
|
||||
* clicked.
|
||||
*/
|
||||
isSelectOnClick(): boolean;
|
||||
/**
|
||||
* Store the option selected by a user immediately after the user clicks the
|
||||
* option. Do not wait for the user to leave this option list field (by
|
||||
* clicking outside of it - on another field, for example). For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* optionList.enableSelectOnClick()
|
||||
* ```
|
||||
*/
|
||||
enableSelectOnClick(): void;
|
||||
/**
|
||||
* Wait to store the option selected by a user until they leave this option
|
||||
* list field (by clicking outside of it - on another field, for example).
|
||||
* For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* optionList.disableSelectOnClick()
|
||||
* ```
|
||||
*/
|
||||
disableSelectOnClick(): void;
|
||||
/**
|
||||
* Show this option list on the specified page. For example:
|
||||
* ```js
|
||||
* const ubuntuFont = await pdfDoc.embedFont(ubuntuFontBytes)
|
||||
* const page = pdfDoc.addPage()
|
||||
*
|
||||
* const form = pdfDoc.getForm()
|
||||
* const optionList = form.createOptionList('best.gundams')
|
||||
* optionList.setOptions(['Exia', 'Dynames', 'Kyrios', 'Virtue'])
|
||||
* optionList.select(['Exia', 'Virtue'])
|
||||
*
|
||||
* optionList.addToPage(page, {
|
||||
* x: 50,
|
||||
* y: 75,
|
||||
* width: 200,
|
||||
* height: 100,
|
||||
* textColor: rgb(1, 0, 0),
|
||||
* backgroundColor: rgb(0, 1, 0),
|
||||
* borderColor: rgb(0, 0, 1),
|
||||
* borderWidth: 2,
|
||||
* rotate: degrees(90),
|
||||
* font: ubuntuFont,
|
||||
* })
|
||||
* ```
|
||||
* This will create a new widget for this option list field.
|
||||
* @param page The page to which this option list widget should be added.
|
||||
* @param options The options to be used when adding this option list widget.
|
||||
*/
|
||||
addToPage(page: PDFPage, options?: FieldAppearanceOptions): void;
|
||||
/**
|
||||
* Returns `true` if this option list has been marked as dirty, or if any of
|
||||
* this option list's widgets do not have an appearance stream. For example:
|
||||
* ```js
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* if (optionList.needsAppearancesUpdate()) console.log('Needs update')
|
||||
* ```
|
||||
* @returns Whether or not this option list needs an appearance update.
|
||||
*/
|
||||
needsAppearancesUpdate(): boolean;
|
||||
/**
|
||||
* Update the appearance streams for each of this option list's widgets using
|
||||
* the default appearance provider for option lists. For example:
|
||||
* ```js
|
||||
* const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* optionList.defaultUpdateAppearances(helvetica)
|
||||
* ```
|
||||
* @param font The font to be used for creating the appearance streams.
|
||||
*/
|
||||
defaultUpdateAppearances(font: PDFFont): void;
|
||||
/**
|
||||
* Update the appearance streams for each of this option list's widgets using
|
||||
* the given appearance provider. If no `provider` is passed, the default
|
||||
* appearance provider for option lists will be used. For example:
|
||||
* ```js
|
||||
* const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)
|
||||
* const optionList = form.getOptionList('some.optionList.field')
|
||||
* optionList.updateAppearances(helvetica, (field, widget, font) => {
|
||||
* ...
|
||||
* return drawOptionList(...)
|
||||
* })
|
||||
* ```
|
||||
* @param font The font to be used for creating the appearance streams.
|
||||
* @param provider Optionally, the appearance provider to be used for
|
||||
* generating the contents of the appearance streams.
|
||||
*/
|
||||
updateAppearances(font: PDFFont, provider?: AppearanceProviderFor<PDFOptionList>): void;
|
||||
private updateWidgetAppearance;
|
||||
}
|
||||
//# sourceMappingURL=PDFOptionList.d.ts.map
|
||||
253
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFRadioGroup.d.ts
generated
vendored
Normal file
253
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFRadioGroup.d.ts
generated
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
import PDFDocument from "../PDFDocument";
|
||||
import PDFPage from "../PDFPage";
|
||||
import PDFField, { FieldAppearanceOptions } from "./PDFField";
|
||||
import { AppearanceProviderFor } from "./appearances";
|
||||
import { PDFRef, PDFAcroRadioButton } from "../../core";
|
||||
/**
|
||||
* Represents a radio group field of a [[PDFForm]].
|
||||
*
|
||||
* [[PDFRadioGroup]] fields are collections of radio buttons. The purpose of a
|
||||
* radio group is to enable users to select one option from a set of mutually
|
||||
* exclusive choices. Each choice in a radio group is represented by a radio
|
||||
* button. Radio buttons each have two states: `on` and `off`. At most one
|
||||
* radio button in a group may be in the `on` state at any time. Users can
|
||||
* click on a radio button to select it (and thereby automatically deselect any
|
||||
* other radio button that might have already been selected). Some radio
|
||||
* groups allow users to toggle a selected radio button `off` by clicking on
|
||||
* it (see [[PDFRadioGroup.isOffToggleable]]).
|
||||
*
|
||||
* Note that some radio groups allow multiple radio buttons to be in the `on`
|
||||
* state at the same type **if** they represent the same underlying value (see
|
||||
* [[PDFRadioGroup.isMutuallyExclusive]]).
|
||||
*/
|
||||
export default class PDFRadioGroup extends PDFField {
|
||||
/**
|
||||
* > **NOTE:** You probably don't want to call this method directly. Instead,
|
||||
* > consider using the [[PDFForm.getOptionList]] method, which will create an
|
||||
* > instance of [[PDFOptionList]] for you.
|
||||
*
|
||||
* Create an instance of [[PDFOptionList]] from an existing acroRadioButton
|
||||
* and ref
|
||||
*
|
||||
* @param acroRadioButton The underlying `PDFAcroRadioButton` for this
|
||||
* radio group.
|
||||
* @param ref The unique reference for this radio group.
|
||||
* @param doc The document to which this radio group will belong.
|
||||
*/
|
||||
static of: (acroRadioButton: PDFAcroRadioButton, ref: PDFRef, doc: PDFDocument) => PDFRadioGroup;
|
||||
/** The low-level PDFAcroRadioButton wrapped by this radio group. */
|
||||
readonly acroField: PDFAcroRadioButton;
|
||||
private constructor();
|
||||
/**
|
||||
* Get the list of available options for this radio group. Each option is
|
||||
* represented by a radio button. These radio buttons are displayed at
|
||||
* various locations in the document, potentially on different pages (though
|
||||
* typically they are stacked horizontally or vertically on the same page).
|
||||
* For example:
|
||||
* ```js
|
||||
* const radioGroup = form.getRadioGroup('some.radioGroup.field')
|
||||
* const options = radioGroup.getOptions()
|
||||
* console.log('Radio Group options:', options)
|
||||
* ```
|
||||
* @returns The options for this radio group.
|
||||
*/
|
||||
getOptions(): string[];
|
||||
/**
|
||||
* Get the selected option for this radio group. The selected option is
|
||||
* represented by the radio button in this group that is turned on. At most
|
||||
* one radio button in a group can be selected. If no buttons in this group
|
||||
* are selected, `undefined` is returned.
|
||||
* For example:
|
||||
* ```js
|
||||
* const radioGroup = form.getRadioGroup('some.radioGroup.field')
|
||||
* const selected = radioGroup.getSelected()
|
||||
* console.log('Selected radio button:', selected)
|
||||
* ```
|
||||
* @returns The selected option for this radio group.
|
||||
*/
|
||||
getSelected(): string | undefined;
|
||||
/**
|
||||
* Select an option for this radio group. This operation is analogous to a
|
||||
* human user clicking one of the radio buttons in this group via a PDF
|
||||
* reader to toggle it on. This method will update the underlying state of
|
||||
* the radio group to indicate which option has been selected. PDF libraries
|
||||
* and readers will be able to extract this value from the saved document and
|
||||
* determine which option was selected.
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const radioGroup = form.getRadioGroup('best.superhero.radioGroup')
|
||||
* radioGroup.select('One Punch Man')
|
||||
* ```
|
||||
*
|
||||
* This method will mark this radio group as dirty, causing its appearance
|
||||
* streams to be updated when either [[PDFDocument.save]] or
|
||||
* [[PDFForm.updateFieldAppearances]] is called. The updated appearance
|
||||
* streams will display a dot inside the widget of this check box field
|
||||
* that represents the selected option.
|
||||
*
|
||||
* @param option The option to be selected.
|
||||
*/
|
||||
select(option: string): void;
|
||||
/**
|
||||
* Clear any selected option for this dropdown. This will result in all
|
||||
* radio buttons in this group being toggled off. This method will update
|
||||
* the underlying state of the dropdown to indicate that no radio buttons
|
||||
* have been selected.
|
||||
* For example:
|
||||
* ```js
|
||||
* const radioGroup = form.getRadioGroup('some.radioGroup.field')
|
||||
* radioGroup.clear()
|
||||
* ```
|
||||
* This method will mark this radio group as dirty. See
|
||||
* [[PDFRadioGroup.select]] for more details about what this means.
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* Returns `true` if users can click on radio buttons in this group to toggle
|
||||
* them off. The alternative is that once a user clicks on a radio button
|
||||
* to select it, the only way to deselect it is by selecting on another radio
|
||||
* button in the group. See [[PDFRadioGroup.enableOffToggling]] and
|
||||
* [[PDFRadioGroup.disableOffToggling]]. For example:
|
||||
* ```js
|
||||
* const radioGroup = form.getRadioGroup('some.radioGroup.field')
|
||||
* if (radioGroup.isOffToggleable()) console.log('Off toggling is enabled')
|
||||
* ```
|
||||
*/
|
||||
isOffToggleable(): boolean;
|
||||
/**
|
||||
* Allow users to click on selected radio buttons in this group to toggle
|
||||
* them off. For example:
|
||||
* ```js
|
||||
* const radioGroup = form.getRadioGroup('some.radioGroup.field')
|
||||
* radioGroup.enableOffToggling()
|
||||
* ```
|
||||
* > **NOTE:** This feature is documented in the PDF specification
|
||||
* > (Table 226). However, most PDF readers do not respect this option and
|
||||
* > prevent users from toggling radio buttons off even when it is enabled.
|
||||
* > At the time of this writing (9/6/2020) Mac's Preview software did
|
||||
* > respect the option. Adobe Acrobat, Foxit Reader, and Google Chrome did
|
||||
* > not.
|
||||
*/
|
||||
enableOffToggling(): void;
|
||||
/**
|
||||
* Prevent users from clicking on selected radio buttons in this group to
|
||||
* toggle them off. Clicking on a selected radio button will have no effect.
|
||||
* The only way to deselect a selected radio button is to click on a
|
||||
* different radio button in the group. For example:
|
||||
* ```js
|
||||
* const radioGroup = form.getRadioGroup('some.radioGroup.field')
|
||||
* radioGroup.disableOffToggling()
|
||||
* ```
|
||||
*/
|
||||
disableOffToggling(): void;
|
||||
/**
|
||||
* Returns `true` if the radio buttons in this group are mutually exclusive.
|
||||
* This means that when the user selects a radio button, only that specific
|
||||
* button will be turned on. Even if other radio buttons in the group
|
||||
* represent the same value, they will not be enabled. The alternative to
|
||||
* this is that clicking a radio button will select that button along with
|
||||
* any other radio buttons in the group that share the same value. See
|
||||
* [[PDFRadioGroup.enableMutualExclusion]] and
|
||||
* [[PDFRadioGroup.disableMutualExclusion]].
|
||||
* For example:
|
||||
* ```js
|
||||
* const radioGroup = form.getRadioGroup('some.radioGroup.field')
|
||||
* if (radioGroup.isMutuallyExclusive()) console.log('Mutual exclusion is enabled')
|
||||
* ```
|
||||
*/
|
||||
isMutuallyExclusive(): boolean;
|
||||
/**
|
||||
* When the user clicks a radio button in this group it will be selected. In
|
||||
* addition, any other radio buttons in this group that share the same
|
||||
* underlying value will also be selected. For example:
|
||||
* ```js
|
||||
* const radioGroup = form.getRadioGroup('some.radioGroup.field')
|
||||
* radioGroup.enableMutualExclusion()
|
||||
* ```
|
||||
* Note that this option must be enabled prior to adding options to the
|
||||
* radio group. It does not currently apply retroactively to existing
|
||||
* radio buttons in the group.
|
||||
*/
|
||||
enableMutualExclusion(): void;
|
||||
/**
|
||||
* When the user clicks a radio button in this group only it will be selected.
|
||||
* No other radio buttons in the group will be selected, even if they share
|
||||
* the same underlying value. For example:
|
||||
* ```js
|
||||
* const radioGroup = form.getRadioGroup('some.radioGroup.field')
|
||||
* radioGroup.disableMutualExclusion()
|
||||
* ```
|
||||
* Note that this option must be disabled prior to adding options to the
|
||||
* radio group. It does not currently apply retroactively to existing
|
||||
* radio buttons in the group.
|
||||
*/
|
||||
disableMutualExclusion(): void;
|
||||
/**
|
||||
* Add a new radio button to this group on the specified page. For example:
|
||||
* ```js
|
||||
* const page = pdfDoc.addPage()
|
||||
*
|
||||
* const form = pdfDoc.getForm()
|
||||
* const radioGroup = form.createRadioGroup('best.gundam')
|
||||
*
|
||||
* const options = {
|
||||
* x: 50,
|
||||
* width: 25,
|
||||
* height: 25,
|
||||
* textColor: rgb(1, 0, 0),
|
||||
* backgroundColor: rgb(0, 1, 0),
|
||||
* borderColor: rgb(0, 0, 1),
|
||||
* borderWidth: 2,
|
||||
* rotate: degrees(90),
|
||||
* }
|
||||
*
|
||||
* radioGroup.addOptionToPage('Exia', page, { ...options, y: 50 })
|
||||
* radioGroup.addOptionToPage('Dynames', page, { ...options, y: 110 })
|
||||
* ```
|
||||
* This will create a new radio button widget for this radio group field.
|
||||
* @param option The option that the radio button widget represents.
|
||||
* @param page The page to which the radio button widget should be added.
|
||||
* @param options The options to be used when adding the radio button widget.
|
||||
*/
|
||||
addOptionToPage(option: string, page: PDFPage, options?: FieldAppearanceOptions): void;
|
||||
/**
|
||||
* Returns `true` if any of this group's radio button widgets do not have an
|
||||
* appearance stream for their current state. For example:
|
||||
* ```js
|
||||
* const radioGroup = form.getRadioGroup('some.radioGroup.field')
|
||||
* if (radioGroup.needsAppearancesUpdate()) console.log('Needs update')
|
||||
* ```
|
||||
* @returns Whether or not this radio group needs an appearance update.
|
||||
*/
|
||||
needsAppearancesUpdate(): boolean;
|
||||
/**
|
||||
* Update the appearance streams for each of this group's radio button widgets
|
||||
* using the default appearance provider for radio groups. For example:
|
||||
* ```js
|
||||
* const radioGroup = form.getRadioGroup('some.radioGroup.field')
|
||||
* radioGroup.defaultUpdateAppearances()
|
||||
* ```
|
||||
*/
|
||||
defaultUpdateAppearances(): void;
|
||||
/**
|
||||
* Update the appearance streams for each of this group's radio button widgets
|
||||
* using the given appearance provider. If no `provider` is passed, the
|
||||
* default appearance provider for radio groups will be used. For example:
|
||||
* ```js
|
||||
* const radioGroup = form.getRadioGroup('some.radioGroup.field')
|
||||
* radioGroup.updateAppearances((field, widget) => {
|
||||
* ...
|
||||
* return {
|
||||
* normal: { on: drawRadioButton(...), off: drawRadioButton(...) },
|
||||
* down: { on: drawRadioButton(...), off: drawRadioButton(...) },
|
||||
* }
|
||||
* })
|
||||
* ```
|
||||
* @param provider Optionally, the appearance provider to be used for
|
||||
* generating the contents of the appearance streams.
|
||||
*/
|
||||
updateAppearances(provider?: AppearanceProviderFor<PDFRadioGroup>): void;
|
||||
private updateWidgetAppearance;
|
||||
}
|
||||
//# sourceMappingURL=PDFRadioGroup.d.ts.map
|
||||
30
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFSignature.d.ts
generated
vendored
Normal file
30
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFSignature.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import PDFDocument from "../PDFDocument";
|
||||
import PDFField from "./PDFField";
|
||||
import { PDFRef, PDFAcroSignature } from "../../core";
|
||||
/**
|
||||
* Represents a signature field of a [[PDFForm]].
|
||||
*
|
||||
* [[PDFSignature]] fields are digital signatures. `pdf-lib` does not
|
||||
* currently provide any specialized APIs for creating digital signatures or
|
||||
* reading the contents of existing digital signatures.
|
||||
*/
|
||||
export default class PDFSignature extends PDFField {
|
||||
/**
|
||||
* > **NOTE:** You probably don't want to call this method directly. Instead,
|
||||
* > consider using the [[PDFForm.getSignature]] method, which will create an
|
||||
* > instance of [[PDFSignature]] for you.
|
||||
*
|
||||
* Create an instance of [[PDFSignature]] from an existing acroSignature and
|
||||
* ref
|
||||
*
|
||||
* @param acroSignature The underlying `PDFAcroSignature` for this signature.
|
||||
* @param ref The unique reference for this signature.
|
||||
* @param doc The document to which this signature will belong.
|
||||
*/
|
||||
static of: (acroSignature: PDFAcroSignature, ref: PDFRef, doc: PDFDocument) => PDFSignature;
|
||||
/** The low-level PDFAcroSignature wrapped by this signature. */
|
||||
readonly acroField: PDFAcroSignature;
|
||||
private constructor();
|
||||
needsAppearancesUpdate(): boolean;
|
||||
}
|
||||
//# sourceMappingURL=PDFSignature.d.ts.map
|
||||
538
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFTextField.d.ts
generated
vendored
Normal file
538
node_modules/pdf-lib/ts3.4/cjs/api/form/PDFTextField.d.ts
generated
vendored
Normal file
@@ -0,0 +1,538 @@
|
||||
import PDFDocument from "../PDFDocument";
|
||||
import PDFPage from "../PDFPage";
|
||||
import PDFFont from "../PDFFont";
|
||||
import PDFImage from "../PDFImage";
|
||||
import PDFField, { FieldAppearanceOptions } from "./PDFField";
|
||||
import { AppearanceProviderFor } from "./appearances";
|
||||
import { TextAlignment } from "../text/alignment";
|
||||
import { PDFRef, PDFAcroText } from "../../core";
|
||||
/**
|
||||
* Represents a text field of a [[PDFForm]].
|
||||
*
|
||||
* [[PDFTextField]] fields are boxes that display text entered by the user. The
|
||||
* purpose of a text field is to enable users to enter text or view text values
|
||||
* in the document prefilled by software. Users can click on a text field and
|
||||
* input text via their keyboard. Some text fields allow multiple lines of text
|
||||
* to be entered (see [[PDFTextField.isMultiline]]).
|
||||
*/
|
||||
export default class PDFTextField extends PDFField {
|
||||
/**
|
||||
* > **NOTE:** You probably don't want to call this method directly. Instead,
|
||||
* > consider using the [[PDFForm.getTextField]] method, which will create an
|
||||
* > instance of [[PDFTextField]] for you.
|
||||
*
|
||||
* Create an instance of [[PDFTextField]] from an existing acroText and ref
|
||||
*
|
||||
* @param acroText The underlying `PDFAcroText` for this text field.
|
||||
* @param ref The unique reference for this text field.
|
||||
* @param doc The document to which this text field will belong.
|
||||
*/
|
||||
static of: (acroText: PDFAcroText, ref: PDFRef, doc: PDFDocument) => PDFTextField;
|
||||
/** The low-level PDFAcroText wrapped by this text field. */
|
||||
readonly acroField: PDFAcroText;
|
||||
private constructor();
|
||||
/**
|
||||
* Get the text that this field contains. This text is visible to users who
|
||||
* view this field in a PDF reader.
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* const text = textField.getText()
|
||||
* console.log('Text field contents:', text)
|
||||
* ```
|
||||
*
|
||||
* Note that if this text field contains no underlying value, `undefined`
|
||||
* will be returned. Text fields may also contain an underlying value that
|
||||
* is simply an empty string (`''`). This detail is largely irrelevant for
|
||||
* most applications. In general, you'll want to treat both cases the same
|
||||
* way and simply consider the text field to be empty. In either case, the
|
||||
* text field will appear empty to users when viewed in a PDF reader.
|
||||
*
|
||||
* An error will be thrown if this is a rich text field. `pdf-lib` does not
|
||||
* support reading rich text fields. Nor do most PDF readers and writers.
|
||||
* Rich text fields are based on XFA (XML Forms Architecture). Relatively few
|
||||
* PDFs use rich text fields or XFA. Unlike PDF itself, XFA is not an ISO
|
||||
* standard. XFA has been deprecated in PDF 2.0:
|
||||
* * https://en.wikipedia.org/wiki/XFA
|
||||
* * http://blog.pdfshareforms.com/pdf-2-0-release-bid-farewell-xfa-forms/
|
||||
*
|
||||
* @returns The text contained in this text field.
|
||||
*/
|
||||
getText(): string | undefined;
|
||||
/**
|
||||
* Set the text for this field. This operation is analogous to a human user
|
||||
* clicking on the text field in a PDF reader and typing in text via their
|
||||
* keyboard. This method will update the underlying state of the text field
|
||||
* to indicate what text has been set. PDF libraries and readers will be able
|
||||
* to extract these values from the saved document and determine what text
|
||||
* was set.
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('best.superhero.text.field')
|
||||
* textField.setText('One Punch Man')
|
||||
* ```
|
||||
*
|
||||
* This method will mark this text field as dirty, causing its appearance
|
||||
* streams to be updated when either [[PDFDocument.save]] or
|
||||
* [[PDFForm.updateFieldAppearances]] is called. The updated streams will
|
||||
* display the text this field contains inside the widgets of this text
|
||||
* field.
|
||||
*
|
||||
* **IMPORTANT:** The default font used to update appearance streams is
|
||||
* [[StandardFonts.Helvetica]]. Note that this is a WinAnsi font. This means
|
||||
* that encoding errors will be thrown if this field contains text outside
|
||||
* the WinAnsi character set (the latin alphabet).
|
||||
*
|
||||
* Embedding a custom font and passing it to
|
||||
* [[PDFForm.updateFieldAppearances]] or [[PDFTextField.updateAppearances]]
|
||||
* allows you to generate appearance streams with characters outside the
|
||||
* latin alphabet (assuming the custom font supports them).
|
||||
*
|
||||
* If this is a rich text field, it will be converted to a standard text
|
||||
* field in order to set the text. `pdf-lib` does not support writing rich
|
||||
* text strings. Nor do most PDF readers and writers. See
|
||||
* [[PDFTextField.getText]] for more information about rich text fields and
|
||||
* their deprecation in PDF 2.0.
|
||||
*
|
||||
* @param text The text this field should contain.
|
||||
*/
|
||||
setText(text: string | undefined): void;
|
||||
/**
|
||||
* Get the alignment for this text field. This value represents the
|
||||
* justification of the text when it is displayed to the user in PDF readers.
|
||||
* There are three possible alignments: left, center, and right. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* const alignment = textField.getAlignment()
|
||||
* if (alignment === TextAlignment.Left) console.log('Text is left justified')
|
||||
* if (alignment === TextAlignment.Center) console.log('Text is centered')
|
||||
* if (alignment === TextAlignment.Right) console.log('Text is right justified')
|
||||
* ```
|
||||
* @returns The alignment of this text field.
|
||||
*/
|
||||
getAlignment(): TextAlignment;
|
||||
/**
|
||||
* Set the alignment for this text field. This will determine the
|
||||
* justification of the text when it is displayed to the user in PDF readers.
|
||||
* There are three possible alignments: left, center, and right. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
*
|
||||
* // Text will be left justified when displayed
|
||||
* textField.setAlignment(TextAlignment.Left)
|
||||
*
|
||||
* // Text will be centered when displayed
|
||||
* textField.setAlignment(TextAlignment.Center)
|
||||
*
|
||||
* // Text will be right justified when displayed
|
||||
* textField.setAlignment(TextAlignment.Right)
|
||||
* ```
|
||||
* This method will mark this text field as dirty. See
|
||||
* [[PDFTextField.setText]] for more details about what this means.
|
||||
* @param alignment The alignment for this text field.
|
||||
*/
|
||||
setAlignment(alignment: TextAlignment): void;
|
||||
/**
|
||||
* Get the maximum length of this field. This value represents the maximum
|
||||
* number of characters that can be typed into this field by the user. If
|
||||
* this field does not have a maximum length, `undefined` is returned.
|
||||
* For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* const maxLength = textField.getMaxLength()
|
||||
* if (maxLength === undefined) console.log('No max length')
|
||||
* else console.log(`Max length is ${maxLength}`)
|
||||
* ```
|
||||
* @returns The maximum number of characters allowed in this field, or
|
||||
* `undefined` if no limit exists.
|
||||
*/
|
||||
getMaxLength(): number | undefined;
|
||||
/**
|
||||
* Set the maximum length of this field. This limits the number of characters
|
||||
* that can be typed into this field by the user. This also limits the length
|
||||
* of the string that can be passed to [[PDFTextField.setText]]. This limit
|
||||
* can be removed by passing `undefined` as `maxLength`. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
*
|
||||
* // Allow between 0 and 5 characters to be entered
|
||||
* textField.setMaxLength(5)
|
||||
*
|
||||
* // Allow any number of characters to be entered
|
||||
* textField.setMaxLength(undefined)
|
||||
* ```
|
||||
* This method will mark this text field as dirty. See
|
||||
* [[PDFTextField.setText]] for more details about what this means.
|
||||
* @param maxLength The maximum number of characters allowed in this field, or
|
||||
* `undefined` to remove the limit.
|
||||
*/
|
||||
setMaxLength(maxLength?: number): void;
|
||||
/**
|
||||
* Remove the maximum length for this text field. This allows any number of
|
||||
* characters to be typed into this field by the user. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.removeMaxLength()
|
||||
* ```
|
||||
* Calling this method is equivalent to passing `undefined` to
|
||||
* [[PDFTextField.setMaxLength]].
|
||||
*/
|
||||
removeMaxLength(): void;
|
||||
/**
|
||||
* Display an image inside the bounds of this text field's widgets. For example:
|
||||
* ```js
|
||||
* const pngImage = await pdfDoc.embedPng(...)
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.setImage(pngImage)
|
||||
* ```
|
||||
* This will update the appearances streams for each of this text field's widgets.
|
||||
* @param image The image that should be displayed.
|
||||
*/
|
||||
setImage(image: PDFImage): void;
|
||||
/**
|
||||
* Set the font size for this field. Larger font sizes will result in larger
|
||||
* text being displayed when PDF readers render this text field. Font sizes
|
||||
* may be integer or floating point numbers. Supplying a negative font size
|
||||
* will cause this method to throw an error.
|
||||
*
|
||||
* For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.setFontSize(4)
|
||||
* textField.setFontSize(15.7)
|
||||
* ```
|
||||
*
|
||||
* > This method depends upon the existence of a default appearance
|
||||
* > (`/DA`) string. If this field does not have a default appearance string,
|
||||
* > or that string does not contain a font size (via the `Tf` operator),
|
||||
* > then this method will throw an error.
|
||||
*
|
||||
* @param fontSize The font size to be used when rendering text in this field.
|
||||
*/
|
||||
setFontSize(fontSize: number): void;
|
||||
/**
|
||||
* Returns `true` if each line of text is shown on a new line when this
|
||||
* field is displayed in a PDF reader. The alternative is that all lines of
|
||||
* text are merged onto a single line when displayed. See
|
||||
* [[PDFTextField.enableMultiline]] and [[PDFTextField.disableMultiline]].
|
||||
* For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* if (textField.isMultiline()) console.log('Multiline is enabled')
|
||||
* ```
|
||||
* @returns Whether or not this is a multiline text field.
|
||||
*/
|
||||
isMultiline(): boolean;
|
||||
/**
|
||||
* Display each line of text on a new line when this field is displayed in a
|
||||
* PDF reader. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.enableMultiline()
|
||||
* ```
|
||||
* This method will mark this text field as dirty. See
|
||||
* [[PDFTextField.setText]] for more details about what this means.
|
||||
*/
|
||||
enableMultiline(): void;
|
||||
/**
|
||||
* Display each line of text on the same line when this field is displayed
|
||||
* in a PDF reader. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.disableMultiline()
|
||||
* ```
|
||||
* This method will mark this text field as dirty. See
|
||||
* [[PDFTextField.setText]] for more details about what this means.
|
||||
*/
|
||||
disableMultiline(): void;
|
||||
/**
|
||||
* Returns `true` if this is a password text field. This means that the field
|
||||
* is intended for storing a secure password. See
|
||||
* [[PDFTextField.enablePassword]] and [[PDFTextField.disablePassword]].
|
||||
* For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* if (textField.isPassword()) console.log('Password is enabled')
|
||||
* ```
|
||||
* @returns Whether or not this is a password text field.
|
||||
*/
|
||||
isPassword(): boolean;
|
||||
/**
|
||||
* Indicate that this text field is intended for storing a secure password.
|
||||
* For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.enablePassword()
|
||||
* ```
|
||||
* Values entered into password text fields should not be displayed on the
|
||||
* screen by PDF readers. Most PDF readers will display the value as
|
||||
* asterisks or bullets. PDF readers should never store values entered by the
|
||||
* user into password text fields. Similarly, applications should not
|
||||
* write data to a password text field.
|
||||
*
|
||||
* **Please note that this method does not cause entered values to be
|
||||
* encrypted or secured in any way! It simply sets a flag that PDF software
|
||||
* and readers can access to determine the _purpose_ of this field.**
|
||||
*/
|
||||
enablePassword(): void;
|
||||
/**
|
||||
* Indicate that this text field is **not** intended for storing a secure
|
||||
* password. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.disablePassword()
|
||||
* ```
|
||||
*/
|
||||
disablePassword(): void;
|
||||
/**
|
||||
* Returns `true` if the contents of this text field represent a file path.
|
||||
* See [[PDFTextField.enableFileSelection]] and
|
||||
* [[PDFTextField.disableFileSelection]]. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* if (textField.isFileSelector()) console.log('Is a file selector')
|
||||
* ```
|
||||
* @returns Whether or not this field should contain file paths.
|
||||
*/
|
||||
isFileSelector(): boolean;
|
||||
/**
|
||||
* Indicate that this text field is intended to store a file path. The
|
||||
* contents of the file stored at that path should be submitted as the value
|
||||
* of the field. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.enableFileSelection()
|
||||
* ```
|
||||
*/
|
||||
enableFileSelection(): void;
|
||||
/**
|
||||
* Indicate that this text field is **not** intended to store a file path.
|
||||
* For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.disableFileSelection()
|
||||
* ```
|
||||
*/
|
||||
disableFileSelection(): void;
|
||||
/**
|
||||
* Returns `true` if the text entered in this field should be spell checked
|
||||
* by PDF readers. See [[PDFTextField.enableSpellChecking]] and
|
||||
* [[PDFTextField.disableSpellChecking]]. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* if (textField.isSpellChecked()) console.log('Spell checking is enabled')
|
||||
* ```
|
||||
* @returns Whether or not this field should be spell checked.
|
||||
*/
|
||||
isSpellChecked(): boolean;
|
||||
/**
|
||||
* Allow PDF readers to spell check the text entered in this field.
|
||||
* For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.enableSpellChecking()
|
||||
* ```
|
||||
*/
|
||||
enableSpellChecking(): void;
|
||||
/**
|
||||
* Do not allow PDF readers to spell check the text entered in this field.
|
||||
* For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.disableSpellChecking()
|
||||
* ```
|
||||
*/
|
||||
disableSpellChecking(): void;
|
||||
/**
|
||||
* Returns `true` if PDF readers should allow the user to scroll the text
|
||||
* field when its contents do not fit within the field's view bounds. See
|
||||
* [[PDFTextField.enableScrolling]] and [[PDFTextField.disableScrolling]].
|
||||
* For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* if (textField.isScrollable()) console.log('Scrolling is enabled')
|
||||
* ```
|
||||
* @returns Whether or not the field is scrollable in PDF readers.
|
||||
*/
|
||||
isScrollable(): boolean;
|
||||
/**
|
||||
* Allow PDF readers to present a scroll bar to the user when the contents
|
||||
* of this text field do not fit within its view bounds. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.enableScrolling()
|
||||
* ```
|
||||
* A horizontal scroll bar should be shown for singleline fields. A vertical
|
||||
* scroll bar should be shown for multiline fields.
|
||||
*/
|
||||
enableScrolling(): void;
|
||||
/**
|
||||
* Do not allow PDF readers to present a scroll bar to the user when the
|
||||
* contents of this text field do not fit within its view bounds. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.disableScrolling()
|
||||
* ```
|
||||
*/
|
||||
disableScrolling(): void;
|
||||
/**
|
||||
* Returns `true` if this is a combed text field. This means that the field
|
||||
* is split into `n` equal size cells with one character in each (where `n`
|
||||
* is equal to the max length of the text field). The result is that all
|
||||
* characters in this field are displayed an equal distance apart from one
|
||||
* another. See [[PDFTextField.enableCombing]] and
|
||||
* [[PDFTextField.disableCombing]]. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* if (textField.isCombed()) console.log('Combing is enabled')
|
||||
* ```
|
||||
* Note that in order for a text field to be combed, the following must be
|
||||
* true (in addition to enabling combing):
|
||||
* * It must not be a multiline field (see [[PDFTextField.isMultiline]])
|
||||
* * It must not be a password field (see [[PDFTextField.isPassword]])
|
||||
* * It must not be a file selector field (see [[PDFTextField.isFileSelector]])
|
||||
* * It must have a max length defined (see [[PDFTextField.setMaxLength]])
|
||||
* @returns Whether or not this field is combed.
|
||||
*/
|
||||
isCombed(): boolean;
|
||||
/**
|
||||
* Split this field into `n` equal size cells with one character in each
|
||||
* (where `n` is equal to the max length of the text field). This will cause
|
||||
* all characters in the field to be displayed an equal distance apart from
|
||||
* one another. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.enableCombing()
|
||||
* ```
|
||||
*
|
||||
* In addition to calling this method, text fields must have a max length
|
||||
* defined in order to be combed (see [[PDFTextField.setMaxLength]]).
|
||||
*
|
||||
* This method will also call the following three methods internally:
|
||||
* * [[PDFTextField.disableMultiline]]
|
||||
* * [[PDFTextField.disablePassword]]
|
||||
* * [[PDFTextField.disableFileSelection]]
|
||||
*
|
||||
* This method will mark this text field as dirty. See
|
||||
* [[PDFTextField.setText]] for more details about what this means.
|
||||
*/
|
||||
enableCombing(): void;
|
||||
/**
|
||||
* Turn off combing for this text field. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.disableCombing()
|
||||
* ```
|
||||
* See [[PDFTextField.isCombed]] and [[PDFTextField.enableCombing]] for more
|
||||
* information about what combing is.
|
||||
*
|
||||
* This method will mark this text field as dirty. See
|
||||
* [[PDFTextField.setText]] for more details about what this means.
|
||||
*/
|
||||
disableCombing(): void;
|
||||
/**
|
||||
* Returns `true` if this text field contains rich text. See
|
||||
* [[PDFTextField.enableRichFormatting]] and
|
||||
* [[PDFTextField.disableRichFormatting]]. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* if (textField.isRichFormatted()) console.log('Rich formatting enabled')
|
||||
* ```
|
||||
* @returns Whether or not this field contains rich text.
|
||||
*/
|
||||
isRichFormatted(): boolean;
|
||||
/**
|
||||
* Indicate that this field contains XFA data - or rich text. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.enableRichFormatting()
|
||||
* ```
|
||||
* Note that `pdf-lib` does not support reading or writing rich text fields.
|
||||
* Nor do most PDF readers and writers. Rich text fields are based on XFA
|
||||
* (XML Forms Architecture). Relatively few PDFs use rich text fields or XFA.
|
||||
* Unlike PDF itself, XFA is not an ISO standard. XFA has been deprecated in
|
||||
* PDF 2.0:
|
||||
* * https://en.wikipedia.org/wiki/XFA
|
||||
* * http://blog.pdfshareforms.com/pdf-2-0-release-bid-farewell-xfa-forms/
|
||||
*/
|
||||
enableRichFormatting(): void;
|
||||
/**
|
||||
* Indicate that this is a standard text field that does not XFA data (rich
|
||||
* text). For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.disableRichFormatting()
|
||||
* ```
|
||||
*/
|
||||
disableRichFormatting(): void;
|
||||
/**
|
||||
* Show this text field on the specified page. For example:
|
||||
* ```js
|
||||
* const ubuntuFont = await pdfDoc.embedFont(ubuntuFontBytes)
|
||||
* const page = pdfDoc.addPage()
|
||||
*
|
||||
* const form = pdfDoc.getForm()
|
||||
* const textField = form.createTextField('best.gundam')
|
||||
* textField.setText('Exia')
|
||||
*
|
||||
* textField.addToPage(page, {
|
||||
* x: 50,
|
||||
* y: 75,
|
||||
* width: 200,
|
||||
* height: 100,
|
||||
* textColor: rgb(1, 0, 0),
|
||||
* backgroundColor: rgb(0, 1, 0),
|
||||
* borderColor: rgb(0, 0, 1),
|
||||
* borderWidth: 2,
|
||||
* rotate: degrees(90),
|
||||
* font: ubuntuFont,
|
||||
* })
|
||||
* ```
|
||||
* This will create a new widget for this text field.
|
||||
* @param page The page to which this text field widget should be added.
|
||||
* @param options The options to be used when adding this text field widget.
|
||||
*/
|
||||
addToPage(page: PDFPage, options?: FieldAppearanceOptions): void;
|
||||
/**
|
||||
* Returns `true` if this text field has been marked as dirty, or if any of
|
||||
* this text field's widgets do not have an appearance stream. For example:
|
||||
* ```js
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* if (textField.needsAppearancesUpdate()) console.log('Needs update')
|
||||
* ```
|
||||
* @returns Whether or not this text field needs an appearance update.
|
||||
*/
|
||||
needsAppearancesUpdate(): boolean;
|
||||
/**
|
||||
* Update the appearance streams for each of this text field's widgets using
|
||||
* the default appearance provider for text fields. For example:
|
||||
* ```js
|
||||
* const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.defaultUpdateAppearances(helvetica)
|
||||
* ```
|
||||
* @param font The font to be used for creating the appearance streams.
|
||||
*/
|
||||
defaultUpdateAppearances(font: PDFFont): void;
|
||||
/**
|
||||
* Update the appearance streams for each of this text field's widgets using
|
||||
* the given appearance provider. If no `provider` is passed, the default
|
||||
* appearance provider for text fields will be used. For example:
|
||||
* ```js
|
||||
* const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)
|
||||
* const textField = form.getTextField('some.text.field')
|
||||
* textField.updateAppearances(helvetica, (field, widget, font) => {
|
||||
* ...
|
||||
* return drawTextField(...)
|
||||
* })
|
||||
* ```
|
||||
* @param font The font to be used for creating the appearance streams.
|
||||
* @param provider Optionally, the appearance provider to be used for
|
||||
* generating the contents of the appearance streams.
|
||||
*/
|
||||
updateAppearances(font: PDFFont, provider?: AppearanceProviderFor<PDFTextField>): void;
|
||||
private updateWidgetAppearance;
|
||||
}
|
||||
//# sourceMappingURL=PDFTextField.d.ts.map
|
||||
42
node_modules/pdf-lib/ts3.4/cjs/api/form/appearances.d.ts
generated
vendored
Normal file
42
node_modules/pdf-lib/ts3.4/cjs/api/form/appearances.d.ts
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import { PDFOperator, PDFWidgetAnnotation } from "../../core";
|
||||
import PDFFont from "../PDFFont";
|
||||
import PDFButton from "./PDFButton";
|
||||
import PDFCheckBox from "./PDFCheckBox";
|
||||
import PDFDropdown from "./PDFDropdown";
|
||||
import PDFField from "./PDFField";
|
||||
import PDFOptionList from "./PDFOptionList";
|
||||
import PDFRadioGroup from "./PDFRadioGroup";
|
||||
import PDFSignature from "./PDFSignature";
|
||||
import PDFTextField from "./PDFTextField";
|
||||
/*********************** Appearance Provider Types ****************************/
|
||||
declare type CheckBoxAppearanceProvider = (checkBox: PDFCheckBox, widget: PDFWidgetAnnotation) => AppearanceOrMapping<{
|
||||
on: PDFOperator[];
|
||||
off: PDFOperator[];
|
||||
}>;
|
||||
declare type RadioGroupAppearanceProvider = (radioGroup: PDFRadioGroup, widget: PDFWidgetAnnotation) => AppearanceOrMapping<{
|
||||
on: PDFOperator[];
|
||||
off: PDFOperator[];
|
||||
}>;
|
||||
declare type ButtonAppearanceProvider = (button: PDFButton, widget: PDFWidgetAnnotation, font: PDFFont) => AppearanceOrMapping<PDFOperator[]>;
|
||||
declare type DropdownAppearanceProvider = (dropdown: PDFDropdown, widget: PDFWidgetAnnotation, font: PDFFont) => AppearanceOrMapping<PDFOperator[]>;
|
||||
declare type OptionListAppearanceProvider = (optionList: PDFOptionList, widget: PDFWidgetAnnotation, font: PDFFont) => AppearanceOrMapping<PDFOperator[]>;
|
||||
declare type TextFieldAppearanceProvider = (textField: PDFTextField, widget: PDFWidgetAnnotation, font: PDFFont) => AppearanceOrMapping<PDFOperator[]>;
|
||||
declare type SignatureAppearanceProvider = (signature: PDFSignature, widget: PDFWidgetAnnotation, font: PDFFont) => AppearanceOrMapping<PDFOperator[]>;
|
||||
/******************* Appearance Provider Utility Types ************************/
|
||||
export declare type AppearanceMapping<T> = {
|
||||
normal: T;
|
||||
rollover?: T;
|
||||
down?: T;
|
||||
};
|
||||
declare type AppearanceOrMapping<T> = T | AppearanceMapping<T>;
|
||||
export declare type AppearanceProviderFor<T extends PDFField> = T extends PDFCheckBox ? CheckBoxAppearanceProvider : T extends PDFRadioGroup ? RadioGroupAppearanceProvider : T extends PDFButton ? ButtonAppearanceProvider : T extends PDFDropdown ? DropdownAppearanceProvider : T extends PDFOptionList ? OptionListAppearanceProvider : T extends PDFTextField ? TextFieldAppearanceProvider : T extends PDFSignature ? SignatureAppearanceProvider : never;
|
||||
/********************* Appearance Provider Functions **************************/
|
||||
export declare const normalizeAppearance: <T>(appearance: T | AppearanceMapping<T>) => AppearanceMapping<T>;
|
||||
export declare const defaultCheckBoxAppearanceProvider: AppearanceProviderFor<PDFCheckBox>;
|
||||
export declare const defaultRadioGroupAppearanceProvider: AppearanceProviderFor<PDFRadioGroup>;
|
||||
export declare const defaultButtonAppearanceProvider: AppearanceProviderFor<PDFButton>;
|
||||
export declare const defaultTextFieldAppearanceProvider: AppearanceProviderFor<PDFTextField>;
|
||||
export declare const defaultDropdownAppearanceProvider: AppearanceProviderFor<PDFDropdown>;
|
||||
export declare const defaultOptionListAppearanceProvider: AppearanceProviderFor<PDFOptionList>;
|
||||
export {};
|
||||
//# sourceMappingURL=appearances.d.ts.map
|
||||
11
node_modules/pdf-lib/ts3.4/cjs/api/form/index.d.ts
generated
vendored
Normal file
11
node_modules/pdf-lib/ts3.4/cjs/api/form/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
export * from "./appearances";
|
||||
export { default as PDFButton } from "./PDFButton";
|
||||
export { default as PDFCheckBox } from "./PDFCheckBox";
|
||||
export { default as PDFDropdown } from "./PDFDropdown";
|
||||
export { default as PDFField } from "./PDFField";
|
||||
export { default as PDFForm } from "./PDFForm";
|
||||
export { default as PDFOptionList } from "./PDFOptionList";
|
||||
export { default as PDFRadioGroup } from "./PDFRadioGroup";
|
||||
export { default as PDFSignature } from "./PDFSignature";
|
||||
export { default as PDFTextField } from "./PDFTextField";
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
Reference in New Issue
Block a user