PDFEmbeddedPage
Represents a PDF page that has been embedded in a PDFDocument.
Hierarchy
- PDFEmbeddedPage
Implements
Index
Properties
Methods
Properties
doc
• doc: PDFDocument
Defined in api/PDFEmbeddedPage.ts:29
The document to which this embedded page belongs.
height
• height: number
Defined in api/PDFEmbeddedPage.ts:35
The height of this page in pixels.
ref
• ref: PDFRef
Defined in api/PDFEmbeddedPage.ts:26
The unique reference assigned to this embedded page within the document.
width
• width: number
Defined in api/PDFEmbeddedPage.ts:32
The width of this page in pixels.
Methods
embed
▸ embed(): Promise‹void›
Defined in api/PDFEmbeddedPage.ts:98
NOTE: You probably don't need to call this method directly. The PDFDocument.save and PDFDocument.saveAsBase64 methods will automatically ensure all embeddable pages get embedded.
Embed this embeddable page in its document.
Returns: Promise‹void›
Resolves when the embedding is complete.
scale
▸ scale(factor
: number): object
Defined in api/PDFEmbeddedPage.ts:73
Compute the width and height of this page after being scaled by the
given factor
. For example:
embeddedPage.width // => 500
embeddedPage.height // => 250
const scaled = embeddedPage.scale(0.5)
scaled.width // => 250
scaled.height // => 125
This operation is often useful before drawing a page with
PDFPage.drawPage to compute the width
and height
options.
Parameters:
Name | Type | Description |
---|---|---|
factor | number | The factor by which this page should be scaled. |
Returns: object
The width and height of the page after being scaled.
height: number = this.height * factor
width: number = this.width * factor
size
▸ size(): object
Defined in api/PDFEmbeddedPage.ts:85
Get the width and height of this page. For example:
const { width, height } = embeddedPage.size()
Returns: object
The width and height of the page.
height: number = this.height * factor
width: number = this.width * factor
Static
of
▸ of(ref
: PDFRef, doc
: PDFDocument, embedder
: PDFPageEmbedder): PDFEmbeddedPage‹›
Defined in api/PDFEmbeddedPage.ts:22
NOTE: You probably don't want to call this method directly. Instead, consider using the PDFDocument.embedPdf and PDFDocument.embedPage methods, which will create instances of PDFEmbeddedPage for you.
Create an instance of PDFEmbeddedPage from an existing ref and embedder
Parameters:
Name | Type | Description |
---|---|---|
ref | PDFRef | The unique reference for this embedded page. |
doc | PDFDocument | The document to which the embedded page will belong. |
embedder | PDFPageEmbedder | The embedder that will be used to embed the page. |
Returns: PDFEmbeddedPage‹›