* Get the document's interactive form. * * Returns null if no form exists. The form is loaded lazily on first call * and cached for subsequent calls. * * @returns The form, or null if no form exists * * @example * ```typescript * const form = await pdf.getForm(); * if (
()
| 2643 | * ``` |
| 2644 | */ |
| 2645 | getForm(): PDFForm | null { |
| 2646 | // If catalog has changed since last load, invalidate form cache |
| 2647 | if (this._form !== undefined) { |
| 2648 | const catalog = this.ctx.catalog.getDict(); |
| 2649 | |
| 2650 | if (catalog.dirty || !catalog.has("AcroForm")) { |
| 2651 | this._form = undefined; |
| 2652 | } |
| 2653 | } |
| 2654 | |
| 2655 | if (this._form === undefined) { |
| 2656 | this._form = PDFForm.load(this.ctx); |
| 2657 | } |
| 2658 | |
| 2659 | return this._form; |
| 2660 | } |
| 2661 | |
| 2662 | /** |
| 2663 | * Get or create the document's interactive form. |