happypdf / PDFEmbeddedPage
Class: PDFEmbeddedPage
Defined in: src/api/PDFEmbeddedPage.ts:9
Represents a PDF page that has been embedded in a [[PDFDocument]].
Implements
Properties
doc
readonly doc: PDFDocument;Defined in: src/api/PDFEmbeddedPage.ts:29
The document to which this embedded page belongs.
height
readonly height: number;Defined in: src/api/PDFEmbeddedPage.ts:35
The height of this page in pixels.
ref
readonly ref: PDFRef;Defined in: src/api/PDFEmbeddedPage.ts:26
The unique reference assigned to this embedded page within the document.
width
readonly width: number;Defined in: src/api/PDFEmbeddedPage.ts:32
The width of this page in pixels.
Methods
embed()
embed(): Promise<void>;Defined in: src/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.
Implementation of
of()
static of(
ref,
doc,
embedder): PDFEmbeddedPage;Defined in: src/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
| Parameter | 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
scale()
scale(factor): {
height: number;
width: number;
};Defined in: src/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 // => 125This operation is often useful before drawing a page with [[PDFPage.drawPage]] to compute the width and height options.
Parameters
| Parameter | Type | Description |
|---|---|---|
factor | number | The factor by which this page should be scaled. |
Returns
{
height: number;
width: number;
}The width and height of the page after being scaled.
height
height: number;width
width: number;size()
size(): {
height: number;
width: number;
};Defined in: src/api/PDFEmbeddedPage.ts:85
Get the width and height of this page. For example:
const { width, height } = embeddedPage.size()Returns
{
height: number;
width: number;
}The width and height of the page.
height
height: number;width
width: number;