Skip to content

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 ​

ts
readonly doc: PDFDocument;

Defined in: src/api/PDFEmbeddedPage.ts:29

The document to which this embedded page belongs.


height ​

ts
readonly height: number;

Defined in: src/api/PDFEmbeddedPage.ts:35

The height of this page in pixels.


ref ​

ts
readonly ref: PDFRef;

Defined in: src/api/PDFEmbeddedPage.ts:26

The unique reference assigned to this embedded page within the document.


width ​

ts
readonly width: number;

Defined in: src/api/PDFEmbeddedPage.ts:32

The width of this page in pixels.

Methods ​

embed() ​

ts
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&lt;void&gt;

Resolves when the embedding is complete.

Implementation of ​

Embeddable.embed


of() ​

ts
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 ​

ParameterTypeDescription
refPDFRefThe unique reference for this embedded page.
docPDFDocumentThe document to which the embedded page will belong.
embedderPDFPageEmbedderThe embedder that will be used to embed the page.

Returns ​

PDFEmbeddedPage


scale() ​

ts
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:

js
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 ​

ParameterTypeDescription
factornumberThe factor by which this page should be scaled.

Returns ​

ts
{
  height: number;
  width: number;
}

The width and height of the page after being scaled.

height ​
ts
height: number;
width ​
ts
width: number;

size() ​

ts
size(): {
  height: number;
  width: number;
};

Defined in: src/api/PDFEmbeddedPage.ts:85

Get the width and height of this page. For example:

js
const { width, height } = embeddedPage.size()

Returns ​

ts
{
  height: number;
  width: number;
}

The width and height of the page.

height ​
ts
height: number;
width ​
ts
width: number;

MIT Licensed. A fork of pdf-lib.