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c,OAAOmK,GACxBuS,aAAetc,EAAAA,IAAUsc,EAAIF,gBAAgBnK,EAAGC,E,CAG1D,EA1gDO/Q,EAAA3B,GAAK,SAACoS,EAAuBlT,EAAaC,GAC/C,WAAIwC,EAAQyQ,EAAUlT,EAAKC,EAA3B,EAWKwC,EAAA2C,OAAS,SAACnF,IACf6C,EAAAA,EAAAA,IAAS7C,EAAK,MAAO,CAAC,CAAC0B,EAAAA,EAAa,iBACpC,IAAMkc,EAAWxM,EAAAA,GAAOvQ,IAAI,GACtBgd,EAAWzb,EAAAA,GAAY0b,qBAAqB9d,EAAIO,QAASqd,GAE/D,OAAO,IAAIpb,EAAQqb,EADH7d,EAAIO,QAAQiF,SAASqY,GACC7d,EACxC,EAy/CFwC,C,CAvhDA,G,QAAqBA,OAAAA,EAAAA,EAAAA,EAAO,I,mBCxDrB,IAAK8W,E,iBAAZ,SAAYA,GACVA,EAAA,gBACAA,EAAA,oBACAA,EAAA,gBACAA,EAAA,kBACAA,EAAA,gBACAA,EAAA,kBACAA,EAAA,wBACAA,EAAA,sBACAA,EAAA,sBACAA,EAAA,sBACAA,EAAA,wBACAA,EAAA,qBACD,CAbD,CAAYA,IAAAA,EAAS,I,mBCLd,IAAKoD,E,iBAAZ,SAAYA,GACVA,EAAA,kBACAA,EAAA,2BACAA,EAAA,iCACAA,EAAA,yCACAA,EAAA,sBACAA,EAAA,+BACAA,EAAA,qCACAA,EAAA,6CACAA,EAAA,yBACAA,EAAA,4BACAA,EAAA,gCACAA,EAAA,wCACAA,EAAA,gBACAA,EAAA,2BACD,CAfD,CAAYA,IAAAA,EAAa,I","sources":["../node_modules/pdf-lib/src/api/PDFEmbeddedFile.ts","../node_modules/pdf-lib/src/api/PDFDocument.ts","../node_modules/pdf-lib/src/api/PDFDocumentOptions.ts","../node_modules/pdf-lib/src/api/PDFEmbeddedPage.ts","../node_modules/pdf-lib/src/api/PDFFont.ts","../node_modules/pdf-lib/src/api/PDFImage.ts","../node_modules/pdf-lib/src/api/PDFJavaScript.ts","../node_modules/pdf-lib/src/api/PDFPage.ts","../node_modules/pdf-lib/src/api/PDFPageOptions.ts","../node_modules/pdf-lib/src/api/StandardFonts.ts"],"sourcesContent":["import Embeddable from 'src/api/Embeddable';\nimport PDFDocument from 'src/api/PDFDocument';\nimport FileEmbedder from 'src/core/embedders/FileEmbedder';\nimport { PDFName, PDFArray, PDFDict, PDFHexString, PDFRef } from 'src/core';\n\n/**\n * Represents a file that has been embedded in a [[PDFDocument]].\n */\nexport default class PDFEmbeddedFile implements Embeddable {\n /**\n * > **NOTE:** You probably don't want to call this method directly. Instead,\n * > consider using the [[PDFDocument.attach]] method, which will create\n * instances of [[PDFEmbeddedFile]] for you.\n *\n * Create an instance of [[PDFEmbeddedFile]] from an existing ref and embedder\n *\n * @param ref The unique reference for this file.\n * @param doc The document to which the file will belong.\n * @param embedder The embedder that will be used to embed the file.\n */\n static of = (ref: PDFRef, doc: PDFDocument, embedder: FileEmbedder) =>\n new PDFEmbeddedFile(ref, doc, embedder);\n\n /** The unique reference assigned to this embedded file within the document. */\n readonly ref: PDFRef;\n\n /** The document to which this embedded file belongs. */\n readonly doc: PDFDocument;\n\n private alreadyEmbedded = false;\n private readonly embedder: FileEmbedder;\n\n private constructor(ref: PDFRef, doc: PDFDocument, embedder: FileEmbedder) {\n this.ref = ref;\n this.doc = doc;\n this.embedder = embedder;\n }\n\n /**\n * > **NOTE:** You probably don't need to call this method directly. The\n * > [[PDFDocument.save]] and [[PDFDocument.saveAsBase64]] methods will\n * > automatically ensure all embeddable files get embedded.\n *\n * Embed this embeddable file in its document.\n *\n * @returns Resolves when the embedding is complete.\n */\n async embed(): Promise {\n if (!this.alreadyEmbedded) {\n const ref = await this.embedder.embedIntoContext(\n this.doc.context,\n this.ref,\n );\n\n if (!this.doc.catalog.has(PDFName.of('Names'))) {\n this.doc.catalog.set(PDFName.of('Names'), this.doc.context.obj({}));\n }\n const Names = this.doc.catalog.lookup(PDFName.of('Names'), PDFDict);\n\n if (!Names.has(PDFName.of('EmbeddedFiles'))) {\n Names.set(PDFName.of('EmbeddedFiles'), this.doc.context.obj({}));\n }\n const EmbeddedFiles = Names.lookup(PDFName.of('EmbeddedFiles'), PDFDict);\n\n if (!EmbeddedFiles.has(PDFName.of('Names'))) {\n EmbeddedFiles.set(PDFName.of('Names'), this.doc.context.obj([]));\n }\n const EFNames = EmbeddedFiles.lookup(PDFName.of('Names'), PDFArray);\n\n EFNames.push(PDFHexString.fromText(this.embedder.fileName));\n EFNames.push(ref);\n\n /**\n * The AF-Tag is needed to achieve PDF-A3 compliance for embedded files\n *\n * The following document outlines the uses cases of the associated files (AF) tag.\n * See:\n * https://www.pdfa.org/wp-content/uploads/2018/10/PDF20_AN002-AF.pdf\n */\n\n if (!this.doc.catalog.has(PDFName.of('AF'))) {\n this.doc.catalog.set(PDFName.of('AF'), this.doc.context.obj([]));\n }\n const AF = this.doc.catalog.lookup(PDFName.of('AF'), PDFArray);\n AF.push(ref);\n\n this.alreadyEmbedded = true;\n }\n }\n}\n","import Embeddable from 'src/api/Embeddable';\nimport {\n EncryptedPDFError,\n FontkitNotRegisteredError,\n ForeignPageError,\n RemovePageFromEmptyDocumentError,\n} from 'src/api/errors';\nimport PDFEmbeddedPage from 'src/api/PDFEmbeddedPage';\nimport PDFFont from 'src/api/PDFFont';\nimport PDFImage from 'src/api/PDFImage';\nimport PDFPage from 'src/api/PDFPage';\nimport PDFForm from 'src/api/form/PDFForm';\nimport { PageSizes } from 'src/api/sizes';\nimport { StandardFonts } from 'src/api/StandardFonts';\nimport {\n CustomFontEmbedder,\n CustomFontSubsetEmbedder,\n JpegEmbedder,\n PageBoundingBox,\n PageEmbeddingMismatchedContextError,\n PDFCatalog,\n PDFContext,\n PDFDict,\n PDFHexString,\n PDFName,\n PDFObjectCopier,\n PDFPageEmbedder,\n PDFPageLeaf,\n PDFPageTree,\n PDFParser,\n PDFStreamWriter,\n PDFString,\n PDFWriter,\n PngEmbedder,\n StandardFontEmbedder,\n UnexpectedObjectTypeError,\n} from 'src/core';\nimport {\n ParseSpeeds,\n AttachmentOptions,\n SaveOptions,\n Base64SaveOptions,\n LoadOptions,\n CreateOptions,\n EmbedFontOptions,\n SetTitleOptions,\n} from 'src/api/PDFDocumentOptions';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport { Fontkit } from 'src/types/fontkit';\nimport { TransformationMatrix } from 'src/types/matrix';\nimport {\n assertIs,\n assertIsOneOfOrUndefined,\n assertOrUndefined,\n assertRange,\n Cache,\n canBeConvertedToUint8Array,\n encodeToBase64,\n isStandardFont,\n pluckIndices,\n range,\n toUint8Array,\n} from 'src/utils';\nimport FileEmbedder, { AFRelationship } from 'src/core/embedders/FileEmbedder';\nimport PDFEmbeddedFile from 'src/api/PDFEmbeddedFile';\nimport PDFJavaScript from 'src/api/PDFJavaScript';\nimport JavaScriptEmbedder from 'src/core/embedders/JavaScriptEmbedder';\n\n/**\n * Represents a PDF document.\n */\nexport default class PDFDocument {\n /**\n * Load an existing [[PDFDocument]]. The input data can be provided in\n * multiple formats:\n *\n * | Type | Contents |\n * | ------------- | ------------------------------------------------------ |\n * | `string` | A base64 encoded string (or data URI) containing a PDF |\n * | `Uint8Array` | The raw bytes of a PDF |\n * | `ArrayBuffer` | The raw bytes of a PDF |\n *\n * For example:\n * ```js\n * import { PDFDocument } from 'pdf-lib'\n *\n * // pdf=string\n * const base64 =\n * 'JVBERi0xLjcKJYGBgYEKCjUgMCBvYmoKPDwKL0ZpbHRlciAvRmxhdGVEZWNvZGUKL0xlbm' +\n * 'd0aCAxMDQKPj4Kc3RyZWFtCniccwrhMlAAwaJ0Ln2P1Jyy1JLM5ERdc0MjCwUjE4WQNC4Q' +\n * '6cNlCFZkqGCqYGSqEJLLZWNuYGZiZmbkYuZsZmlmZGRgZmluDCQNzc3NTM2NzdzMXMxMjQ' +\n * 'ztFEKyuEK0uFxDuAAOERdVCmVuZHN0cmVhbQplbmRvYmoKCjYgMCBvYmoKPDwKL0ZpbHRl' +\n * 'ciAvRmxhdGVEZWNvZGUKL1R5cGUgL09ialN0bQovTiA0Ci9GaXJzdCAyMAovTGVuZ3RoID' +\n * 'IxNQo+PgpzdHJlYW0KeJxVj9GqwjAMhu/zFHkBzTo3nCCCiiKIHPEICuJF3cKoSCu2E8/b' +\n * '20wPIr1p8v9/8kVhgilmGfawX2CGaVrgcAi0/bsy0lrX7IGWpvJ4iJYEN3gEmrrGBlQwGs' +\n * 'HHO9VBX1wNrxAqMX87RBD5xpJuddqwd82tjAHxzV1U5LPgy52DKXWnr1Lheg+j/c/pzGVr' +\n * 'iqV0VlwZPXGPCJjElw/ybkwUmeoWgxesDXGhHJC/D/iikp1Av80ptKU0FdBEe25pPihAM1' +\n * 'u6ytgaaWfs2Hrz35CJT1+EWmAKZW5kc3RyZWFtCmVuZG9iagoKNyAwIG9iago8PAovU2l6' +\n * 'ZSA4Ci9Sb290IDIgMCBSCi9GaWx0ZXIgL0ZsYXRlRGVjb2RlCi9UeXBlIC9YUmVmCi9MZW' +\n * '5ndGggMzgKL1cgWyAxIDIgMiBdCi9JbmRleCBbIDAgOCBdCj4+CnN0cmVhbQp4nBXEwREA' +\n * 'EBAEsCwz3vrvRmOOyyOoGhZdutHN2MT55fIAVocD+AplbmRzdHJlYW0KZW5kb2JqCgpzdG' +\n * 'FydHhyZWYKNTEwCiUlRU9G'\n *\n * const dataUri = 'data:application/pdf;base64,' + base64\n *\n * const pdfDoc1 = await PDFDocument.load(base64)\n * const pdfDoc2 = await PDFDocument.load(dataUri)\n *\n * // pdf=Uint8Array\n * import fs from 'fs'\n * const uint8Array = fs.readFileSync('with_update_sections.pdf')\n * const pdfDoc3 = await PDFDocument.load(uint8Array)\n *\n * // pdf=ArrayBuffer\n * const url = 'https://pdf-lib.js.org/assets/with_update_sections.pdf'\n * const arrayBuffer = await fetch(url).then(res => res.arrayBuffer())\n * const pdfDoc4 = await PDFDocument.load(arrayBuffer)\n *\n * ```\n *\n * @param pdf The input data containing a PDF document.\n * @param options The options to be used when loading the document.\n * @returns Resolves with a document loaded from the input.\n */\n static async load(\n pdf: string | Uint8Array | ArrayBuffer,\n options: LoadOptions = {},\n ) {\n const {\n ignoreEncryption = false,\n parseSpeed = ParseSpeeds.Slow,\n throwOnInvalidObject = false,\n updateMetadata = true,\n capNumbers = false,\n } = options;\n\n assertIs(pdf, 'pdf', ['string', Uint8Array, ArrayBuffer]);\n assertIs(ignoreEncryption, 'ignoreEncryption', ['boolean']);\n assertIs(parseSpeed, 'parseSpeed', ['number']);\n assertIs(throwOnInvalidObject, 'throwOnInvalidObject', ['boolean']);\n\n const bytes = toUint8Array(pdf);\n const context = await PDFParser.forBytesWithOptions(\n bytes,\n parseSpeed,\n throwOnInvalidObject,\n capNumbers,\n ).parseDocument();\n return new PDFDocument(context, ignoreEncryption, updateMetadata);\n }\n\n /**\n * Create a new [[PDFDocument]].\n * @returns Resolves with the newly created document.\n */\n static async create(options: CreateOptions = {}) {\n const { updateMetadata = true } = options;\n\n const context = PDFContext.create();\n const pageTree = PDFPageTree.withContext(context);\n const pageTreeRef = context.register(pageTree);\n const catalog = PDFCatalog.withContextAndPages(context, pageTreeRef);\n context.trailerInfo.Root = context.register(catalog);\n\n return new PDFDocument(context, false, updateMetadata);\n }\n\n /** The low-level context of this document. */\n readonly context: PDFContext;\n\n /** The catalog of this document. */\n readonly catalog: PDFCatalog;\n\n /** Whether or not this document is encrypted. */\n readonly isEncrypted: boolean;\n\n /** The default word breaks used in PDFPage.drawText */\n defaultWordBreaks: string[] = [' '];\n\n private fontkit?: Fontkit;\n private pageCount: number | undefined;\n private readonly pageCache: Cache;\n private readonly pageMap: Map;\n private readonly formCache: Cache;\n private readonly fonts: PDFFont[];\n private readonly images: PDFImage[];\n private readonly embeddedPages: PDFEmbeddedPage[];\n private readonly embeddedFiles: PDFEmbeddedFile[];\n private readonly javaScripts: PDFJavaScript[];\n\n private constructor(\n context: PDFContext,\n ignoreEncryption: boolean,\n updateMetadata: boolean,\n ) {\n assertIs(context, 'context', [[PDFContext, 'PDFContext']]);\n assertIs(ignoreEncryption, 'ignoreEncryption', ['boolean']);\n\n this.context = context;\n this.catalog = context.lookup(context.trailerInfo.Root) as PDFCatalog;\n this.isEncrypted = !!context.lookup(context.trailerInfo.Encrypt);\n\n this.pageCache = Cache.populatedBy(this.computePages);\n this.pageMap = new Map();\n this.formCache = Cache.populatedBy(this.getOrCreateForm);\n this.fonts = [];\n this.images = [];\n this.embeddedPages = [];\n this.embeddedFiles = [];\n this.javaScripts = [];\n\n if (!ignoreEncryption && this.isEncrypted) throw new EncryptedPDFError();\n\n if (updateMetadata) this.updateInfoDict();\n }\n\n /**\n * Register a fontkit instance. This must be done before custom fonts can\n * be embedded. See [here](https://github.com/Hopding/pdf-lib/tree/master#fontkit-installation)\n * for instructions on how to install and register a fontkit instance.\n *\n * > You do **not** need to call this method to embed standard fonts.\n *\n * For example:\n * ```js\n * import { PDFDocument } from 'pdf-lib'\n * import fontkit from '@pdf-lib/fontkit'\n *\n * const pdfDoc = await PDFDocument.create()\n * pdfDoc.registerFontkit(fontkit)\n * ```\n *\n * @param fontkit The fontkit instance to be registered.\n */\n registerFontkit(fontkit: Fontkit): void {\n this.fontkit = fontkit;\n }\n\n /**\n * Get the [[PDFForm]] containing all interactive fields for this document.\n * For example:\n * ```js\n * const form = pdfDoc.getForm()\n * const fields = form.getFields()\n * fields.forEach(field => {\n * const type = field.constructor.name\n * const name = field.getName()\n * console.log(`${type}: ${name}`)\n * })\n * ```\n * @returns The form for this document.\n */\n getForm(): PDFForm {\n const form = this.formCache.access();\n if (form.hasXFA()) {\n console.warn(\n 'Removing XFA form data as pdf-lib does not support reading or writing XFA',\n );\n form.deleteXFA();\n }\n return form;\n }\n\n /**\n * Get this document's title metadata. The title appears in the\n * \"Document Properties\" section of most PDF readers. For example:\n * ```js\n * const title = pdfDoc.getTitle()\n * ```\n * @returns A string containing the title of this document, if it has one.\n */\n getTitle(): string | undefined {\n const title = this.getInfoDict().lookup(PDFName.Title);\n if (!title) return undefined;\n assertIsLiteralOrHexString(title);\n return title.decodeText();\n }\n\n /**\n * Get this document's author metadata. The author appears in the\n * \"Document Properties\" section of most PDF readers. For example:\n * ```js\n * const author = pdfDoc.getAuthor()\n * ```\n * @returns A string containing the author of this document, if it has one.\n */\n getAuthor(): string | undefined {\n const author = this.getInfoDict().lookup(PDFName.Author);\n if (!author) return undefined;\n assertIsLiteralOrHexString(author);\n return author.decodeText();\n }\n\n /**\n * Get this document's subject metadata. The subject appears in the\n * \"Document Properties\" section of most PDF readers. For example:\n * ```js\n * const subject = pdfDoc.getSubject()\n * ```\n * @returns A string containing the subject of this document, if it has one.\n */\n getSubject(): string | undefined {\n const subject = this.getInfoDict().lookup(PDFName.Subject);\n if (!subject) return undefined;\n assertIsLiteralOrHexString(subject);\n return subject.decodeText();\n }\n\n /**\n * Get this document's keywords metadata. The keywords appear in the\n * \"Document Properties\" section of most PDF readers. For example:\n * ```js\n * const keywords = pdfDoc.getKeywords()\n * ```\n * @returns A string containing the keywords of this document, if it has any.\n */\n getKeywords(): string | undefined {\n const keywords = this.getInfoDict().lookup(PDFName.Keywords);\n if (!keywords) return undefined;\n assertIsLiteralOrHexString(keywords);\n return keywords.decodeText();\n }\n\n /**\n * Get this document's creator metadata. The creator appears in the\n * \"Document Properties\" section of most PDF readers. For example:\n * ```js\n * const creator = pdfDoc.getCreator()\n * ```\n * @returns A string containing the creator of this document, if it has one.\n */\n getCreator(): string | undefined {\n const creator = this.getInfoDict().lookup(PDFName.Creator);\n if (!creator) return undefined;\n assertIsLiteralOrHexString(creator);\n return creator.decodeText();\n }\n\n /**\n * Get this document's producer metadata. The producer appears in the\n * \"Document Properties\" section of most PDF readers. For example:\n * ```js\n * const producer = pdfDoc.getProducer()\n * ```\n * @returns A string containing the producer of this document, if it has one.\n */\n getProducer(): string | undefined {\n const producer = this.getInfoDict().lookup(PDFName.Producer);\n if (!producer) return undefined;\n assertIsLiteralOrHexString(producer);\n return producer.decodeText();\n }\n\n /**\n * Get this document's creation date metadata. The creation date appears in\n * the \"Document Properties\" section of most PDF readers. For example:\n * ```js\n * const creationDate = pdfDoc.getCreationDate()\n * ```\n * @returns A Date containing the creation date of this document,\n * if it has one.\n */\n getCreationDate(): Date | undefined {\n const creationDate = this.getInfoDict().lookup(PDFName.CreationDate);\n if (!creationDate) return undefined;\n assertIsLiteralOrHexString(creationDate);\n return creationDate.decodeDate();\n }\n\n /**\n * Get this document's modification date metadata. The modification date\n * appears in the \"Document Properties\" section of most PDF readers.\n * For example:\n * ```js\n * const modification = pdfDoc.getModificationDate()\n * ```\n * @returns A Date containing the modification date of this document,\n * if it has one.\n */\n getModificationDate(): Date | undefined {\n const modificationDate = this.getInfoDict().lookup(PDFName.ModDate);\n if (!modificationDate) return undefined;\n assertIsLiteralOrHexString(modificationDate);\n return modificationDate.decodeDate();\n }\n\n /**\n * Set this document's title metadata. The title will appear in the\n * \"Document Properties\" section of most PDF readers. For example:\n * ```js\n * pdfDoc.setTitle('🥚 The Life of an Egg 🍳')\n * ```\n *\n * To display the title in the window's title bar, set the\n * `showInWindowTitleBar` option to `true` (works for _most_ PDF readers).\n * For example:\n * ```js\n * pdfDoc.setTitle('🥚 The Life of an Egg 🍳', { showInWindowTitleBar: true })\n * ```\n *\n * @param title The title of this document.\n * @param options The options to be used when setting the title.\n */\n setTitle(title: string, options?: SetTitleOptions): void {\n assertIs(title, 'title', ['string']);\n const key = PDFName.of('Title');\n this.getInfoDict().set(key, PDFHexString.fromText(title));\n\n // Indicate that readers should display the title rather than the filename\n if (options?.showInWindowTitleBar) {\n const prefs = this.catalog.getOrCreateViewerPreferences();\n prefs.setDisplayDocTitle(true);\n }\n }\n\n /**\n * Set this document's author metadata. The author will appear in the\n * \"Document Properties\" section of most PDF readers. For example:\n * ```js\n * pdfDoc.setAuthor('Humpty Dumpty')\n * ```\n * @param author The author of this document.\n */\n setAuthor(author: string): void {\n assertIs(author, 'author', ['string']);\n const key = PDFName.of('Author');\n this.getInfoDict().set(key, PDFHexString.fromText(author));\n }\n\n /**\n * Set this document's subject metadata. The subject will appear in the\n * \"Document Properties\" section of most PDF readers. For example:\n * ```js\n * pdfDoc.setSubject('📘 An Epic Tale of Woe 📖')\n * ```\n * @param subject The subject of this document.\n */\n setSubject(subject: string): void {\n assertIs(subject, 'author', ['string']);\n const key = PDFName.of('Subject');\n this.getInfoDict().set(key, PDFHexString.fromText(subject));\n }\n\n /**\n * Set this document's keyword metadata. These keywords will appear in the\n * \"Document Properties\" section of most PDF readers. For example:\n * ```js\n * pdfDoc.setKeywords(['eggs', 'wall', 'fall', 'king', 'horses', 'men'])\n * ```\n * @param keywords An array of keywords associated with this document.\n */\n setKeywords(keywords: string[]): void {\n assertIs(keywords, 'keywords', [Array]);\n const key = PDFName.of('Keywords');\n this.getInfoDict().set(key, PDFHexString.fromText(keywords.join(' ')));\n }\n\n /**\n * Set this document's creator metadata. The creator will appear in the\n * \"Document Properties\" section of most PDF readers. For example:\n * ```js\n * pdfDoc.setCreator('PDF App 9000 🤖')\n * ```\n * @param creator The creator of this document.\n */\n setCreator(creator: string): void {\n assertIs(creator, 'creator', ['string']);\n const key = PDFName.of('Creator');\n this.getInfoDict().set(key, PDFHexString.fromText(creator));\n }\n\n /**\n * Set this document's producer metadata. The producer will appear in the\n * \"Document Properties\" section of most PDF readers. For example:\n * ```js\n * pdfDoc.setProducer('PDF App 9000 🤖')\n * ```\n * @param producer The producer of this document.\n */\n setProducer(producer: string): void {\n assertIs(producer, 'creator', ['string']);\n const key = PDFName.of('Producer');\n this.getInfoDict().set(key, PDFHexString.fromText(producer));\n }\n\n /**\n * Set this document's language metadata. The language will appear in the\n * \"Document Properties\" section of some PDF readers. For example:\n * ```js\n * pdfDoc.setLanguage('en-us')\n * ```\n *\n * @param language An RFC 3066 _Language-Tag_ denoting the language of this\n * document, or an empty string if the language is unknown.\n */\n setLanguage(language: string): void {\n assertIs(language, 'language', ['string']);\n const key = PDFName.of('Lang');\n this.catalog.set(key, PDFString.of(language));\n }\n\n /**\n * Set this document's creation date metadata. The creation date will appear\n * in the \"Document Properties\" section of most PDF readers. For example:\n * ```js\n * pdfDoc.setCreationDate(new Date())\n * ```\n * @param creationDate The date this document was created.\n */\n setCreationDate(creationDate: Date): void {\n assertIs(creationDate, 'creationDate', [[Date, 'Date']]);\n const key = PDFName.of('CreationDate');\n this.getInfoDict().set(key, PDFString.fromDate(creationDate));\n }\n\n /**\n * Set this document's modification date metadata. The modification date will\n * appear in the \"Document Properties\" section of most PDF readers. For\n * example:\n * ```js\n * pdfDoc.setModificationDate(new Date())\n * ```\n * @param modificationDate The date this document was last modified.\n */\n setModificationDate(modificationDate: Date): void {\n assertIs(modificationDate, 'modificationDate', [[Date, 'Date']]);\n const key = PDFName.of('ModDate');\n this.getInfoDict().set(key, PDFString.fromDate(modificationDate));\n }\n\n /**\n * Get the number of pages contained in this document. For example:\n * ```js\n * const totalPages = pdfDoc.getPageCount()\n * ```\n * @returns The number of pages in this document.\n */\n getPageCount(): number {\n if (this.pageCount === undefined) this.pageCount = this.getPages().length;\n return this.pageCount;\n }\n\n /**\n * Get an array of all the pages contained in this document. The pages are\n * stored in the array in the same order that they are rendered in the\n * document. For example:\n * ```js\n * const pages = pdfDoc.getPages()\n * pages[0] // The first page of the document\n * pages[2] // The third page of the document\n * pages[197] // The 198th page of the document\n * ```\n * @returns An array of all the pages contained in this document.\n */\n getPages(): PDFPage[] {\n return this.pageCache.access();\n }\n\n /**\n * Get the page rendered at a particular `index` of the document. For example:\n * ```js\n * pdfDoc.getPage(0) // The first page of the document\n * pdfDoc.getPage(2) // The third page of the document\n * pdfDoc.getPage(197) // The 198th page of the document\n * ```\n * @returns The [[PDFPage]] rendered at the given `index` of the document.\n */\n getPage(index: number): PDFPage {\n const pages = this.getPages();\n assertRange(index, 'index', 0, pages.length - 1);\n return pages[index];\n }\n\n /**\n * Get an array of indices for all the pages contained in this document. The\n * array will contain a range of integers from\n * `0..pdfDoc.getPageCount() - 1`. For example:\n * ```js\n * const pdfDoc = await PDFDocument.create()\n * pdfDoc.addPage()\n * pdfDoc.addPage()\n * pdfDoc.addPage()\n *\n * const indices = pdfDoc.getPageIndices()\n * indices // => [0, 1, 2]\n * ```\n * @returns An array of indices for all pages contained in this document.\n */\n getPageIndices(): number[] {\n return range(0, this.getPageCount());\n }\n\n /**\n * Remove the page at a given index from this document. For example:\n * ```js\n * pdfDoc.removePage(0) // Remove the first page of the document\n * pdfDoc.removePage(2) // Remove the third page of the document\n * pdfDoc.removePage(197) // Remove the 198th page of the document\n * ```\n * Once a page has been removed, it will no longer be rendered at that index\n * in the document.\n * @param index The index of the page to be removed.\n */\n removePage(index: number): void {\n const pageCount = this.getPageCount();\n if (this.pageCount === 0) throw new RemovePageFromEmptyDocumentError();\n assertRange(index, 'index', 0, pageCount - 1);\n this.catalog.removeLeafNode(index);\n this.pageCount = pageCount - 1;\n }\n\n /**\n * Add a page to the end of this document. This method accepts three\n * different value types for the `page` parameter:\n *\n * | Type | Behavior |\n * | ------------------ | ----------------------------------------------------------------------------------- |\n * | `undefined` | Create a new page and add it to the end of this document |\n * | `[number, number]` | Create a new page with the given dimensions and add it to the end of this document |\n * | `PDFPage` | Add the existing page to the end of this document |\n *\n * For example:\n * ```js\n * // page=undefined\n * const newPage = pdfDoc.addPage()\n *\n * // page=[number, number]\n * import { PageSizes } from 'pdf-lib'\n * const newPage1 = pdfDoc.addPage(PageSizes.A7)\n * const newPage2 = pdfDoc.addPage(PageSizes.Letter)\n * const newPage3 = pdfDoc.addPage([500, 750])\n *\n * // page=PDFPage\n * const pdfDoc1 = await PDFDocument.create()\n * const pdfDoc2 = await PDFDocument.load(...)\n * const [existingPage] = await pdfDoc1.copyPages(pdfDoc2, [0])\n * pdfDoc1.addPage(existingPage)\n * ```\n *\n * @param page Optionally, the desired dimensions or existing page.\n * @returns The newly created (or existing) page.\n */\n addPage(page?: PDFPage | [number, number]): PDFPage {\n assertIs(page, 'page', ['undefined', [PDFPage, 'PDFPage'], Array]);\n return this.insertPage(this.getPageCount(), page);\n }\n\n /**\n * Insert a page at a given index within this document. This method accepts\n * three different value types for the `page` parameter:\n *\n * | Type | Behavior |\n * | ------------------ | ------------------------------------------------------------------------------ |\n * | `undefined` | Create a new page and insert it into this document |\n * | `[number, number]` | Create a new page with the given dimensions and insert it into this document |\n * | `PDFPage` | Insert the existing page into this document |\n *\n * For example:\n * ```js\n * // page=undefined\n * const newPage = pdfDoc.insertPage(2)\n *\n * // page=[number, number]\n * import { PageSizes } from 'pdf-lib'\n * const newPage1 = pdfDoc.insertPage(2, PageSizes.A7)\n * const newPage2 = pdfDoc.insertPage(0, PageSizes.Letter)\n * const newPage3 = pdfDoc.insertPage(198, [500, 750])\n *\n * // page=PDFPage\n * const pdfDoc1 = await PDFDocument.create()\n * const pdfDoc2 = await PDFDocument.load(...)\n * const [existingPage] = await pdfDoc1.copyPages(pdfDoc2, [0])\n * pdfDoc1.insertPage(0, existingPage)\n * ```\n *\n * @param index The index at which the page should be inserted (zero-based).\n * @param page Optionally, the desired dimensions or existing page.\n * @returns The newly created (or existing) page.\n */\n insertPage(index: number, page?: PDFPage | [number, number]): PDFPage {\n const pageCount = this.getPageCount();\n assertRange(index, 'index', 0, pageCount);\n assertIs(page, 'page', ['undefined', [PDFPage, 'PDFPage'], Array]);\n if (!page || Array.isArray(page)) {\n const dims = Array.isArray(page) ? page : PageSizes.A4;\n page = PDFPage.create(this);\n page.setSize(...dims);\n } else if (page.doc !== this) {\n throw new ForeignPageError();\n }\n\n const parentRef = this.catalog.insertLeafNode(page.ref, index);\n page.node.setParent(parentRef);\n\n this.pageMap.set(page.node, page);\n this.pageCache.invalidate();\n\n this.pageCount = pageCount + 1;\n\n return page;\n }\n\n /**\n * Copy pages from a source document into this document. Allows pages to be\n * copied between different [[PDFDocument]] instances. For example:\n * ```js\n * const pdfDoc = await PDFDocument.create()\n * const srcDoc = await PDFDocument.load(...)\n *\n * const copiedPages = await pdfDoc.copyPages(srcDoc, [0, 3, 89])\n * const [firstPage, fourthPage, ninetiethPage] = copiedPages;\n *\n * pdfDoc.addPage(fourthPage)\n * pdfDoc.insertPage(0, ninetiethPage)\n * pdfDoc.addPage(firstPage)\n * ```\n * @param srcDoc The document from which pages should be copied.\n * @param indices The indices of the pages that should be copied.\n * @returns Resolves with an array of pages copied into this document.\n */\n async copyPages(srcDoc: PDFDocument, indices: number[]): Promise {\n assertIs(srcDoc, 'srcDoc', [[PDFDocument, 'PDFDocument']]);\n assertIs(indices, 'indices', [Array]);\n await srcDoc.flush();\n const copier = PDFObjectCopier.for(srcDoc.context, this.context);\n const srcPages = srcDoc.getPages();\n const copiedPages: PDFPage[] = new Array(indices.length);\n for (let idx = 0, len = indices.length; idx < len; idx++) {\n const srcPage = srcPages[indices[idx]];\n const copiedPage = copier.copy(srcPage.node);\n const ref = this.context.register(copiedPage);\n copiedPages[idx] = PDFPage.of(copiedPage, ref, this);\n }\n return copiedPages;\n }\n\n /**\n * Get a copy of this document.\n *\n * For example:\n * ```js\n * const srcDoc = await PDFDocument.load(...)\n * const pdfDoc = await srcDoc.copy()\n * ```\n *\n * > **NOTE:** This method won't copy all information over to the new\n * > document (acroforms, outlines, etc...).\n *\n * @returns Resolves with a copy this document.\n */\n async copy(): Promise {\n const pdfCopy = await PDFDocument.create();\n const contentPages = await pdfCopy.copyPages(this, this.getPageIndices());\n\n for (let idx = 0, len = contentPages.length; idx < len; idx++) {\n pdfCopy.addPage(contentPages[idx]);\n }\n\n if (this.getAuthor() !== undefined) {\n pdfCopy.setAuthor(this.getAuthor()!);\n }\n if (this.getCreationDate() !== undefined) {\n pdfCopy.setCreationDate(this.getCreationDate()!);\n }\n if (this.getCreator() !== undefined) {\n pdfCopy.setCreator(this.getCreator()!);\n }\n if (this.getModificationDate() !== undefined) {\n pdfCopy.setModificationDate(this.getModificationDate()!);\n }\n if (this.getProducer() !== undefined) {\n pdfCopy.setProducer(this.getProducer()!);\n }\n if (this.getSubject() !== undefined) {\n pdfCopy.setSubject(this.getSubject()!);\n }\n if (this.getTitle() !== undefined) {\n pdfCopy.setTitle(this.getTitle()!);\n }\n pdfCopy.defaultWordBreaks = this.defaultWordBreaks;\n\n return pdfCopy;\n }\n\n /**\n * Add JavaScript to this document. The supplied `script` is executed when the\n * document is opened. The `script` can be used to perform some operation\n * when the document is opened (e.g. logging to the console), or it can be\n * used to define a function that can be referenced later in a JavaScript\n * action. For example:\n * ```js\n * // Show \"Hello World!\" in the console when the PDF is opened\n * pdfDoc.addJavaScript(\n * 'main',\n * 'console.show(); console.println(\"Hello World!\");'\n * );\n *\n * // Define a function named \"foo\" that can be called in JavaScript Actions\n * pdfDoc.addJavaScript(\n * 'foo',\n * 'function foo() { return \"foo\"; }'\n * );\n * ```\n * See the [JavaScript for Acrobat API Reference](https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/js_api_reference.pdf)\n * for details.\n * @param name The name of the script. Must be unique per document.\n * @param script The JavaScript to execute.\n */\n addJavaScript(name: string, script: string) {\n assertIs(name, 'name', ['string']);\n assertIs(script, 'script', ['string']);\n\n const embedder = JavaScriptEmbedder.for(script, name);\n\n const ref = this.context.nextRef();\n const javaScript = PDFJavaScript.of(ref, this, embedder);\n this.javaScripts.push(javaScript);\n }\n\n /**\n * Add an attachment to this document. Attachments are visible in the\n * \"Attachments\" panel of Adobe Acrobat and some other PDF readers. Any\n * type of file can be added as an attachment. This includes, but is not\n * limited to, `.png`, `.jpg`, `.pdf`, `.csv`, `.docx`, and `.xlsx` files.\n *\n * The input data can be provided in multiple formats:\n *\n * | Type | Contents |\n * | ------------- | -------------------------------------------------------------- |\n * | `string` | A base64 encoded string (or data URI) containing an attachment |\n * | `Uint8Array` | The raw bytes of an attachment |\n * | `ArrayBuffer` | The raw bytes of an attachment |\n *\n * For example:\n * ```js\n * // attachment=string\n * await pdfDoc.attach('/9j/4AAQSkZJRgABAQAAAQABAAD/2wBD...', 'cat_riding_unicorn.jpg', {\n * mimeType: 'image/jpeg',\n * description: 'Cool cat riding a unicorn! 🦄🐈🕶️',\n * creationDate: new Date('2019/12/01'),\n * modificationDate: new Date('2020/04/19'),\n * })\n * await pdfDoc.attach('data:image/jpeg;base64,/9j/4AAQ...', 'cat_riding_unicorn.jpg', {\n * mimeType: 'image/jpeg',\n * description: 'Cool cat riding a unicorn! 🦄🐈🕶️',\n * creationDate: new Date('2019/12/01'),\n * modificationDate: new Date('2020/04/19'),\n * })\n *\n * // attachment=Uint8Array\n * import fs from 'fs'\n * const uint8Array = fs.readFileSync('cat_riding_unicorn.jpg')\n * await pdfDoc.attach(uint8Array, 'cat_riding_unicorn.jpg', {\n * mimeType: 'image/jpeg',\n * description: 'Cool cat riding a unicorn! 🦄🐈🕶️',\n * creationDate: new Date('2019/12/01'),\n * modificationDate: new Date('2020/04/19'),\n * })\n *\n * // attachment=ArrayBuffer\n * const url = 'https://pdf-lib.js.org/assets/cat_riding_unicorn.jpg'\n * const arrayBuffer = await fetch(url).then(res => res.arrayBuffer())\n * await pdfDoc.attach(arrayBuffer, 'cat_riding_unicorn.jpg', {\n * mimeType: 'image/jpeg',\n * description: 'Cool cat riding a unicorn! 🦄🐈🕶️',\n * creationDate: new Date('2019/12/01'),\n * modificationDate: new Date('2020/04/19'),\n * })\n * ```\n *\n * @param attachment The input data containing the file to be attached.\n * @param name The name of the file to be attached.\n * @returns Resolves when the attachment is complete.\n */\n async attach(\n attachment: string | Uint8Array | ArrayBuffer,\n name: string,\n options: AttachmentOptions = {},\n ): Promise {\n assertIs(attachment, 'attachment', ['string', Uint8Array, ArrayBuffer]);\n assertIs(name, 'name', ['string']);\n assertOrUndefined(options.mimeType, 'mimeType', ['string']);\n assertOrUndefined(options.description, 'description', ['string']);\n assertOrUndefined(options.creationDate, 'options.creationDate', [Date]);\n assertOrUndefined(options.modificationDate, 'options.modificationDate', [\n Date,\n ]);\n assertIsOneOfOrUndefined(\n options.afRelationship,\n 'options.afRelationship',\n AFRelationship,\n );\n\n const bytes = toUint8Array(attachment);\n const embedder = FileEmbedder.for(bytes, name, options);\n\n const ref = this.context.nextRef();\n const embeddedFile = PDFEmbeddedFile.of(ref, this, embedder);\n this.embeddedFiles.push(embeddedFile);\n }\n\n /**\n * Embed a font into this document. The input data can be provided in multiple\n * formats:\n *\n * | Type | Contents |\n * | --------------- | ------------------------------------------------------- |\n * | `StandardFonts` | One of the standard 14 fonts |\n * | `string` | A base64 encoded string (or data URI) containing a font |\n * | `Uint8Array` | The raw bytes of a font |\n * | `ArrayBuffer` | The raw bytes of a font |\n *\n * For example:\n * ```js\n * // font=StandardFonts\n * import { StandardFonts } from 'pdf-lib'\n * const font1 = await pdfDoc.embedFont(StandardFonts.Helvetica)\n *\n * // font=string\n * const font2 = await pdfDoc.embedFont('AAEAAAAVAQAABABQRFNJRx/upe...')\n * const font3 = await pdfDoc.embedFont('data:font/opentype;base64,AAEAAA...')\n *\n * // font=Uint8Array\n * import fs from 'fs'\n * const font4 = await pdfDoc.embedFont(fs.readFileSync('Ubuntu-R.ttf'))\n *\n * // font=ArrayBuffer\n * const url = 'https://pdf-lib.js.org/assets/ubuntu/Ubuntu-R.ttf'\n * const ubuntuBytes = await fetch(url).then(res => res.arrayBuffer())\n * const font5 = await pdfDoc.embedFont(ubuntuBytes)\n * ```\n * See also: [[registerFontkit]]\n * @param font The input data for a font.\n * @param options The options to be used when embedding the font.\n * @returns Resolves with the embedded font.\n */\n async embedFont(\n font: StandardFonts | string | Uint8Array | ArrayBuffer,\n options: EmbedFontOptions = {},\n ): Promise {\n const { subset = false, customName, features } = options;\n\n assertIs(font, 'font', ['string', Uint8Array, ArrayBuffer]);\n assertIs(subset, 'subset', ['boolean']);\n\n let embedder: CustomFontEmbedder | StandardFontEmbedder;\n if (isStandardFont(font)) {\n embedder = StandardFontEmbedder.for(font, customName);\n } else if (canBeConvertedToUint8Array(font)) {\n const bytes = toUint8Array(font);\n const fontkit = this.assertFontkit();\n embedder = subset\n ? await CustomFontSubsetEmbedder.for(\n fontkit,\n bytes,\n customName,\n features,\n )\n : await CustomFontEmbedder.for(fontkit, bytes, customName, features);\n } else {\n throw new TypeError(\n '`font` must be one of `StandardFonts | string | Uint8Array | ArrayBuffer`',\n );\n }\n\n const ref = this.context.nextRef();\n const pdfFont = PDFFont.of(ref, this, embedder);\n this.fonts.push(pdfFont);\n\n return pdfFont;\n }\n\n /**\n * Embed a standard font into this document.\n * For example:\n * ```js\n * import { StandardFonts } from 'pdf-lib'\n * const helveticaFont = pdfDoc.embedFont(StandardFonts.Helvetica)\n * ```\n * @param font The standard font to be embedded.\n * @param customName The name to be used when embedding the font.\n * @returns The embedded font.\n */\n embedStandardFont(font: StandardFonts, customName?: string): PDFFont {\n assertIs(font, 'font', ['string']);\n if (!isStandardFont(font)) {\n throw new TypeError('`font` must be one of type `StandardFonts`');\n }\n\n const embedder = StandardFontEmbedder.for(font, customName);\n\n const ref = this.context.nextRef();\n const pdfFont = PDFFont.of(ref, this, embedder);\n this.fonts.push(pdfFont);\n\n return pdfFont;\n }\n\n /**\n * Embed a JPEG image into this document. The input data can be provided in\n * multiple formats:\n *\n * | Type | Contents |\n * | ------------- | ------------------------------------------------------------- |\n * | `string` | A base64 encoded string (or data URI) containing a JPEG image |\n * | `Uint8Array` | The raw bytes of a JPEG image |\n * | `ArrayBuffer` | The raw bytes of a JPEG image |\n *\n * For example:\n * ```js\n * // jpg=string\n * const image1 = await pdfDoc.embedJpg('/9j/4AAQSkZJRgABAQAAAQABAAD/2wBD...')\n * const image2 = await pdfDoc.embedJpg('data:image/jpeg;base64,/9j/4AAQ...')\n *\n * // jpg=Uint8Array\n * import fs from 'fs'\n * const uint8Array = fs.readFileSync('cat_riding_unicorn.jpg')\n * const image3 = await pdfDoc.embedJpg(uint8Array)\n *\n * // jpg=ArrayBuffer\n * const url = 'https://pdf-lib.js.org/assets/cat_riding_unicorn.jpg'\n * const arrayBuffer = await fetch(url).then(res => res.arrayBuffer())\n * const image4 = await pdfDoc.embedJpg(arrayBuffer)\n * ```\n *\n * @param jpg The input data for a JPEG image.\n * @returns Resolves with the embedded image.\n */\n async embedJpg(jpg: string | Uint8Array | ArrayBuffer): Promise {\n assertIs(jpg, 'jpg', ['string', Uint8Array, ArrayBuffer]);\n const bytes = toUint8Array(jpg);\n const embedder = await JpegEmbedder.for(bytes);\n const ref = this.context.nextRef();\n const pdfImage = PDFImage.of(ref, this, embedder);\n this.images.push(pdfImage);\n return pdfImage;\n }\n\n /**\n * Embed a PNG image into this document. The input data can be provided in\n * multiple formats:\n *\n * | Type | Contents |\n * | ------------- | ------------------------------------------------------------ |\n * | `string` | A base64 encoded string (or data URI) containing a PNG image |\n * | `Uint8Array` | The raw bytes of a PNG image |\n * | `ArrayBuffer` | The raw bytes of a PNG image |\n *\n * For example:\n * ```js\n * // png=string\n * const image1 = await pdfDoc.embedPng('iVBORw0KGgoAAAANSUhEUgAAAlgAAAF3...')\n * const image2 = await pdfDoc.embedPng('data:image/png;base64,iVBORw0KGg...')\n *\n * // png=Uint8Array\n * import fs from 'fs'\n * const uint8Array = fs.readFileSync('small_mario.png')\n * const image3 = await pdfDoc.embedPng(uint8Array)\n *\n * // png=ArrayBuffer\n * const url = 'https://pdf-lib.js.org/assets/small_mario.png'\n * const arrayBuffer = await fetch(url).then(res => res.arrayBuffer())\n * const image4 = await pdfDoc.embedPng(arrayBuffer)\n * ```\n *\n * @param png The input data for a PNG image.\n * @returns Resolves with the embedded image.\n */\n async embedPng(png: string | Uint8Array | ArrayBuffer): Promise {\n assertIs(png, 'png', ['string', Uint8Array, ArrayBuffer]);\n const bytes = toUint8Array(png);\n const embedder = await PngEmbedder.for(bytes);\n const ref = this.context.nextRef();\n const pdfImage = PDFImage.of(ref, this, embedder);\n this.images.push(pdfImage);\n return pdfImage;\n }\n\n /**\n * Embed one or more PDF pages into this document.\n *\n * For example:\n * ```js\n * const pdfDoc = await PDFDocument.create()\n *\n * const sourcePdfUrl = 'https://pdf-lib.js.org/assets/with_large_page_count.pdf'\n * const sourcePdf = await fetch(sourcePdfUrl).then((res) => res.arrayBuffer())\n *\n * // Embed page 74 of `sourcePdf` into `pdfDoc`\n * const [embeddedPage] = await pdfDoc.embedPdf(sourcePdf, [73])\n * ```\n *\n * See [[PDFDocument.load]] for examples of the allowed input data formats.\n *\n * @param pdf The input data containing a PDF document.\n * @param indices The indices of the pages that should be embedded.\n * @returns Resolves with an array of the embedded pages.\n */\n async embedPdf(\n pdf: string | Uint8Array | ArrayBuffer | PDFDocument,\n indices: number[] = [0],\n ): Promise {\n assertIs(pdf, 'pdf', [\n 'string',\n Uint8Array,\n ArrayBuffer,\n [PDFDocument, 'PDFDocument'],\n ]);\n assertIs(indices, 'indices', [Array]);\n\n const srcDoc =\n pdf instanceof PDFDocument ? pdf : await PDFDocument.load(pdf);\n\n const srcPages = pluckIndices(srcDoc.getPages(), indices);\n\n return this.embedPages(srcPages);\n }\n\n /**\n * Embed a single PDF page into this document.\n *\n * For example:\n * ```js\n * const pdfDoc = await PDFDocument.create()\n *\n * const sourcePdfUrl = 'https://pdf-lib.js.org/assets/with_large_page_count.pdf'\n * const sourceBuffer = await fetch(sourcePdfUrl).then((res) => res.arrayBuffer())\n * const sourcePdfDoc = await PDFDocument.load(sourceBuffer)\n * const sourcePdfPage = sourcePdfDoc.getPages()[73]\n *\n * const embeddedPage = await pdfDoc.embedPage(\n * sourcePdfPage,\n *\n * // Clip a section of the source page so that we only embed part of it\n * { left: 100, right: 450, bottom: 330, top: 570 },\n *\n * // Translate all drawings of the embedded page by (10, 200) units\n * [1, 0, 0, 1, 10, 200],\n * )\n * ```\n *\n * @param page The page to be embedded.\n * @param boundingBox\n * Optionally, an area of the source page that should be embedded\n * (defaults to entire page).\n * @param transformationMatrix\n * Optionally, a transformation matrix that is always applied to the embedded\n * page anywhere it is drawn.\n * @returns Resolves with the embedded pdf page.\n */\n async embedPage(\n page: PDFPage,\n boundingBox?: PageBoundingBox,\n transformationMatrix?: TransformationMatrix,\n ): Promise {\n assertIs(page, 'page', [[PDFPage, 'PDFPage']]);\n const [embeddedPage] = await this.embedPages(\n [page],\n [boundingBox],\n [transformationMatrix],\n );\n return embeddedPage;\n }\n\n /**\n * Embed one or more PDF pages into this document.\n *\n * For example:\n * ```js\n * const pdfDoc = await PDFDocument.create()\n *\n * const sourcePdfUrl = 'https://pdf-lib.js.org/assets/with_large_page_count.pdf'\n * const sourceBuffer = await fetch(sourcePdfUrl).then((res) => res.arrayBuffer())\n * const sourcePdfDoc = await PDFDocument.load(sourceBuffer)\n *\n * const page1 = sourcePdfDoc.getPages()[0]\n * const page2 = sourcePdfDoc.getPages()[52]\n * const page3 = sourcePdfDoc.getPages()[73]\n *\n * const embeddedPages = await pdfDoc.embedPages([page1, page2, page3])\n * ```\n *\n * @param page\n * The pages to be embedded (they must all share the same context).\n * @param boundingBoxes\n * Optionally, an array of clipping boundaries - one for each page\n * (defaults to entirety of each page).\n * @param transformationMatrices\n * Optionally, an array of transformation matrices - one for each page\n * (each page's transformation will apply anywhere it is drawn).\n * @returns Resolves with an array of the embedded pdf pages.\n */\n async embedPages(\n pages: PDFPage[],\n boundingBoxes: (PageBoundingBox | undefined)[] = [],\n transformationMatrices: (TransformationMatrix | undefined)[] = [],\n ) {\n if (pages.length === 0) return [];\n\n // Assert all pages have the same context\n for (let idx = 0, len = pages.length - 1; idx < len; idx++) {\n const currPage = pages[idx];\n const nextPage = pages[idx + 1];\n if (currPage.node.context !== nextPage.node.context) {\n throw new PageEmbeddingMismatchedContextError();\n }\n }\n\n const context = pages[0].node.context;\n const maybeCopyPage =\n context === this.context\n ? (p: PDFPageLeaf) => p\n : PDFObjectCopier.for(context, this.context).copy;\n\n const embeddedPages = new Array(pages.length);\n for (let idx = 0, len = pages.length; idx < len; idx++) {\n const page = maybeCopyPage(pages[idx].node);\n const box = boundingBoxes[idx];\n const matrix = transformationMatrices[idx];\n\n const embedder = await PDFPageEmbedder.for(page, box, matrix);\n\n const ref = this.context.nextRef();\n embeddedPages[idx] = PDFEmbeddedPage.of(ref, this, embedder);\n }\n\n this.embeddedPages.push(...embeddedPages);\n\n return embeddedPages;\n }\n\n /**\n * > **NOTE:** You shouldn't need to call this method directly. The [[save]]\n * > and [[saveAsBase64]] methods will automatically ensure that all embedded\n * > assets are flushed before serializing the document.\n *\n * Flush all embedded fonts, PDF pages, and images to this document's\n * [[context]].\n *\n * @returns Resolves when the flush is complete.\n */\n async flush(): Promise {\n await this.embedAll(this.fonts);\n await this.embedAll(this.images);\n await this.embedAll(this.embeddedPages);\n await this.embedAll(this.embeddedFiles);\n await this.embedAll(this.javaScripts);\n }\n\n /**\n * Serialize this document to an array of bytes making up a PDF file.\n * For example:\n * ```js\n * const pdfBytes = await pdfDoc.save()\n * ```\n *\n * There are a number of things you can do with the serialized document,\n * depending on the JavaScript environment you're running in:\n * * Write it to a file in Node or React Native\n * * Download it as a Blob in the browser\n * * Render it in an `iframe`\n *\n * @param options The options to be used when saving the document.\n * @returns Resolves with the bytes of the serialized document.\n */\n async save(options: SaveOptions = {}): Promise {\n const {\n useObjectStreams = true,\n addDefaultPage = true,\n objectsPerTick = 50,\n updateFieldAppearances = true,\n } = options;\n\n assertIs(useObjectStreams, 'useObjectStreams', ['boolean']);\n assertIs(addDefaultPage, 'addDefaultPage', ['boolean']);\n assertIs(objectsPerTick, 'objectsPerTick', ['number']);\n assertIs(updateFieldAppearances, 'updateFieldAppearances', ['boolean']);\n\n if (addDefaultPage && this.getPageCount() === 0) this.addPage();\n\n if (updateFieldAppearances) {\n const form = this.formCache.getValue();\n if (form) form.updateFieldAppearances();\n }\n\n await this.flush();\n\n const Writer = useObjectStreams ? PDFStreamWriter : PDFWriter;\n return Writer.forContext(this.context, objectsPerTick).serializeToBuffer();\n }\n\n /**\n * Serialize this document to a base64 encoded string or data URI making up a\n * PDF file. For example:\n * ```js\n * const base64String = await pdfDoc.saveAsBase64()\n * base64String // => 'JVBERi0xLjcKJYGBgYEKC...'\n *\n * const base64DataUri = await pdfDoc.saveAsBase64({ dataUri: true })\n * base64DataUri // => 'data:application/pdf;base64,JVBERi0xLjcKJYGBgYEKC...'\n * ```\n *\n * @param options The options to be used when saving the document.\n * @returns Resolves with a base64 encoded string or data URI of the\n * serialized document.\n */\n async saveAsBase64(options: Base64SaveOptions = {}): Promise {\n const { dataUri = false, ...otherOptions } = options;\n assertIs(dataUri, 'dataUri', ['boolean']);\n const bytes = await this.save(otherOptions);\n const base64 = encodeToBase64(bytes);\n return dataUri ? `data:application/pdf;base64,${base64}` : base64;\n }\n\n findPageForAnnotationRef(ref: PDFRef): PDFPage | undefined {\n const pages = this.getPages();\n for (let idx = 0, len = pages.length; idx < len; idx++) {\n const page = pages[idx];\n const annotations = page.node.Annots();\n\n if (annotations?.indexOf(ref) !== undefined) {\n return page;\n }\n }\n\n return undefined;\n }\n\n private async embedAll(embeddables: Embeddable[]): Promise {\n for (let idx = 0, len = embeddables.length; idx < len; idx++) {\n await embeddables[idx].embed();\n }\n }\n\n private updateInfoDict(): void {\n const pdfLib = `pdf-lib (https://github.com/Hopding/pdf-lib)`;\n const now = new Date();\n\n const info = this.getInfoDict();\n\n this.setProducer(pdfLib);\n this.setModificationDate(now);\n\n if (!info.get(PDFName.of('Creator'))) this.setCreator(pdfLib);\n if (!info.get(PDFName.of('CreationDate'))) this.setCreationDate(now);\n }\n\n private getInfoDict(): PDFDict {\n const existingInfo = this.context.lookup(this.context.trailerInfo.Info);\n if (existingInfo instanceof PDFDict) return existingInfo;\n\n const newInfo = this.context.obj({});\n this.context.trailerInfo.Info = this.context.register(newInfo);\n\n return newInfo;\n }\n\n private assertFontkit(): Fontkit {\n if (!this.fontkit) throw new FontkitNotRegisteredError();\n return this.fontkit;\n }\n\n private computePages = (): PDFPage[] => {\n const pages: PDFPage[] = [];\n this.catalog.Pages().traverse((node, ref) => {\n if (node instanceof PDFPageLeaf) {\n let page = this.pageMap.get(node);\n if (!page) {\n page = PDFPage.of(node, ref, this);\n this.pageMap.set(node, page);\n }\n pages.push(page);\n }\n });\n return pages;\n };\n\n private getOrCreateForm = (): PDFForm => {\n const acroForm = this.catalog.getOrCreateAcroForm();\n return PDFForm.of(acroForm, this);\n };\n}\n\n/* tslint:disable-next-line only-arrow-functions */\nfunction assertIsLiteralOrHexString(\n pdfObject: PDFObject,\n): asserts pdfObject is PDFHexString | PDFString {\n if (\n !(pdfObject instanceof PDFHexString) &&\n !(pdfObject instanceof PDFString)\n ) {\n throw new UnexpectedObjectTypeError([PDFHexString, PDFString], pdfObject);\n }\n}\n","import { EmbeddedFileOptions } from 'src/core/embedders/FileEmbedder';\nimport { TypeFeatures } from 'src/types/fontkit';\n\nexport enum ParseSpeeds {\n Fastest = Infinity,\n Fast = 1500,\n Medium = 500,\n Slow = 100,\n}\n\nexport interface AttachmentOptions extends EmbeddedFileOptions {}\n\nexport interface SaveOptions {\n useObjectStreams?: boolean;\n addDefaultPage?: boolean;\n objectsPerTick?: number;\n updateFieldAppearances?: boolean;\n}\n\nexport interface Base64SaveOptions extends SaveOptions {\n dataUri?: boolean;\n}\n\nexport interface LoadOptions {\n ignoreEncryption?: boolean;\n parseSpeed?: ParseSpeeds | number;\n throwOnInvalidObject?: boolean;\n updateMetadata?: boolean;\n capNumbers?: boolean;\n}\n\nexport interface CreateOptions {\n updateMetadata?: boolean;\n}\n\nexport interface EmbedFontOptions {\n subset?: boolean;\n customName?: string;\n features?: TypeFeatures;\n}\n\nexport interface SetTitleOptions {\n showInWindowTitleBar: boolean;\n}\n","import Embeddable from 'src/api/Embeddable';\nimport PDFDocument from 'src/api/PDFDocument';\nimport { PDFPageEmbedder, PDFRef } from 'src/core';\nimport { assertIs } from 'src/utils';\n\n/**\n * Represents a PDF page that has been embedded in a [[PDFDocument]].\n */\nexport default class PDFEmbeddedPage implements Embeddable {\n /**\n * > **NOTE:** You probably don't want to call this method directly. Instead,\n * > consider using the [[PDFDocument.embedPdf]] and\n * > [[PDFDocument.embedPage]] methods, which will create instances of\n * > [[PDFEmbeddedPage]] for you.\n *\n * Create an instance of [[PDFEmbeddedPage]] from an existing ref and embedder\n *\n * @param ref The unique reference for this embedded page.\n * @param doc The document to which the embedded page will belong.\n * @param embedder The embedder that will be used to embed the page.\n */\n static of = (ref: PDFRef, doc: PDFDocument, embedder: PDFPageEmbedder) =>\n new PDFEmbeddedPage(ref, doc, embedder);\n\n /** The unique reference assigned to this embedded page within the document. */\n readonly ref: PDFRef;\n\n /** The document to which this embedded page belongs. */\n readonly doc: PDFDocument;\n\n /** The width of this page in pixels. */\n readonly width: number;\n\n /** The height of this page in pixels. */\n readonly height: number;\n\n private alreadyEmbedded = false;\n private readonly embedder: PDFPageEmbedder;\n\n private constructor(\n ref: PDFRef,\n doc: PDFDocument,\n embedder: PDFPageEmbedder,\n ) {\n assertIs(ref, 'ref', [[PDFRef, 'PDFRef']]);\n assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);\n assertIs(embedder, 'embedder', [[PDFPageEmbedder, 'PDFPageEmbedder']]);\n\n this.ref = ref;\n this.doc = doc;\n this.width = embedder.width;\n this.height = embedder.height;\n\n this.embedder = embedder;\n }\n\n /**\n * Compute the width and height of this page after being scaled by the\n * given `factor`. For example:\n * ```js\n * embeddedPage.width // => 500\n * embeddedPage.height // => 250\n *\n * const scaled = embeddedPage.scale(0.5)\n * scaled.width // => 250\n * scaled.height // => 125\n * ```\n * This operation is often useful before drawing a page with\n * [[PDFPage.drawPage]] to compute the `width` and `height` options.\n * @param factor The factor by which this page should be scaled.\n * @returns The width and height of the page after being scaled.\n */\n scale(factor: number) {\n assertIs(factor, 'factor', ['number']);\n return { width: this.width * factor, height: this.height * factor };\n }\n\n /**\n * Get the width and height of this page. For example:\n * ```js\n * const { width, height } = embeddedPage.size()\n * ```\n * @returns The width and height of the page.\n */\n size() {\n return this.scale(1);\n }\n\n /**\n * > **NOTE:** You probably don't need to call this method directly. The\n * > [[PDFDocument.save]] and [[PDFDocument.saveAsBase64]] methods will\n * > automatically ensure all embeddable pages get embedded.\n *\n * Embed this embeddable page in its document.\n *\n * @returns Resolves when the embedding is complete.\n */\n async embed(): Promise {\n if (!this.alreadyEmbedded) {\n await this.embedder.embedIntoContext(this.doc.context, this.ref);\n this.alreadyEmbedded = true;\n }\n }\n}\n","import Embeddable from 'src/api//Embeddable';\nimport PDFDocument from 'src/api/PDFDocument';\nimport {\n CustomFontEmbedder,\n PDFHexString,\n PDFRef,\n StandardFontEmbedder,\n} from 'src/core';\nimport { assertIs, assertOrUndefined } from 'src/utils';\n\nexport type FontEmbedder = CustomFontEmbedder | StandardFontEmbedder;\n\n/**\n * Represents a font that has been embedded in a [[PDFDocument]].\n */\nexport default class PDFFont implements Embeddable {\n /**\n * > **NOTE:** You probably don't want to call this method directly. Instead,\n * > consider using the [[PDFDocument.embedFont]] and\n * > [[PDFDocument.embedStandardFont]] methods, which will create instances\n * > of [[PDFFont]] for you.\n *\n * Create an instance of [[PDFFont]] from an existing ref and embedder\n *\n * @param ref The unique reference for this font.\n * @param doc The document to which the font will belong.\n * @param embedder The embedder that will be used to embed the font.\n */\n static of = (ref: PDFRef, doc: PDFDocument, embedder: FontEmbedder) =>\n new PDFFont(ref, doc, embedder);\n\n /** The unique reference assigned to this font within the document. */\n readonly ref: PDFRef;\n\n /** The document to which this font belongs. */\n readonly doc: PDFDocument;\n\n /** The name of this font. */\n readonly name: string;\n\n private modified = true;\n private readonly embedder: FontEmbedder;\n\n private constructor(ref: PDFRef, doc: PDFDocument, embedder: FontEmbedder) {\n assertIs(ref, 'ref', [[PDFRef, 'PDFRef']]);\n assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);\n assertIs(embedder, 'embedder', [\n [CustomFontEmbedder, 'CustomFontEmbedder'],\n [StandardFontEmbedder, 'StandardFontEmbedder'],\n ]);\n\n this.ref = ref;\n this.doc = doc;\n this.name = embedder.fontName;\n\n this.embedder = embedder;\n }\n\n /**\n * > **NOTE:** You probably don't need to call this method directly. The\n * > [[PDFPage.drawText]] method will automatically encode the text it is\n * > given.\n *\n * Encodes a string of text in this font.\n *\n * @param text The text to be encoded.\n * @returns The encoded text as a hex string.\n */\n encodeText(text: string): PDFHexString {\n assertIs(text, 'text', ['string']);\n this.modified = true;\n return this.embedder.encodeText(text);\n }\n\n /**\n * Measure the width of a string of text drawn in this font at a given size.\n * For example:\n * ```js\n * const width = font.widthOfTextAtSize('Foo Bar Qux Baz', 36)\n * ```\n * @param text The string of text to be measured.\n * @param size The font size to be used for this measurement.\n * @returns The width of the string of text when drawn in this font at the\n * given size.\n */\n widthOfTextAtSize(text: string, size: number): number {\n assertIs(text, 'text', ['string']);\n assertIs(size, 'size', ['number']);\n return this.embedder.widthOfTextAtSize(text, size);\n }\n\n /**\n * Measure the height of this font at a given size. For example:\n * ```js\n * const height = font.heightAtSize(24)\n * ```\n *\n * The `options.descender` value controls whether or not the font's\n * descender is included in the height calculation.\n *\n * @param size The font size to be used for this measurement.\n * @param options The options to be used when computing this measurement.\n * @returns The height of this font at the given size.\n */\n heightAtSize(size: number, options?: { descender?: boolean }): number {\n assertIs(size, 'size', ['number']);\n assertOrUndefined(options?.descender, 'options.descender', ['boolean']);\n return this.embedder.heightOfFontAtSize(size, {\n descender: options?.descender ?? true,\n });\n }\n\n /**\n * Compute the font size at which this font is a given height. For example:\n * ```js\n * const fontSize = font.sizeAtHeight(12)\n * ```\n * @param height The height to be used for this calculation.\n * @returns The font size at which this font is the given height.\n */\n sizeAtHeight(height: number): number {\n assertIs(height, 'height', ['number']);\n return this.embedder.sizeOfFontAtHeight(height);\n }\n\n /**\n * Get the set of unicode code points that can be represented by this font.\n * @returns The set of unicode code points supported by this font.\n */\n getCharacterSet(): number[] {\n if (this.embedder instanceof StandardFontEmbedder) {\n return this.embedder.encoding.supportedCodePoints;\n } else {\n return this.embedder.font.characterSet;\n }\n }\n\n /**\n * > **NOTE:** You probably don't need to call this method directly. The\n * > [[PDFDocument.save]] and [[PDFDocument.saveAsBase64]] methods will\n * > automatically ensure all fonts get embedded.\n *\n * Embed this font in its document.\n *\n * @returns Resolves when the embedding is complete.\n */\n async embed(): Promise {\n // TODO: Cleanup orphan embedded objects if a font is embedded multiple times...\n if (this.modified) {\n await this.embedder.embedIntoContext(this.doc.context, this.ref);\n this.modified = false;\n }\n }\n}\n","import Embeddable from 'src/api/Embeddable';\nimport PDFDocument from 'src/api/PDFDocument';\nimport { JpegEmbedder, PDFRef, PngEmbedder } from 'src/core';\nimport { assertIs } from 'src/utils';\n\nexport type ImageEmbedder = JpegEmbedder | PngEmbedder;\n\n/**\n * Represents an image that has been embedded in a [[PDFDocument]].\n */\nexport default class PDFImage implements Embeddable {\n /**\n * > **NOTE:** You probably don't want to call this method directly. Instead,\n * > consider using the [[PDFDocument.embedPng]] and [[PDFDocument.embedJpg]]\n * > methods, which will create instances of [[PDFImage]] for you.\n *\n * Create an instance of [[PDFImage]] from an existing ref and embedder\n *\n * @param ref The unique reference for this image.\n * @param doc The document to which the image will belong.\n * @param embedder The embedder that will be used to embed the image.\n */\n static of = (ref: PDFRef, doc: PDFDocument, embedder: ImageEmbedder) =>\n new PDFImage(ref, doc, embedder);\n\n /** The unique reference assigned to this image within the document. */\n readonly ref: PDFRef;\n\n /** The document to which this image belongs. */\n readonly doc: PDFDocument;\n\n /** The width of this image in pixels. */\n readonly width: number;\n\n /** The height of this image in pixels. */\n readonly height: number;\n\n private embedder: ImageEmbedder | undefined;\n private embedTask: Promise | undefined;\n\n private constructor(ref: PDFRef, doc: PDFDocument, embedder: ImageEmbedder) {\n assertIs(ref, 'ref', [[PDFRef, 'PDFRef']]);\n assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);\n assertIs(embedder, 'embedder', [\n [JpegEmbedder, 'JpegEmbedder'],\n [PngEmbedder, 'PngEmbedder'],\n ]);\n\n this.ref = ref;\n this.doc = doc;\n this.width = embedder.width;\n this.height = embedder.height;\n\n this.embedder = embedder;\n }\n\n /**\n * Compute the width and height of this image after being scaled by the\n * given `factor`. For example:\n * ```js\n * image.width // => 500\n * image.height // => 250\n *\n * const scaled = image.scale(0.5)\n * scaled.width // => 250\n * scaled.height // => 125\n * ```\n * This operation is often useful before drawing an image with\n * [[PDFPage.drawImage]] to compute the `width` and `height` options.\n * @param factor The factor by which this image should be scaled.\n * @returns The width and height of the image after being scaled.\n */\n scale(factor: number) {\n assertIs(factor, 'factor', ['number']);\n return { width: this.width * factor, height: this.height * factor };\n }\n\n /**\n * Get the width and height of this image after scaling it as large as\n * possible while maintaining its aspect ratio and not exceeding the\n * specified `width` and `height`. For example:\n * ```\n * image.width // => 500\n * image.height // => 250\n *\n * const scaled = image.scaleToFit(750, 1000)\n * scaled.width // => 750\n * scaled.height // => 375\n * ```\n * The `width` and `height` parameters can also be thought of as the width\n * and height of a box that the scaled image must fit within.\n * @param width The bounding box's width.\n * @param height The bounding box's height.\n * @returns The width and height of the image after being scaled.\n */\n scaleToFit(width: number, height: number) {\n assertIs(width, 'width', ['number']);\n assertIs(height, 'height', ['number']);\n\n const imgWidthScale = width / this.width;\n const imgHeightScale = height / this.height;\n const scale = Math.min(imgWidthScale, imgHeightScale);\n\n return this.scale(scale);\n }\n\n /**\n * Get the width and height of this image. For example:\n * ```js\n * const { width, height } = image.size()\n * ```\n * @returns The width and height of the image.\n */\n size() {\n return this.scale(1);\n }\n\n /**\n * > **NOTE:** You probably don't need to call this method directly. The\n * > [[PDFDocument.save]] and [[PDFDocument.saveAsBase64]] methods will\n * > automatically ensure all images get embedded.\n *\n * Embed this image in its document.\n *\n * @returns Resolves when the embedding is complete.\n */\n async embed(): Promise {\n if (!this.embedder) return;\n\n // The image should only be embedded once. If there's a pending embed\n // operation then wait on it. Otherwise we need to start the embed.\n if (!this.embedTask) {\n const { doc, ref } = this;\n this.embedTask = this.embedder.embedIntoContext(doc.context, ref);\n }\n await this.embedTask;\n\n // We clear `this.embedder` so that the indirectly referenced image data\n // can be garbage collected, thus avoiding a memory leak.\n // See https://github.com/Hopding/pdf-lib/pull/1032/files.\n this.embedder = undefined;\n }\n}\n","import Embeddable from 'src/api/Embeddable';\nimport PDFDocument from 'src/api/PDFDocument';\nimport JavaScriptEmbedder from 'src/core/embedders/JavaScriptEmbedder';\nimport { PDFName, PDFArray, PDFDict, PDFHexString, PDFRef } from 'src/core';\n\n/**\n * Represents JavaScript that has been embedded in a [[PDFDocument]].\n */\nexport default class PDFJavaScript implements Embeddable {\n /**\n * > **NOTE:** You probably don't want to call this method directly. Instead,\n * > consider using the [[PDFDocument.addJavaScript]] method, which will\n * create instances of [[PDFJavaScript]] for you.\n *\n * Create an instance of [[PDFJavaScript]] from an existing ref and script\n *\n * @param ref The unique reference for this script.\n * @param doc The document to which the script will belong.\n * @param embedder The embedder that will be used to embed the script.\n */\n static of = (ref: PDFRef, doc: PDFDocument, embedder: JavaScriptEmbedder) =>\n new PDFJavaScript(ref, doc, embedder);\n\n /** The unique reference assigned to this embedded script within the document. */\n readonly ref: PDFRef;\n\n /** The document to which this embedded script belongs. */\n readonly doc: PDFDocument;\n\n private alreadyEmbedded = false;\n private readonly embedder: JavaScriptEmbedder;\n\n private constructor(\n ref: PDFRef,\n doc: PDFDocument,\n embedder: JavaScriptEmbedder,\n ) {\n this.ref = ref;\n this.doc = doc;\n this.embedder = embedder;\n }\n\n /**\n * > **NOTE:** You probably don't need to call this method directly. The\n * > [[PDFDocument.save]] and [[PDFDocument.saveAsBase64]] methods will\n * > automatically ensure all JavaScripts get embedded.\n *\n * Embed this JavaScript in its document.\n *\n * @returns Resolves when the embedding is complete.\n */\n async embed(): Promise {\n if (!this.alreadyEmbedded) {\n const { catalog, context } = this.doc;\n\n const ref = await this.embedder.embedIntoContext(\n this.doc.context,\n this.ref,\n );\n\n if (!catalog.has(PDFName.of('Names'))) {\n catalog.set(PDFName.of('Names'), context.obj({}));\n }\n const Names = catalog.lookup(PDFName.of('Names'), PDFDict);\n\n if (!Names.has(PDFName.of('JavaScript'))) {\n Names.set(PDFName.of('JavaScript'), context.obj({}));\n }\n const Javascript = Names.lookup(PDFName.of('JavaScript'), PDFDict);\n\n if (!Javascript.has(PDFName.of('Names'))) {\n Javascript.set(PDFName.of('Names'), context.obj([]));\n }\n const JSNames = Javascript.lookup(PDFName.of('Names'), PDFArray);\n\n JSNames.push(PDFHexString.fromText(this.embedder.scriptName));\n JSNames.push(ref);\n\n this.alreadyEmbedded = true;\n }\n }\n}\n","import { Color, rgb } from 'src/api/colors';\nimport {\n drawImage,\n drawLine,\n drawLinesOfText,\n drawPage,\n drawRectangle,\n drawSvgPath,\n drawEllipse,\n} from 'src/api/operations';\nimport {\n popGraphicsState,\n pushGraphicsState,\n translate,\n LineCapStyle,\n scale,\n} from 'src/api/operators';\nimport PDFDocument from 'src/api/PDFDocument';\nimport PDFEmbeddedPage from 'src/api/PDFEmbeddedPage';\nimport PDFFont from 'src/api/PDFFont';\nimport PDFImage from 'src/api/PDFImage';\nimport {\n PDFPageDrawCircleOptions,\n PDFPageDrawEllipseOptions,\n PDFPageDrawImageOptions,\n PDFPageDrawLineOptions,\n PDFPageDrawPageOptions,\n PDFPageDrawRectangleOptions,\n PDFPageDrawSquareOptions,\n PDFPageDrawSVGOptions,\n PDFPageDrawTextOptions,\n BlendMode,\n} from 'src/api/PDFPageOptions';\nimport { degrees, Rotation, toDegrees } from 'src/api/rotations';\nimport { StandardFonts } from 'src/api/StandardFonts';\nimport {\n PDFContentStream,\n PDFHexString,\n PDFName,\n PDFOperator,\n PDFPageLeaf,\n PDFRef,\n PDFDict,\n PDFArray,\n} from 'src/core';\nimport {\n assertEachIs,\n assertIs,\n assertMultiple,\n assertOrUndefined,\n breakTextIntoLines,\n cleanText,\n rectanglesAreEqual,\n lineSplit,\n assertRangeOrUndefined,\n assertIsOneOfOrUndefined,\n} from 'src/utils';\n\n/**\n * Represents a single page of a [[PDFDocument]].\n */\nexport default class PDFPage {\n /**\n * > **NOTE:** You probably don't want to call this method directly. Instead,\n * > consider using the [[PDFDocument.addPage]] and [[PDFDocument.insertPage]]\n * > methods, which can create instances of [[PDFPage]] for you.\n *\n * Create an instance of [[PDFPage]] from an existing leaf node.\n *\n * @param leafNode The leaf node to be wrapped.\n * @param ref The unique reference for the page.\n * @param doc The document to which the page will belong.\n */\n static of = (leafNode: PDFPageLeaf, ref: PDFRef, doc: PDFDocument) =>\n new PDFPage(leafNode, ref, doc);\n\n /**\n * > **NOTE:** You probably don't want to call this method directly. Instead,\n * > consider using the [[PDFDocument.addPage]] and [[PDFDocument.insertPage]]\n * > methods, which can create instances of [[PDFPage]] for you.\n *\n * Create an instance of [[PDFPage]].\n *\n * @param doc The document to which the page will belong.\n */\n static create = (doc: PDFDocument) => {\n assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);\n const dummyRef = PDFRef.of(-1);\n const pageLeaf = PDFPageLeaf.withContextAndParent(doc.context, dummyRef);\n const pageRef = doc.context.register(pageLeaf);\n return new PDFPage(pageLeaf, pageRef, doc);\n };\n\n /** The low-level PDFDictionary wrapped by this page. */\n readonly node: PDFPageLeaf;\n\n /** The unique reference assigned to this page within the document. */\n readonly ref: PDFRef;\n\n /** The document to which this page belongs. */\n readonly doc: PDFDocument;\n\n private fontKey?: PDFName;\n private font?: PDFFont;\n private fontSize = 24;\n private fontColor = rgb(0, 0, 0) as Color;\n private lineHeight = 24;\n private x = 0;\n private y = 0;\n private contentStream?: PDFContentStream;\n private contentStreamRef?: PDFRef;\n\n private constructor(leafNode: PDFPageLeaf, ref: PDFRef, doc: PDFDocument) {\n assertIs(leafNode, 'leafNode', [[PDFPageLeaf, 'PDFPageLeaf']]);\n assertIs(ref, 'ref', [[PDFRef, 'PDFRef']]);\n assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);\n\n this.node = leafNode;\n this.ref = ref;\n this.doc = doc;\n }\n\n /**\n * Rotate this page by a multiple of 90 degrees. For example:\n * ```js\n * import { degrees } from 'pdf-lib'\n *\n * page.setRotation(degrees(-90))\n * page.setRotation(degrees(0))\n * page.setRotation(degrees(90))\n * page.setRotation(degrees(180))\n * page.setRotation(degrees(270))\n * ```\n * @param angle The angle to rotate this page.\n */\n setRotation(angle: Rotation): void {\n const degreesAngle = toDegrees(angle);\n assertMultiple(degreesAngle, 'degreesAngle', 90);\n this.node.set(PDFName.of('Rotate'), this.doc.context.obj(degreesAngle));\n }\n\n /**\n * Get this page's rotation angle in degrees. For example:\n * ```js\n * const rotationAngle = page.getRotation().angle;\n * ```\n * @returns The rotation angle of the page in degrees (always a multiple of\n * 90 degrees).\n */\n getRotation(): Rotation {\n const Rotate = this.node.Rotate();\n return degrees(Rotate ? Rotate.asNumber() : 0);\n }\n\n /**\n * Resize this page by increasing or decreasing its width and height. For\n * example:\n * ```js\n * page.setSize(250, 500)\n * page.setSize(page.getWidth() + 50, page.getHeight() + 100)\n * page.setSize(page.getWidth() - 50, page.getHeight() - 100)\n * ```\n *\n * Note that the PDF specification does not allow for pages to have explicit\n * widths and heights. Instead it defines the \"size\" of a page in terms of\n * five rectangles: the MediaBox, CropBox, BleedBox, TrimBox, and ArtBox. As a\n * result, this method cannot directly change the width and height of a page.\n * Instead, it works by adjusting these five boxes.\n *\n * This method performs the following steps:\n * 1. Set width & height of MediaBox.\n * 2. Set width & height of CropBox, if it has same dimensions as MediaBox.\n * 3. Set width & height of BleedBox, if it has same dimensions as MediaBox.\n * 4. Set width & height of TrimBox, if it has same dimensions as MediaBox.\n * 5. Set width & height of ArtBox, if it has same dimensions as MediaBox.\n *\n * This approach works well for most PDF documents as all PDF pages must\n * have a MediaBox, but relatively few have a CropBox, BleedBox, TrimBox, or\n * ArtBox. And when they do have these additional boxes, they often have the\n * same dimensions as the MediaBox. However, if you find this method does not\n * work for your document, consider setting the boxes directly:\n * * [[PDFPage.setMediaBox]]\n * * [[PDFPage.setCropBox]]\n * * [[PDFPage.setBleedBox]]\n * * [[PDFPage.setTrimBox]]\n * * [[PDFPage.setArtBox]]\n *\n * @param width The new width of the page.\n * @param height The new height of the page.\n */\n setSize(width: number, height: number): void {\n assertIs(width, 'width', ['number']);\n assertIs(height, 'height', ['number']);\n\n const mediaBox = this.getMediaBox();\n this.setMediaBox(mediaBox.x, mediaBox.y, width, height);\n\n const cropBox = this.getCropBox();\n const bleedBox = this.getBleedBox();\n const trimBox = this.getTrimBox();\n const artBox = this.getArtBox();\n\n const hasCropBox = this.node.CropBox()!!;\n const hasBleedBox = this.node.BleedBox()!!;\n const hasTrimBox = this.node.TrimBox()!!;\n const hasArtBox = this.node.ArtBox()!!;\n\n if (hasCropBox && rectanglesAreEqual(cropBox, mediaBox)) {\n this.setCropBox(mediaBox.x, mediaBox.y, width, height);\n }\n if (hasBleedBox && rectanglesAreEqual(bleedBox, mediaBox)) {\n this.setBleedBox(mediaBox.x, mediaBox.y, width, height);\n }\n if (hasTrimBox && rectanglesAreEqual(trimBox, mediaBox)) {\n this.setTrimBox(mediaBox.x, mediaBox.y, width, height);\n }\n if (hasArtBox && rectanglesAreEqual(artBox, mediaBox)) {\n this.setArtBox(mediaBox.x, mediaBox.y, width, height);\n }\n }\n\n /**\n * Resize this page by increasing or decreasing its width. For example:\n * ```js\n * page.setWidth(250)\n * page.setWidth(page.getWidth() + 50)\n * page.setWidth(page.getWidth() - 50)\n * ```\n *\n * This method uses [[PDFPage.setSize]] to set the page's width.\n *\n * @param width The new width of the page.\n */\n setWidth(width: number): void {\n assertIs(width, 'width', ['number']);\n this.setSize(width, this.getSize().height);\n }\n\n /**\n * Resize this page by increasing or decreasing its height. For example:\n * ```js\n * page.setHeight(500)\n * page.setHeight(page.getWidth() + 100)\n * page.setHeight(page.getWidth() - 100)\n * ```\n *\n * This method uses [[PDFPage.setSize]] to set the page's height.\n *\n * @param height The new height of the page.\n */\n setHeight(height: number): void {\n assertIs(height, 'height', ['number']);\n this.setSize(this.getSize().width, height);\n }\n\n /**\n * Set the MediaBox of this page. For example:\n * ```js\n * const mediaBox = page.getMediaBox()\n *\n * page.setMediaBox(0, 0, 250, 500)\n * page.setMediaBox(mediaBox.x, mediaBox.y, 50, 100)\n * page.setMediaBox(15, 5, mediaBox.width - 50, mediaBox.height - 100)\n * ```\n *\n * See [[PDFPage.getMediaBox]] for details about what the MediaBox represents.\n *\n * @param x The x coordinate of the lower left corner of the new MediaBox.\n * @param y The y coordinate of the lower left corner of the new MediaBox.\n * @param width The width of the new MediaBox.\n * @param height The height of the new MediaBox.\n */\n setMediaBox(x: number, y: number, width: number, height: number): void {\n assertIs(x, 'x', ['number']);\n assertIs(y, 'y', ['number']);\n assertIs(width, 'width', ['number']);\n assertIs(height, 'height', ['number']);\n const mediaBox = this.doc.context.obj([x, y, x + width, y + height]);\n this.node.set(PDFName.MediaBox, mediaBox);\n }\n\n /**\n * Set the CropBox of this page. For example:\n * ```js\n * const cropBox = page.getCropBox()\n *\n * page.setCropBox(0, 0, 250, 500)\n * page.setCropBox(cropBox.x, cropBox.y, 50, 100)\n * page.setCropBox(15, 5, cropBox.width - 50, cropBox.height - 100)\n * ```\n *\n * See [[PDFPage.getCropBox]] for details about what the CropBox represents.\n *\n * @param x The x coordinate of the lower left corner of the new CropBox.\n * @param y The y coordinate of the lower left corner of the new CropBox.\n * @param width The width of the new CropBox.\n * @param height The height of the new CropBox.\n */\n setCropBox(x: number, y: number, width: number, height: number): void {\n assertIs(x, 'x', ['number']);\n assertIs(y, 'y', ['number']);\n assertIs(width, 'width', ['number']);\n assertIs(height, 'height', ['number']);\n const cropBox = this.doc.context.obj([x, y, x + width, y + height]);\n this.node.set(PDFName.CropBox, cropBox);\n }\n\n /**\n * Set the BleedBox of this page. For example:\n * ```js\n * const bleedBox = page.getBleedBox()\n *\n * page.setBleedBox(0, 0, 250, 500)\n * page.setBleedBox(bleedBox.x, bleedBox.y, 50, 100)\n * page.setBleedBox(15, 5, bleedBox.width - 50, bleedBox.height - 100)\n * ```\n *\n * See [[PDFPage.getBleedBox]] for details about what the BleedBox represents.\n *\n * @param x The x coordinate of the lower left corner of the new BleedBox.\n * @param y The y coordinate of the lower left corner of the new BleedBox.\n * @param width The width of the new BleedBox.\n * @param height The height of the new BleedBox.\n */\n setBleedBox(x: number, y: number, width: number, height: number): void {\n assertIs(x, 'x', ['number']);\n assertIs(y, 'y', ['number']);\n assertIs(width, 'width', ['number']);\n assertIs(height, 'height', ['number']);\n const bleedBox = this.doc.context.obj([x, y, x + width, y + height]);\n this.node.set(PDFName.BleedBox, bleedBox);\n }\n\n /**\n * Set the TrimBox of this page. For example:\n * ```js\n * const trimBox = page.getTrimBox()\n *\n * page.setTrimBox(0, 0, 250, 500)\n * page.setTrimBox(trimBox.x, trimBox.y, 50, 100)\n * page.setTrimBox(15, 5, trimBox.width - 50, trimBox.height - 100)\n * ```\n *\n * See [[PDFPage.getTrimBox]] for details about what the TrimBox represents.\n *\n * @param x The x coordinate of the lower left corner of the new TrimBox.\n * @param y The y coordinate of the lower left corner of the new TrimBox.\n * @param width The width of the new TrimBox.\n * @param height The height of the new TrimBox.\n */\n setTrimBox(x: number, y: number, width: number, height: number): void {\n assertIs(x, 'x', ['number']);\n assertIs(y, 'y', ['number']);\n assertIs(width, 'width', ['number']);\n assertIs(height, 'height', ['number']);\n const trimBox = this.doc.context.obj([x, y, x + width, y + height]);\n this.node.set(PDFName.TrimBox, trimBox);\n }\n\n /**\n * Set the ArtBox of this page. For example:\n * ```js\n * const artBox = page.getArtBox()\n *\n * page.setArtBox(0, 0, 250, 500)\n * page.setArtBox(artBox.x, artBox.y, 50, 100)\n * page.setArtBox(15, 5, artBox.width - 50, artBox.height - 100)\n * ```\n *\n * See [[PDFPage.getArtBox]] for details about what the ArtBox represents.\n *\n * @param x The x coordinate of the lower left corner of the new ArtBox.\n * @param y The y coordinate of the lower left corner of the new ArtBox.\n * @param width The width of the new ArtBox.\n * @param height The height of the new ArtBox.\n */\n setArtBox(x: number, y: number, width: number, height: number): void {\n assertIs(x, 'x', ['number']);\n assertIs(y, 'y', ['number']);\n assertIs(width, 'width', ['number']);\n assertIs(height, 'height', ['number']);\n const artBox = this.doc.context.obj([x, y, x + width, y + height]);\n this.node.set(PDFName.ArtBox, artBox);\n }\n\n /**\n * Get this page's width and height. For example:\n * ```js\n * const { width, height } = page.getSize()\n * ```\n *\n * This method uses [[PDFPage.getMediaBox]] to obtain the page's\n * width and height.\n *\n * @returns The width and height of the page.\n */\n getSize(): { width: number; height: number } {\n const { width, height } = this.getMediaBox();\n return { width, height };\n }\n\n /**\n * Get this page's width. For example:\n * ```js\n * const width = page.getWidth()\n * ```\n *\n * This method uses [[PDFPage.getSize]] to obtain the page's size.\n *\n * @returns The width of the page.\n */\n getWidth(): number {\n return this.getSize().width;\n }\n\n /**\n * Get this page's height. For example:\n * ```js\n * const height = page.getHeight()\n * ```\n *\n * This method uses [[PDFPage.getSize]] to obtain the page's size.\n *\n * @returns The height of the page.\n */\n getHeight(): number {\n return this.getSize().height;\n }\n\n /**\n * Get the rectangle defining this page's MediaBox. For example:\n * ```js\n * const { x, y, width, height } = page.getMediaBox()\n * ```\n *\n * The MediaBox of a page defines the boundaries of the physical medium on\n * which the page is to be displayed/printed. It may include extended area\n * surrounding the page content for bleed marks, printing marks, etc...\n * It may also include areas close to the edges of the medium that cannot be\n * marked because of physical limitations of the output device. Content\n * falling outside this boundary may safely be discarded without affecting\n * the meaning of the PDF file.\n *\n * @returns An object defining the lower left corner of the MediaBox and its\n * width & height.\n */\n getMediaBox(): { x: number; y: number; width: number; height: number } {\n const mediaBox = this.node.MediaBox();\n return mediaBox.asRectangle();\n }\n\n /**\n * Get the rectangle defining this page's CropBox. For example:\n * ```js\n * const { x, y, width, height } = page.getCropBox()\n * ```\n *\n * The CropBox of a page defines the region to which the contents of the page\n * shall be clipped when displayed or printed. Unlike the other boxes, the\n * CropBox does not necessarily represent the physical page geometry. It\n * merely imposes clipping on the page contents.\n *\n * The CropBox's default value is the page's MediaBox.\n *\n * @returns An object defining the lower left corner of the CropBox and its\n * width & height.\n */\n getCropBox(): { x: number; y: number; width: number; height: number } {\n const cropBox = this.node.CropBox();\n return cropBox?.asRectangle() ?? this.getMediaBox();\n }\n\n /**\n * Get the rectangle defining this page's BleedBox. For example:\n * ```js\n * const { x, y, width, height } = page.getBleedBox()\n * ```\n *\n * The BleedBox of a page defines the region to which the contents of the\n * page shall be clipped when output in a production environment. This may\n * include any extra bleed area needed to accommodate the physical\n * limitations of cutting, folding, and trimming equipment. The actual\n * printed page may include printing marks that fall outside the BleedBox.\n *\n * The BleedBox's default value is the page's CropBox.\n *\n * @returns An object defining the lower left corner of the BleedBox and its\n * width & height.\n */\n getBleedBox(): { x: number; y: number; width: number; height: number } {\n const bleedBox = this.node.BleedBox();\n return bleedBox?.asRectangle() ?? this.getCropBox();\n }\n\n /**\n * Get the rectangle defining this page's TrimBox. For example:\n * ```js\n * const { x, y, width, height } = page.getTrimBox()\n * ```\n *\n * The TrimBox of a page defines the intended dimensions of the finished\n * page after trimming. It may be smaller than the MediaBox to allow for\n * production-related content, such as printing instructions, cut marks, or\n * color bars.\n *\n * The TrimBox's default value is the page's CropBox.\n *\n * @returns An object defining the lower left corner of the TrimBox and its\n * width & height.\n */\n getTrimBox(): { x: number; y: number; width: number; height: number } {\n const trimBox = this.node.TrimBox();\n return trimBox?.asRectangle() ?? this.getCropBox();\n }\n\n /**\n * Get the rectangle defining this page's ArtBox. For example:\n * ```js\n * const { x, y, width, height } = page.getArtBox()\n * ```\n *\n * The ArtBox of a page defines the extent of the page's meaningful content\n * (including potential white space).\n *\n * The ArtBox's default value is the page's CropBox.\n *\n * @returns An object defining the lower left corner of the ArtBox and its\n * width & height.\n */\n getArtBox(): { x: number; y: number; width: number; height: number } {\n const artBox = this.node.ArtBox();\n return artBox?.asRectangle() ?? this.getCropBox();\n }\n\n /**\n * Translate this page's content to a new location on the page. This operation\n * is often useful after resizing the page with [[setSize]]. For example:\n * ```js\n * // Add 50 units of whitespace to the top and right of the page\n * page.setSize(page.getWidth() + 50, page.getHeight() + 50)\n *\n * // Move the page's content from the lower-left corner of the page\n * // to the top-right corner.\n * page.translateContent(50, 50)\n *\n * // Now there are 50 units of whitespace to the left and bottom of the page\n * ```\n * See also: [[resetPosition]]\n * @param x The new position on the x-axis for this page's content.\n * @param y The new position on the y-axis for this page's content.\n */\n translateContent(x: number, y: number): void {\n assertIs(x, 'x', ['number']);\n assertIs(y, 'y', ['number']);\n\n this.node.normalize();\n this.getContentStream();\n\n const start = this.createContentStream(\n pushGraphicsState(),\n translate(x, y),\n );\n const startRef = this.doc.context.register(start);\n\n const end = this.createContentStream(popGraphicsState());\n const endRef = this.doc.context.register(end);\n\n this.node.wrapContentStreams(startRef, endRef);\n }\n\n /**\n * Scale the size, content, and annotations of a page.\n *\n * For example:\n * ```js\n * page.scale(0.5, 0.5);\n * ```\n *\n * @param x The factor by which the width for the page should be scaled\n * (e.g. `0.5` is 50%).\n * @param y The factor by which the height for the page should be scaled\n * (e.g. `2.0` is 200%).\n */\n scale(x: number, y: number): void {\n assertIs(x, 'x', ['number']);\n assertIs(y, 'y', ['number']);\n this.setSize(this.getWidth() * x, this.getHeight() * y);\n this.scaleContent(x, y);\n this.scaleAnnotations(x, y);\n }\n\n /**\n * Scale the content of a page. This is useful after resizing an existing\n * page. This scales only the content, not the annotations.\n *\n * For example:\n * ```js\n * // Bisect the size of the page\n * page.setSize(page.getWidth() / 2, page.getHeight() / 2);\n *\n * // Scale the content of the page down by 50% in x and y\n * page.scaleContent(0.5, 0.5);\n * ```\n * See also: [[scaleAnnotations]]\n * @param x The factor by which the x-axis for the content should be scaled\n * (e.g. `0.5` is 50%).\n * @param y The factor by which the y-axis for the content should be scaled\n * (e.g. `2.0` is 200%).\n */\n scaleContent(x: number, y: number): void {\n assertIs(x, 'x', ['number']);\n assertIs(y, 'y', ['number']);\n\n this.node.normalize();\n this.getContentStream();\n\n const start = this.createContentStream(pushGraphicsState(), scale(x, y));\n const startRef = this.doc.context.register(start);\n\n const end = this.createContentStream(popGraphicsState());\n const endRef = this.doc.context.register(end);\n\n this.node.wrapContentStreams(startRef, endRef);\n }\n\n /**\n * Scale the annotations of a page. This is useful if you want to scale a\n * page with comments or other annotations.\n * ```js\n * // Scale the content of the page down by 50% in x and y\n * page.scaleContent(0.5, 0.5);\n *\n * // Scale the content of the page down by 50% in x and y\n * page.scaleAnnotations(0.5, 0.5);\n * ```\n * See also: [[scaleContent]]\n * @param x The factor by which the x-axis for the annotations should be\n * scaled (e.g. `0.5` is 50%).\n * @param y The factor by which the y-axis for the annotations should be\n * scaled (e.g. `2.0` is 200%).\n */\n scaleAnnotations(x: number, y: number) {\n assertIs(x, 'x', ['number']);\n assertIs(y, 'y', ['number']);\n\n const annots = this.node.Annots();\n if (!annots) return;\n\n for (let idx = 0; idx < annots.size(); idx++) {\n const annot = annots.lookup(idx);\n if (annot instanceof PDFDict) this.scaleAnnot(annot, x, y);\n }\n }\n\n /**\n * Reset the x and y coordinates of this page to `(0, 0)`. This operation is\n * often useful after calling [[translateContent]]. For example:\n * ```js\n * // Shift the page's contents up and to the right by 50 units\n * page.translateContent(50, 50)\n *\n * // This text will shifted - it will be drawn at (50, 50)\n * page.drawText('I am shifted')\n *\n * // Move back to (0, 0)\n * page.resetPosition()\n *\n * // This text will not be shifted - it will be drawn at (0, 0)\n * page.drawText('I am not shifted')\n * ```\n */\n resetPosition(): void {\n this.getContentStream(false);\n this.x = 0;\n this.y = 0;\n }\n\n /**\n * Choose a default font for this page. The default font will be used whenever\n * text is drawn on this page and no font is specified. For example:\n * ```js\n * import { StandardFonts } from 'pdf-lib'\n *\n * const timesRomanFont = await pdfDoc.embedFont(StandardFonts.TimesRoman)\n * const helveticaFont = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const courierFont = await pdfDoc.embedFont(StandardFonts.Courier)\n *\n * const page = pdfDoc.addPage()\n *\n * page.setFont(helveticaFont)\n * page.drawText('I will be drawn in Helvetica')\n *\n * page.setFont(timesRomanFont)\n * page.drawText('I will be drawn in Courier', { font: courierFont })\n * ```\n * @param font The default font to be used when drawing text on this page.\n */\n setFont(font: PDFFont): void {\n // TODO: Reuse image Font name if we've already added this image to Resources.Fonts\n assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n this.font = font;\n this.fontKey = this.node.newFontDictionary(this.font.name, this.font.ref);\n }\n\n /**\n * Choose a default font size for this page. The default font size will be\n * used whenever text is drawn on this page and no font size is specified.\n * For example:\n * ```js\n * page.setFontSize(12)\n * page.drawText('I will be drawn in size 12')\n *\n * page.setFontSize(36)\n * page.drawText('I will be drawn in size 24', { fontSize: 24 })\n * ```\n * @param fontSize The default font size to be used when drawing text on this\n * page.\n */\n setFontSize(fontSize: number): void {\n assertIs(fontSize, 'fontSize', ['number']);\n this.fontSize = fontSize;\n }\n\n /**\n * Choose a default font color for this page. The default font color will be\n * used whenever text is drawn on this page and no font color is specified.\n * For example:\n * ```js\n * import { rgb, cmyk, grayscale } from 'pdf-lib'\n *\n * page.setFontColor(rgb(0.97, 0.02, 0.97))\n * page.drawText('I will be drawn in pink')\n *\n * page.setFontColor(cmyk(0.4, 0.7, 0.39, 0.15))\n * page.drawText('I will be drawn in gray', { color: grayscale(0.5) })\n * ```\n * @param fontColor The default font color to be used when drawing text on\n * this page.\n */\n setFontColor(fontColor: Color): void {\n assertIs(fontColor, 'fontColor', [[Object, 'Color']]);\n this.fontColor = fontColor;\n }\n\n /**\n * Choose a default line height for this page. The default line height will be\n * used whenever text is drawn on this page and no line height is specified.\n * For example:\n * ```js\n * page.setLineHeight(12);\n * page.drawText('These lines will be vertically \\n separated by 12 units')\n *\n * page.setLineHeight(36);\n * page.drawText('These lines will be vertically \\n separated by 24 units', {\n * lineHeight: 24\n * })\n * ```\n * @param lineHeight The default line height to be used when drawing text on\n * this page.\n */\n setLineHeight(lineHeight: number): void {\n assertIs(lineHeight, 'lineHeight', ['number']);\n this.lineHeight = lineHeight;\n }\n\n /**\n * Get the default position of this page. For example:\n * ```js\n * const { x, y } = page.getPosition()\n * ```\n * @returns The default position of the page.\n */\n getPosition(): { x: number; y: number } {\n return { x: this.x, y: this.y };\n }\n\n /**\n * Get the default x coordinate of this page. For example:\n * ```js\n * const x = page.getX()\n * ```\n * @returns The default x coordinate of the page.\n */\n getX(): number {\n return this.x;\n }\n\n /**\n * Get the default y coordinate of this page. For example:\n * ```js\n * const y = page.getY()\n * ```\n * @returns The default y coordinate of the page.\n */\n getY(): number {\n return this.y;\n }\n\n /**\n * Change the default position of this page. For example:\n * ```js\n * page.moveTo(0, 0)\n * page.drawText('I will be drawn at the origin')\n *\n * page.moveTo(0, 25)\n * page.drawText('I will be drawn 25 units up')\n *\n * page.moveTo(25, 25)\n * page.drawText('I will be drawn 25 units up and 25 units to the right')\n * ```\n * @param x The new default position on the x-axis for this page.\n * @param y The new default position on the y-axis for this page.\n */\n moveTo(x: number, y: number): void {\n assertIs(x, 'x', ['number']);\n assertIs(y, 'y', ['number']);\n this.x = x;\n this.y = y;\n }\n\n /**\n * Change the default position of this page to be further down the y-axis.\n * For example:\n * ```js\n * page.moveTo(50, 50)\n * page.drawText('I will be drawn at (50, 50)')\n *\n * page.moveDown(10)\n * page.drawText('I will be drawn at (50, 40)')\n * ```\n * @param yDecrease The amount by which the page's default position along the\n * y-axis should be decreased.\n */\n moveDown(yDecrease: number): void {\n assertIs(yDecrease, 'yDecrease', ['number']);\n this.y -= yDecrease;\n }\n\n /**\n * Change the default position of this page to be further up the y-axis.\n * For example:\n * ```js\n * page.moveTo(50, 50)\n * page.drawText('I will be drawn at (50, 50)')\n *\n * page.moveUp(10)\n * page.drawText('I will be drawn at (50, 60)')\n * ```\n * @param yIncrease The amount by which the page's default position along the\n * y-axis should be increased.\n */\n moveUp(yIncrease: number): void {\n assertIs(yIncrease, 'yIncrease', ['number']);\n this.y += yIncrease;\n }\n\n /**\n * Change the default position of this page to be further left on the x-axis.\n * For example:\n * ```js\n * page.moveTo(50, 50)\n * page.drawText('I will be drawn at (50, 50)')\n *\n * page.moveLeft(10)\n * page.drawText('I will be drawn at (40, 50)')\n * ```\n * @param xDecrease The amount by which the page's default position along the\n * x-axis should be decreased.\n */\n moveLeft(xDecrease: number): void {\n assertIs(xDecrease, 'xDecrease', ['number']);\n this.x -= xDecrease;\n }\n\n /**\n * Change the default position of this page to be further right on the y-axis.\n * For example:\n * ```js\n * page.moveTo(50, 50)\n * page.drawText('I will be drawn at (50, 50)')\n *\n * page.moveRight(10)\n * page.drawText('I will be drawn at (60, 50)')\n * ```\n * @param xIncrease The amount by which the page's default position along the\n * x-axis should be increased.\n */\n moveRight(xIncrease: number): void {\n assertIs(xIncrease, 'xIncrease', ['number']);\n this.x += xIncrease;\n }\n\n /**\n * Push one or more operators to the end of this page's current content\n * stream. For example:\n * ```js\n * import {\n * pushGraphicsState,\n * moveTo,\n * lineTo,\n * closePath,\n * setFillingColor,\n * rgb,\n * fill,\n * popGraphicsState,\n * } from 'pdf-lib'\n *\n * // Draw a green triangle in the lower-left corner of the page\n * page.pushOperators(\n * pushGraphicsState(),\n * moveTo(0, 0),\n * lineTo(100, 0),\n * lineTo(50, 100),\n * closePath(),\n * setFillingColor(rgb(0.0, 1.0, 0.0)),\n * fill(),\n * popGraphicsState(),\n * )\n * ```\n * @param operator The operators to be pushed.\n */\n pushOperators(...operator: PDFOperator[]): void {\n assertEachIs(operator, 'operator', [[PDFOperator, 'PDFOperator']]);\n const contentStream = this.getContentStream();\n contentStream.push(...operator);\n }\n\n /**\n * Draw one or more lines of text on this page. For example:\n * ```js\n * import { StandardFonts, rgb } from 'pdf-lib'\n *\n * const helveticaFont = await pdfDoc.embedFont(StandardFonts.Helvetica)\n * const timesRomanFont = await pdfDoc.embedFont(StandardFonts.TimesRoman)\n *\n * const page = pdfDoc.addPage()\n *\n * page.setFont(helveticaFont)\n *\n * page.moveTo(5, 200)\n * page.drawText('The Life of an Egg', { size: 36 })\n *\n * page.moveDown(36)\n * page.drawText('An Epic Tale of Woe', { size: 30 })\n *\n * page.drawText(\n * `Humpty Dumpty sat on a wall \\n` +\n * `Humpty Dumpty had a great fall; \\n` +\n * `All the king's horses and all the king's men \\n` +\n * `Couldn't put Humpty together again. \\n`,\n * {\n * x: 25,\n * y: 100,\n * font: timesRomanFont,\n * size: 24,\n * color: rgb(1, 0, 0),\n * lineHeight: 24,\n * opacity: 0.75,\n * },\n * )\n * ```\n * @param text The text to be drawn.\n * @param options The options to be used when drawing the text.\n */\n drawText(text: string, options: PDFPageDrawTextOptions = {}): void {\n assertIs(text, 'text', ['string']);\n assertOrUndefined(options.color, 'options.color', [[Object, 'Color']]);\n assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);\n assertOrUndefined(options.font, 'options.font', [[PDFFont, 'PDFFont']]);\n assertOrUndefined(options.size, 'options.size', ['number']);\n assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);\n assertOrUndefined(options.xSkew, 'options.xSkew', [[Object, 'Rotation']]);\n assertOrUndefined(options.ySkew, 'options.ySkew', [[Object, 'Rotation']]);\n assertOrUndefined(options.x, 'options.x', ['number']);\n assertOrUndefined(options.y, 'options.y', ['number']);\n assertOrUndefined(options.lineHeight, 'options.lineHeight', ['number']);\n assertOrUndefined(options.maxWidth, 'options.maxWidth', ['number']);\n assertOrUndefined(options.wordBreaks, 'options.wordBreaks', [Array]);\n assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);\n\n const { oldFont, newFont, newFontKey } = this.setOrEmbedFont(options.font);\n const fontSize = options.size || this.fontSize;\n\n const wordBreaks = options.wordBreaks || this.doc.defaultWordBreaks;\n const textWidth = (t: string) => newFont.widthOfTextAtSize(t, fontSize);\n const lines =\n options.maxWidth === undefined\n ? lineSplit(cleanText(text))\n : breakTextIntoLines(text, wordBreaks, options.maxWidth, textWidth);\n\n const encodedLines = new Array(lines.length) as PDFHexString[];\n for (let idx = 0, len = lines.length; idx < len; idx++) {\n encodedLines[idx] = newFont.encodeText(lines[idx]);\n }\n\n const graphicsStateKey = this.maybeEmbedGraphicsState({\n opacity: options.opacity,\n blendMode: options.blendMode,\n });\n\n const contentStream = this.getContentStream();\n contentStream.push(\n ...drawLinesOfText(encodedLines, {\n color: options.color ?? this.fontColor,\n font: newFontKey,\n size: fontSize,\n rotate: options.rotate ?? degrees(0),\n xSkew: options.xSkew ?? degrees(0),\n ySkew: options.ySkew ?? degrees(0),\n x: options.x ?? this.x,\n y: options.y ?? this.y,\n lineHeight: options.lineHeight ?? this.lineHeight,\n graphicsState: graphicsStateKey,\n }),\n );\n\n if (options.font) {\n if (oldFont) this.setFont(oldFont);\n else this.resetFont();\n }\n }\n\n /**\n * Draw an image on this page. For example:\n * ```js\n * import { degrees } from 'pdf-lib'\n *\n * const jpgUrl = 'https://pdf-lib.js.org/assets/cat_riding_unicorn.jpg'\n * const jpgImageBytes = await fetch(jpgUrl).then((res) => res.arrayBuffer())\n *\n * const jpgImage = await pdfDoc.embedJpg(jpgImageBytes)\n * const jpgDims = jpgImage.scale(0.5)\n *\n * const page = pdfDoc.addPage()\n *\n * page.drawImage(jpgImage, {\n * x: 25,\n * y: 25,\n * width: jpgDims.width,\n * height: jpgDims.height,\n * rotate: degrees(30),\n * opacity: 0.75,\n * })\n * ```\n * @param image The image to be drawn.\n * @param options The options to be used when drawing the image.\n */\n drawImage(image: PDFImage, options: PDFPageDrawImageOptions = {}): void {\n // TODO: Reuse image XObject name if we've already added this image to Resources.XObjects\n assertIs(image, 'image', [[PDFImage, 'PDFImage']]);\n assertOrUndefined(options.x, 'options.x', ['number']);\n assertOrUndefined(options.y, 'options.y', ['number']);\n assertOrUndefined(options.width, 'options.width', ['number']);\n assertOrUndefined(options.height, 'options.height', ['number']);\n assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);\n assertOrUndefined(options.xSkew, 'options.xSkew', [[Object, 'Rotation']]);\n assertOrUndefined(options.ySkew, 'options.ySkew', [[Object, 'Rotation']]);\n assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);\n assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);\n\n const xObjectKey = this.node.newXObject('Image', image.ref);\n\n const graphicsStateKey = this.maybeEmbedGraphicsState({\n opacity: options.opacity,\n blendMode: options.blendMode,\n });\n\n const contentStream = this.getContentStream();\n contentStream.push(\n ...drawImage(xObjectKey, {\n x: options.x ?? this.x,\n y: options.y ?? this.y,\n width: options.width ?? image.size().width,\n height: options.height ?? image.size().height,\n rotate: options.rotate ?? degrees(0),\n xSkew: options.xSkew ?? degrees(0),\n ySkew: options.ySkew ?? degrees(0),\n graphicsState: graphicsStateKey,\n }),\n );\n }\n\n /**\n * Draw an embedded PDF page on this page. For example:\n * ```js\n * import { degrees } from 'pdf-lib'\n *\n * const pdfDoc = await PDFDocument.create()\n * const page = pdfDoc.addPage()\n *\n * const sourcePdfUrl = 'https://pdf-lib.js.org/assets/with_large_page_count.pdf'\n * const sourcePdf = await fetch(sourcePdfUrl).then((res) => res.arrayBuffer())\n *\n * // Embed page 74 from the PDF\n * const [embeddedPage] = await pdfDoc.embedPdf(sourcePdf, 73)\n *\n * page.drawPage(embeddedPage, {\n * x: 250,\n * y: 200,\n * xScale: 0.5,\n * yScale: 0.5,\n * rotate: degrees(30),\n * opacity: 0.75,\n * })\n * ```\n *\n * The `options` argument accepts both `width`/`height` and `xScale`/`yScale`\n * as options. Since each of these options defines the size of the drawn page,\n * if both options are given, `width` and `height` take precedence and the\n * corresponding scale variants are ignored.\n *\n * @param embeddedPage The embedded page to be drawn.\n * @param options The options to be used when drawing the embedded page.\n */\n drawPage(\n embeddedPage: PDFEmbeddedPage,\n options: PDFPageDrawPageOptions = {},\n ): void {\n // TODO: Reuse embeddedPage XObject name if we've already added this embeddedPage to Resources.XObjects\n assertIs(embeddedPage, 'embeddedPage', [\n [PDFEmbeddedPage, 'PDFEmbeddedPage'],\n ]);\n assertOrUndefined(options.x, 'options.x', ['number']);\n assertOrUndefined(options.y, 'options.y', ['number']);\n assertOrUndefined(options.xScale, 'options.xScale', ['number']);\n assertOrUndefined(options.yScale, 'options.yScale', ['number']);\n assertOrUndefined(options.width, 'options.width', ['number']);\n assertOrUndefined(options.height, 'options.height', ['number']);\n assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);\n assertOrUndefined(options.xSkew, 'options.xSkew', [[Object, 'Rotation']]);\n assertOrUndefined(options.ySkew, 'options.ySkew', [[Object, 'Rotation']]);\n assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);\n assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);\n\n const xObjectKey = this.node.newXObject(\n 'EmbeddedPdfPage',\n embeddedPage.ref,\n );\n\n const graphicsStateKey = this.maybeEmbedGraphicsState({\n opacity: options.opacity,\n blendMode: options.blendMode,\n });\n\n // prettier-ignore\n const xScale = (\n options.width !== undefined ? options.width / embeddedPage.width\n : options.xScale !== undefined ? options.xScale\n : 1\n );\n\n // prettier-ignore\n const yScale = (\n options.height !== undefined ? options.height / embeddedPage.height\n : options.yScale !== undefined ? options.yScale\n : 1\n );\n\n const contentStream = this.getContentStream();\n contentStream.push(\n ...drawPage(xObjectKey, {\n x: options.x ?? this.x,\n y: options.y ?? this.y,\n xScale,\n yScale,\n rotate: options.rotate ?? degrees(0),\n xSkew: options.xSkew ?? degrees(0),\n ySkew: options.ySkew ?? degrees(0),\n graphicsState: graphicsStateKey,\n }),\n );\n }\n\n /**\n * Draw an SVG path on this page. For example:\n * ```js\n * import { rgb } from 'pdf-lib'\n *\n * const svgPath = 'M 0,20 L 100,160 Q 130,200 150,120 C 190,-40 200,200 300,150 L 400,90'\n *\n * // Draw path as black line\n * page.drawSvgPath(svgPath, { x: 25, y: 75 })\n *\n * // Change border style and opacity\n * page.drawSvgPath(svgPath, {\n * x: 25,\n * y: 275,\n * borderColor: rgb(0.5, 0.5, 0.5),\n * borderWidth: 2,\n * borderOpacity: 0.75,\n * })\n *\n * // Set fill color and opacity\n * page.drawSvgPath(svgPath, {\n * x: 25,\n * y: 475,\n * color: rgb(1.0, 0, 0),\n * opacity: 0.75,\n * })\n *\n * // Draw 50% of original size\n * page.drawSvgPath(svgPath, {\n * x: 25,\n * y: 675,\n * scale: 0.5,\n * })\n * ```\n * @param path The SVG path to be drawn.\n * @param options The options to be used when drawing the SVG path.\n */\n drawSvgPath(path: string, options: PDFPageDrawSVGOptions = {}): void {\n assertIs(path, 'path', ['string']);\n assertOrUndefined(options.x, 'options.x', ['number']);\n assertOrUndefined(options.y, 'options.y', ['number']);\n assertOrUndefined(options.scale, 'options.scale', ['number']);\n assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);\n assertOrUndefined(options.borderWidth, 'options.borderWidth', ['number']);\n assertOrUndefined(options.color, 'options.color', [[Object, 'Color']]);\n assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);\n assertOrUndefined(options.borderColor, 'options.borderColor', [\n [Object, 'Color'],\n ]);\n assertOrUndefined(options.borderDashArray, 'options.borderDashArray', [\n Array,\n ]);\n assertOrUndefined(options.borderDashPhase, 'options.borderDashPhase', [\n 'number',\n ]);\n assertIsOneOfOrUndefined(\n options.borderLineCap,\n 'options.borderLineCap',\n LineCapStyle,\n );\n assertRangeOrUndefined(\n options.borderOpacity,\n 'options.borderOpacity',\n 0,\n 1,\n );\n assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);\n\n const graphicsStateKey = this.maybeEmbedGraphicsState({\n opacity: options.opacity,\n borderOpacity: options.borderOpacity,\n blendMode: options.blendMode,\n });\n\n if (!('color' in options) && !('borderColor' in options)) {\n options.borderColor = rgb(0, 0, 0);\n }\n\n const contentStream = this.getContentStream();\n contentStream.push(\n ...drawSvgPath(path, {\n x: options.x ?? this.x,\n y: options.y ?? this.y,\n scale: options.scale,\n rotate: options.rotate ?? degrees(0),\n color: options.color ?? undefined,\n borderColor: options.borderColor ?? undefined,\n borderWidth: options.borderWidth ?? 0,\n borderDashArray: options.borderDashArray ?? undefined,\n borderDashPhase: options.borderDashPhase ?? undefined,\n borderLineCap: options.borderLineCap ?? undefined,\n graphicsState: graphicsStateKey,\n }),\n );\n }\n\n /**\n * Draw a line on this page. For example:\n * ```js\n * import { rgb } from 'pdf-lib'\n *\n * page.drawLine({\n * start: { x: 25, y: 75 },\n * end: { x: 125, y: 175 },\n * thickness: 2,\n * color: rgb(0.75, 0.2, 0.2),\n * opacity: 0.75,\n * })\n * ```\n * @param options The options to be used when drawing the line.\n */\n drawLine(options: PDFPageDrawLineOptions): void {\n assertIs(options.start, 'options.start', [\n [Object, '{ x: number, y: number }'],\n ]);\n assertIs(options.end, 'options.end', [\n [Object, '{ x: number, y: number }'],\n ]);\n assertIs(options.start.x, 'options.start.x', ['number']);\n assertIs(options.start.y, 'options.start.y', ['number']);\n assertIs(options.end.x, 'options.end.x', ['number']);\n assertIs(options.end.y, 'options.end.y', ['number']);\n assertOrUndefined(options.thickness, 'options.thickness', ['number']);\n assertOrUndefined(options.color, 'options.color', [[Object, 'Color']]);\n assertOrUndefined(options.dashArray, 'options.dashArray', [Array]);\n assertOrUndefined(options.dashPhase, 'options.dashPhase', ['number']);\n assertIsOneOfOrUndefined(options.lineCap, 'options.lineCap', LineCapStyle);\n assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);\n assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);\n\n const graphicsStateKey = this.maybeEmbedGraphicsState({\n borderOpacity: options.opacity,\n blendMode: options.blendMode,\n });\n\n if (!('color' in options)) {\n options.color = rgb(0, 0, 0);\n }\n\n const contentStream = this.getContentStream();\n contentStream.push(\n ...drawLine({\n start: options.start,\n end: options.end,\n thickness: options.thickness ?? 1,\n color: options.color ?? undefined,\n dashArray: options.dashArray ?? undefined,\n dashPhase: options.dashPhase ?? undefined,\n lineCap: options.lineCap ?? undefined,\n graphicsState: graphicsStateKey,\n }),\n );\n }\n\n /**\n * Draw a rectangle on this page. For example:\n * ```js\n * import { degrees, grayscale, rgb } from 'pdf-lib'\n *\n * page.drawRectangle({\n * x: 25,\n * y: 75,\n * width: 250,\n * height: 75,\n * rotate: degrees(-15),\n * borderWidth: 5,\n * borderColor: grayscale(0.5),\n * color: rgb(0.75, 0.2, 0.2),\n * opacity: 0.5,\n * borderOpacity: 0.75,\n * })\n * ```\n * @param options The options to be used when drawing the rectangle.\n */\n drawRectangle(options: PDFPageDrawRectangleOptions = {}): void {\n assertOrUndefined(options.x, 'options.x', ['number']);\n assertOrUndefined(options.y, 'options.y', ['number']);\n assertOrUndefined(options.width, 'options.width', ['number']);\n assertOrUndefined(options.height, 'options.height', ['number']);\n assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);\n assertOrUndefined(options.xSkew, 'options.xSkew', [[Object, 'Rotation']]);\n assertOrUndefined(options.ySkew, 'options.ySkew', [[Object, 'Rotation']]);\n assertOrUndefined(options.borderWidth, 'options.borderWidth', ['number']);\n assertOrUndefined(options.color, 'options.color', [[Object, 'Color']]);\n assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);\n assertOrUndefined(options.borderColor, 'options.borderColor', [\n [Object, 'Color'],\n ]);\n assertOrUndefined(options.borderDashArray, 'options.borderDashArray', [\n Array,\n ]);\n assertOrUndefined(options.borderDashPhase, 'options.borderDashPhase', [\n 'number',\n ]);\n assertIsOneOfOrUndefined(\n options.borderLineCap,\n 'options.borderLineCap',\n LineCapStyle,\n );\n assertRangeOrUndefined(\n options.borderOpacity,\n 'options.borderOpacity',\n 0,\n 1,\n );\n assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);\n\n const graphicsStateKey = this.maybeEmbedGraphicsState({\n opacity: options.opacity,\n borderOpacity: options.borderOpacity,\n blendMode: options.blendMode,\n });\n\n if (!('color' in options) && !('borderColor' in options)) {\n options.color = rgb(0, 0, 0);\n }\n\n const contentStream = this.getContentStream();\n contentStream.push(\n ...drawRectangle({\n x: options.x ?? this.x,\n y: options.y ?? this.y,\n width: options.width ?? 150,\n height: options.height ?? 100,\n rotate: options.rotate ?? degrees(0),\n xSkew: options.xSkew ?? degrees(0),\n ySkew: options.ySkew ?? degrees(0),\n borderWidth: options.borderWidth ?? 0,\n color: options.color ?? undefined,\n borderColor: options.borderColor ?? undefined,\n borderDashArray: options.borderDashArray ?? undefined,\n borderDashPhase: options.borderDashPhase ?? undefined,\n graphicsState: graphicsStateKey,\n borderLineCap: options.borderLineCap ?? undefined,\n }),\n );\n }\n\n /**\n * Draw a square on this page. For example:\n * ```js\n * import { degrees, grayscale, rgb } from 'pdf-lib'\n *\n * page.drawSquare({\n * x: 25,\n * y: 75,\n * size: 100,\n * rotate: degrees(-15),\n * borderWidth: 5,\n * borderColor: grayscale(0.5),\n * color: rgb(0.75, 0.2, 0.2),\n * opacity: 0.5,\n * borderOpacity: 0.75,\n * })\n * ```\n * @param options The options to be used when drawing the square.\n */\n drawSquare(options: PDFPageDrawSquareOptions = {}): void {\n const { size } = options;\n assertOrUndefined(size, 'size', ['number']);\n this.drawRectangle({ ...options, width: size, height: size });\n }\n\n /**\n * Draw an ellipse on this page. For example:\n * ```js\n * import { grayscale, rgb } from 'pdf-lib'\n *\n * page.drawEllipse({\n * x: 200,\n * y: 75,\n * xScale: 100,\n * yScale: 50,\n * borderWidth: 5,\n * borderColor: grayscale(0.5),\n * color: rgb(0.75, 0.2, 0.2),\n * opacity: 0.5,\n * borderOpacity: 0.75,\n * })\n * ```\n * @param options The options to be used when drawing the ellipse.\n */\n drawEllipse(options: PDFPageDrawEllipseOptions = {}): void {\n assertOrUndefined(options.x, 'options.x', ['number']);\n assertOrUndefined(options.y, 'options.y', ['number']);\n assertOrUndefined(options.xScale, 'options.xScale', ['number']);\n assertOrUndefined(options.yScale, 'options.yScale', ['number']);\n assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);\n assertOrUndefined(options.color, 'options.color', [[Object, 'Color']]);\n assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);\n assertOrUndefined(options.borderColor, 'options.borderColor', [\n [Object, 'Color'],\n ]);\n assertRangeOrUndefined(\n options.borderOpacity,\n 'options.borderOpacity',\n 0,\n 1,\n );\n assertOrUndefined(options.borderWidth, 'options.borderWidth', ['number']);\n assertOrUndefined(options.borderDashArray, 'options.borderDashArray', [\n Array,\n ]);\n assertOrUndefined(options.borderDashPhase, 'options.borderDashPhase', [\n 'number',\n ]);\n assertIsOneOfOrUndefined(\n options.borderLineCap,\n 'options.borderLineCap',\n LineCapStyle,\n );\n assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);\n const graphicsStateKey = this.maybeEmbedGraphicsState({\n opacity: options.opacity,\n borderOpacity: options.borderOpacity,\n blendMode: options.blendMode,\n });\n\n if (!('color' in options) && !('borderColor' in options)) {\n options.color = rgb(0, 0, 0);\n }\n\n const contentStream = this.getContentStream();\n contentStream.push(\n ...drawEllipse({\n x: options.x ?? this.x,\n y: options.y ?? this.y,\n xScale: options.xScale ?? 100,\n yScale: options.yScale ?? 100,\n rotate: options.rotate ?? undefined,\n color: options.color ?? undefined,\n borderColor: options.borderColor ?? undefined,\n borderWidth: options.borderWidth ?? 0,\n borderDashArray: options.borderDashArray ?? undefined,\n borderDashPhase: options.borderDashPhase ?? undefined,\n borderLineCap: options.borderLineCap ?? undefined,\n graphicsState: graphicsStateKey,\n }),\n );\n }\n\n /**\n * Draw a circle on this page. For example:\n * ```js\n * import { grayscale, rgb } from 'pdf-lib'\n *\n * page.drawCircle({\n * x: 200,\n * y: 150,\n * size: 100,\n * borderWidth: 5,\n * borderColor: grayscale(0.5),\n * color: rgb(0.75, 0.2, 0.2),\n * opacity: 0.5,\n * borderOpacity: 0.75,\n * })\n * ```\n * @param options The options to be used when drawing the ellipse.\n */\n drawCircle(options: PDFPageDrawCircleOptions = {}): void {\n const { size = 100 } = options;\n assertOrUndefined(size, 'size', ['number']);\n this.drawEllipse({ ...options, xScale: size, yScale: size });\n }\n\n private setOrEmbedFont(font?: PDFFont) {\n const oldFont = this.font;\n const oldFontKey = this.fontKey;\n\n if (font) this.setFont(font);\n else this.getFont();\n\n const newFont = this.font!;\n const newFontKey = this.fontKey!;\n\n return { oldFont, oldFontKey, newFont, newFontKey };\n }\n\n private getFont(): [PDFFont, PDFName] {\n if (!this.font || !this.fontKey) {\n const font = this.doc.embedStandardFont(StandardFonts.Helvetica);\n this.setFont(font);\n }\n return [this.font!, this.fontKey!];\n }\n\n private resetFont(): void {\n this.font = undefined;\n this.fontKey = undefined;\n }\n\n private getContentStream(useExisting = true): PDFContentStream {\n if (useExisting && this.contentStream) return this.contentStream;\n this.contentStream = this.createContentStream();\n this.contentStreamRef = this.doc.context.register(this.contentStream);\n this.node.addContentStream(this.contentStreamRef);\n return this.contentStream;\n }\n\n private createContentStream(...operators: PDFOperator[]): PDFContentStream {\n const dict = this.doc.context.obj({});\n const contentStream = PDFContentStream.of(dict, operators);\n return contentStream;\n }\n\n private maybeEmbedGraphicsState(options: {\n opacity?: number;\n borderOpacity?: number;\n blendMode?: BlendMode;\n }): PDFName | undefined {\n const { opacity, borderOpacity, blendMode } = options;\n\n if (\n opacity === undefined &&\n borderOpacity === undefined &&\n blendMode === undefined\n ) {\n return undefined;\n }\n\n const graphicsState = this.doc.context.obj({\n Type: 'ExtGState',\n ca: opacity,\n CA: borderOpacity,\n BM: blendMode,\n });\n\n const key = this.node.newExtGState('GS', graphicsState);\n\n return key;\n }\n\n private scaleAnnot(annot: PDFDict, x: number, y: number) {\n const selectors = ['RD', 'CL', 'Vertices', 'QuadPoints', 'L', 'Rect'];\n for (let idx = 0, len = selectors.length; idx < len; idx++) {\n const list = annot.lookup(PDFName.of(selectors[idx]));\n if (list instanceof PDFArray) list.scalePDFNumbers(x, y);\n }\n\n const inkLists = annot.lookup(PDFName.of('InkList'));\n if (inkLists instanceof PDFArray) {\n for (let idx = 0, len = inkLists.size(); idx < len; idx++) {\n const arr = inkLists.lookup(idx);\n if (arr instanceof PDFArray) arr.scalePDFNumbers(x, y);\n }\n }\n }\n}\n","import { Color } from 'src/api/colors';\nimport PDFFont from 'src/api/PDFFont';\nimport { Rotation } from 'src/api/rotations';\nimport { LineCapStyle } from 'src/api/operators';\n\nexport enum BlendMode {\n Normal = 'Normal',\n Multiply = 'Multiply',\n Screen = 'Screen',\n Overlay = 'Overlay',\n Darken = 'Darken',\n Lighten = 'Lighten',\n ColorDodge = 'ColorDodge',\n ColorBurn = 'ColorBurn',\n HardLight = 'HardLight',\n SoftLight = 'SoftLight',\n Difference = 'Difference',\n Exclusion = 'Exclusion',\n}\n\nexport interface PDFPageDrawTextOptions {\n color?: Color;\n opacity?: number;\n blendMode?: BlendMode;\n font?: PDFFont;\n size?: number;\n rotate?: Rotation;\n xSkew?: Rotation;\n ySkew?: Rotation;\n x?: number;\n y?: number;\n lineHeight?: number;\n maxWidth?: number;\n wordBreaks?: string[];\n}\n\nexport interface PDFPageDrawImageOptions {\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n rotate?: Rotation;\n xSkew?: Rotation;\n ySkew?: Rotation;\n opacity?: number;\n blendMode?: BlendMode;\n}\n\nexport interface PDFPageDrawPageOptions {\n x?: number;\n y?: number;\n xScale?: number;\n yScale?: number;\n width?: number;\n height?: number;\n rotate?: Rotation;\n xSkew?: Rotation;\n ySkew?: Rotation;\n opacity?: number;\n blendMode?: BlendMode;\n}\n\nexport interface PDFPageDrawSVGOptions {\n x?: number;\n y?: number;\n scale?: number;\n rotate?: Rotation;\n borderWidth?: number;\n color?: Color;\n opacity?: number;\n borderColor?: Color;\n borderOpacity?: number;\n borderDashArray?: number[];\n borderDashPhase?: number;\n borderLineCap?: LineCapStyle;\n blendMode?: BlendMode;\n}\n\nexport interface PDFPageDrawLineOptions {\n start: { x: number; y: number };\n end: { x: number; y: number };\n thickness?: number;\n color?: Color;\n opacity?: number;\n lineCap?: LineCapStyle;\n dashArray?: number[];\n dashPhase?: number;\n blendMode?: BlendMode;\n}\n\nexport interface PDFPageDrawRectangleOptions {\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n rotate?: Rotation;\n xSkew?: Rotation;\n ySkew?: Rotation;\n borderWidth?: number;\n color?: Color;\n opacity?: number;\n borderColor?: Color;\n borderOpacity?: number;\n borderDashArray?: number[];\n borderDashPhase?: number;\n borderLineCap?: LineCapStyle;\n blendMode?: BlendMode;\n}\n\nexport interface PDFPageDrawSquareOptions {\n x?: number;\n y?: number;\n size?: number;\n rotate?: Rotation;\n xSkew?: Rotation;\n ySkew?: Rotation;\n borderWidth?: number;\n color?: Color;\n opacity?: number;\n borderColor?: Color;\n borderOpacity?: number;\n borderDashArray?: number[];\n borderDashPhase?: number;\n borderLineCap?: LineCapStyle;\n blendMode?: BlendMode;\n}\n\nexport interface PDFPageDrawEllipseOptions {\n x?: number;\n y?: number;\n xScale?: number;\n yScale?: number;\n rotate?: Rotation;\n color?: Color;\n opacity?: number;\n borderColor?: Color;\n borderOpacity?: number;\n borderWidth?: number;\n borderDashArray?: number[];\n borderDashPhase?: number;\n borderLineCap?: LineCapStyle;\n blendMode?: BlendMode;\n}\n\nexport interface PDFPageDrawCircleOptions {\n x?: number;\n y?: number;\n size?: number;\n color?: Color;\n opacity?: number;\n borderColor?: Color;\n borderOpacity?: number;\n borderWidth?: number;\n borderDashArray?: number[];\n borderDashPhase?: number;\n borderLineCap?: LineCapStyle;\n blendMode?: BlendMode;\n}\n","export enum StandardFonts {\n Courier = 'Courier',\n CourierBold = 'Courier-Bold',\n CourierOblique = 'Courier-Oblique',\n CourierBoldOblique = 'Courier-BoldOblique',\n Helvetica = 'Helvetica',\n HelveticaBold = 'Helvetica-Bold',\n HelveticaOblique = 'Helvetica-Oblique',\n HelveticaBoldOblique = 'Helvetica-BoldOblique',\n TimesRoman = 'Times-Roman',\n TimesRomanBold = 'Times-Bold',\n TimesRomanItalic = 'Times-Italic',\n TimesRomanBoldItalic = 'Times-BoldItalic',\n Symbol = 'Symbol',\n ZapfDingbats = 'ZapfDingbats',\n}\n"],"names":["PDFEmbeddedFile","ref","doc","embedder","alreadyEmbedded","this","prototype","embed","embedIntoContext","context","_a","sent","catalog","has","PDFName","of","set","obj","Names","lookup","PDFDict","EmbeddedFiles","EFNames","PDFArray","push","PDFHexString","fromText","fileName","PDFDocument","ignoreEncryption","updateMetadata","_this","defaultWordBreaks","computePages","pages","Pages","traverse","node","PDFPageLeaf","page","pageMap","get","PDFPage","getOrCreateForm","acroForm","getOrCreateAcroForm","PDFForm","assertIs","PDFContext","trailerInfo","Root","isEncrypted","Encrypt","pageCache","Cache","populatedBy","Map","formCache","fonts","images","embeddedPages","embeddedFiles","javaScripts","EncryptedPDFError","updateInfoDict","load","pdf","options","_b","parseSpeed","ParseSpeeds","Slow","_c","throwOnInvalidObject","_d","_e","capNumbers","Uint8Array","ArrayBuffer","bytes","toUint8Array","PDFParser","forBytesWithOptions","parseDocument","_f","create","pageTree","PDFPageTree","withContext","pageTreeRef","register","PDFCatalog","withContextAndPages","registerFontkit","fontkit","getForm","form","access","hasXFA","deleteXFA","getTitle","title","getInfoDict","Title","assertIsLiteralOrHexString","decodeText","getAuthor","author","Author","getSubject","subject","Subject","getKeywords","keywords","Keywords","getCreator","creator","Creator","getProducer","producer","Producer","getCreationDate","creationDate","CreationDate","decodeDate","getModificationDate","modificationDate","ModDate","setTitle","key","showInWindowTitleBar","getOrCreateViewerPreferences","setDisplayDocTitle","setAuthor","setSubject","setKeywords","Array","join","setCreator","setProducer","setLanguage","language","PDFString","setCreationDate","Date","fromDate","setModificationDate","getPageCount","undefined","pageCount","getPages","length","getPage","index","assertRange","getPageIndices","range","removePage","RemovePageFromEmptyDocumentError","removeLeafNode","addPage","insertPage","isArray","dims","PageSizes","A4","setSize","apply","ForeignPageError","parentRef","insertLeafNode","setParent","invalidate","copyPages","srcDoc","indices","flush","copier","PDFObjectCopier","for","srcPages","copiedPages","idx","len","srcPage","copiedPage","copy","pdfCopy","contentPages","addJavaScript","name","script","JavaScriptEmbedder","nextRef","javaScript","PDFJavaScript","attach","attachment","assertOrUndefined","mimeType","description","assertIsOneOfOrUndefined","afRelationship","AFRelationship","FileEmbedder","embeddedFile","embedFont","font","subset","customName","features","isStandardFont","StandardFontEmbedder","canBeConvertedToUint8Array","assertFontkit","CustomFontSubsetEmbedder","CustomFontEmbedder","TypeError","pdfFont","PDFFont","embedStandardFont","embedJpg","jpg","JpegEmbedder","pdfImage","PDFImage","embedPng","png","PngEmbedder","embedPdf","pluckIndices","embedPages","embedPage","boundingBox","transformationMatrix","boundingBoxes","transformationMatrices","currPage","nextPage","PageEmbeddingMismatchedContextError","maybeCopyPage","p","box","matrix","PDFPageEmbedder","PDFEmbeddedPage","embedAll","save","useObjectStreams","addDefaultPage","objectsPerTick","updateFieldAppearances","getValue","PDFStreamWriter","PDFWriter","forContext","serializeToBuffer","saveAsBase64","dataUri","otherOptions","__rest","base64","encodeToBase64","findPageForAnnotationRef","annotations","Annots","indexOf","embeddables","pdfLib","now","info","existingInfo","Info","newInfo","FontkitNotRegisteredError","pdfObject","UnexpectedObjectTypeError","Infinity","PDFRef","width","height","scale","factor","size","modified","fontName","encodeText","text","widthOfTextAtSize","heightAtSize","descender","heightOfFontAtSize","sizeAtHeight","sizeOfFontAtHeight","getCharacterSet","encoding","supportedCodePoints","characterSet","scaleToFit","imgWidthScale","imgHeightScale","Math","min","embedTask","Javascript","JSNames","scriptName","leafNode","fontSize","fontColor","rgb","lineHeight","x","y","setRotation","angle","degreesAngle","toDegrees","assertMultiple","getRotation","Rotate","degrees","asNumber","mediaBox","getMediaBox","setMediaBox","cropBox","getCropBox","bleedBox","getBleedBox","trimBox","getTrimBox","artBox","getArtBox","hasCropBox","CropBox","hasBleedBox","BleedBox","hasTrimBox","TrimBox","hasArtBox","ArtBox","rectanglesAreEqual","setCropBox","setBleedBox","setTrimBox","setArtBox","setWidth","getSize","setHeight","MediaBox","getWidth","getHeight","asRectangle","translateContent","normalize","getContentStream","start","createContentStream","pushGraphicsState","translate","startRef","end","popGraphicsState","endRef","wrapContentStreams","scaleContent","scaleAnnotations","annots","annot","scaleAnnot","resetPosition","setFont","fontKey","newFontDictionary","setFontSize","setFontColor","Object","setLineHeight","getPosition","getX","getY","moveTo","moveDown","yDecrease","moveUp","yIncrease","moveLeft","xDecrease","moveRight","xIncrease","pushOperators","operator","_i","arguments","assertEachIs","PDFOperator","contentStream","drawText","color","assertRangeOrUndefined","opacity","rotate","xSkew","ySkew","maxWidth","wordBreaks","blendMode","BlendMode","_h","setOrEmbedFont","oldFont","newFont","newFontKey","lines","lineSplit","cleanText","breakTextIntoLines","t","encodedLines","graphicsStateKey","maybeEmbedGraphicsState","drawLinesOfText","_g","graphicsState","resetFont","drawImage","image","xObjectKey","newXObject","drawPage","embeddedPage","xScale","yScale","drawSvgPath","path","borderWidth","borderColor","borderDashArray","borderDashPhase","borderLineCap","LineCapStyle","borderOpacity","_j","drawLine","thickness","dashArray","dashPhase","lineCap","drawRectangle","_k","_l","_m","_o","drawSquare","__assign","drawEllipse","drawCircle","oldFontKey","getFont","StandardFonts","Helvetica","useExisting","contentStreamRef","addContentStream","operators","dict","PDFContentStream","Type","ca","CA","BM","newExtGState","selectors","list","scalePDFNumbers","inkLists","arr","dummyRef","pageLeaf","withContextAndParent"],"sourceRoot":""}