pdfrx_web
    Preparing search index...

    Interface PdfPage

    A page of a document. Obtain instances via PdfDocument.pages; do not construct directly.

    A page has two identities that usually coincide but need not: where it sits in the document (pageNumber, its rotation) and which physical page of which PDF it draws (sourcePage). rotatedTo returns a proxy page that changes the effective rotation while sharing the physical page. PdfDocument.setPages similarly assigns placement and page numbers from array order, which is what makes rearrangement free.

    interface PdfPage {
        basePage: PdfPage | null;
        document: PdfDocument;
        height: number;
        id: PdfPageId;
        isLoaded: boolean;
        pageNumber: number;
        rotation: PdfPageRotation;
        sourceDocument: PdfDocument;
        sourcePageIndex: number;
        sourceRotation: PdfPageRotation;
        width: number;
        get isProxy(): boolean;
        get renderKey(): string;
        get sourceKey(): string;
        get sourcePage(): PdfPage;
        addAnnotation(
            spec: PdfAnnotationSpec,
            options?: PdfAnnotationMutationOptions,
        ): Promise<string>;
        annotationSpecToWorker(spec: PdfAnnotationSpec): WorkerAnnotationSpec;
        createCancellationToken(): PdfPageRenderCancellationToken;
        dest(options: PdfDestOptions): PdfDest;
        duplicate(): PdfPage;
        hasSameSource(other: PdfPage): boolean;
        loadAnnotations(
            options?: PdfLoadAnnotationsOptions,
        ): Promise<PdfAnnotationObject[]>;
        loadEditableLinkSpecs(): Promise<PdfLinkSpec[]>;
        loadFormFields(): Promise<PdfFormField[]>;
        loadHighlights(
            options?: PdfLoadHighlightsOptions,
        ): Promise<PdfHighlightObject[]>;
        loadLinks(
            options?: { enableAutoLinkDetection?: boolean },
        ): Promise<PdfLink[]>;
        loadText(): Promise<PdfPageRawText | null>;
        placedIn(
            document: PdfDocument,
            pageNumber: number,
            id?: PdfPageId,
        ): PdfPage;
        rebasedOn(base: PdfPage): PdfPage;
        removeAnnotation(
            id: string,
            options?: PdfAnnotationMutationOptions,
        ): Promise<boolean>;
        render(options?: PdfPageRenderOptions): Promise<PdfImage | null>;
        rotated180(): PdfPage;
        rotatedBy(delta: PdfPageRotation): PdfPage;
        rotatedCCW90(): PdfPage;
        rotatedCW90(): PdfPage;
        rotatedTo(rotation: PdfPageRotation): PdfPage;
        stageLinkAnnotations(links: readonly PdfLinkSpec[]): void;
        toAssembleSource(): PdfAssembleSource;
        toRawPagePoint(x: number, y: number): [number, number];
        toWorkerInfo(): WorkerPageInfo;
        updateAnnotation(
            id: string,
            spec: PdfAnnotationSpec,
            options?: PdfAnnotationMutationOptions,
        ): Promise<string>;
        WorkerRectToPdf(r: WorkerRect): PdfRect;
        writeLinksNow(links: readonly PdfLinkSpec[]): Promise<void>;
    }
    Index
    basePage: PdfPage | null

    The real page this one stands in for, or null if this is a real page.

    document: PdfDocument

    Document whose current arrangement contains this page.

    For an imported page this differs from sourceDocument, which owns the physical PDF page and its annotations and form widgets.

    height: number

    Page height in points (1/72 inch), at this page's rotation.

    Opaque logical-page identity. Placement and rotation proxies retain it; duplicate creates a distinct identity without copying PDF data.

    isLoaded: boolean

    False for pages not yet materialized during progressive loading.

    pageNumber: number

    1-based page number — the position in PdfDocument.pages, not in the PDF.

    rotation: PdfPageRotation

    Effective page rotation (clockwise); on a rotated proxy this differs from the rotation baked into the PDF.

    sourceDocument: PdfDocument

    The document holding the physical page this one draws.

    sourcePageIndex: number

    Reserved for internal use only. 0-based index of the physical page within sourceDocument.

    sourceRotation: PdfPageRotation

    Reserved for internal use only. Rotation baked into the PDF for the physical page.

    width: number

    Page width in points (1/72 inch), at this page's rotation.

    • get isProxy(): boolean

      Whether this page is a proxy over basePage rather than a real page.

      Returns boolean

    • get renderKey(): string

      Identity of what render draws — sourceKey plus rotation. Cache bitmaps under this and moving a page around costs nothing.

      Returns string

    • get sourceKey(): string

      Identity of the physical page, independent of where it sits in the document. Two pages with the same key produce the same text and links.

      Returns string

    • get sourcePage(): PdfPage

      The real page backing this one; this when isProxy is false.

      Returns PdfPage

    • Adds an annotation to this page and returns its id.

      The id is stored in the PDF annotation dictionary's /NM ("annotation name") entry. /NM is a PDF-standard string intended to distinguish an annotation from the other annotations on the same page; it is not the visible annotation text or the page number. The engine generates one when PdfAnnotationSpec.id is omitted. Keep the returned value to pass to updateAnnotation or removeAnnotation, or to correlate the annotation with another representation. It is preserved when the PDF is encoded and opened again.

      The physical write is sent to sourceDocument; the annotationsChanged event is emitted from the source document and every open arrangement that places that source page. Duplicate placements share annotation state and all of their page numbers are reported as affected.

      Parameters

      Returns Promise<string>

      The resulting Promise.

    • Internal

      Converts an annotation spec (bbox-relative page coords) to the wire form (raw page coords) the worker's create/replace commands expect.

      Parameters

      Returns WorkerAnnotationSpec

    • Creates a token that cancels a render that has not started yet, making it resolve to null. Use one per render call.

      Returns PdfPageRenderCancellationToken

      The resulting PdfPageRenderCancellationToken.

      const token = page.createCancellationToken();
      scrolledAway.then(() => token.cancel());
      const image = await page.render({ fullWidth, fullHeight, cancellationToken: token });
    • Creates an immutable destination for this logical page or its current 1-based position.

      An ID-based destination is ambiguous when the same page identity occurs in multiple arrangement slots. Use duplicate when destinations must distinguish repeated placements; see that method for examples and details.

      Parameters

      Returns PdfDest

      The resulting PdfDest.

    • Returns a lightweight proxy over the same physical page with a new logical identity. No PDF data is copied or materialized, so this operation is effectively free. The returned page still renders the same physical page; only placement identity is separated.

      This matters when one PdfPage is placed more than once. Reusing the same object also reuses its opaque id, so an ID-based dest can identify the page but not a particular occurrence:

      const [page, ...rest] = document.pages;
      document.setPages([page!, ...rest, page!]);

      const ambiguous = page!.dest({
      by: 'id',
      command: 'fit',
      params: [],
      });
      // Both placements have the same ID. Following `ambiguous` selects one
      // matching placement; callers must not rely on which one is selected.

      Call duplicate() before arranging the second occurrence when destinations must distinguish them:

      const [page, ...rest] = document.pages;
      const secondPlacement = page!.duplicate();
      document.setPages([page!, ...rest, secondPlacement]);

      const firstDest = page!.dest({
      by: 'id',
      command: 'fit',
      params: [],
      });
      const secondDest = secondPlacement.dest({
      by: 'id',
      command: 'fit',
      params: [],
      });

      The two destinations now follow separate placements, while both pages continue to use the same underlying PDF page data.

      Returns PdfPage

      The resulting PdfPage.

    • Whether other draws the same physical page of the same PDF, regardless of page number or rotation. Useful for keying caches by content.

      Parameters

      • other: PdfPage

        The other value (PdfPage).

      Returns boolean

      Whether the condition is satisfied.

    • Loads the editable annotations on this page (including Link annotations, but not widgets/popups), with rects and geometry in bounding-box-relative page coordinates (like loadLinks). Returns an empty array if the document is disposed or the page is not yet loaded.

      Parameters

      Returns Promise<PdfAnnotationObject[]>

      The resolved Promise.

    • Internal

      Returns the complete writable Link-annotation list for CRUD.

      Returns Promise<PdfLinkSpec[]>

    • Loads the AcroForm fields whose widgets sit on this page, grouped by fully-qualified name. Rects are in PDF page coordinates (bounding-box relative, like loadLinks). Returns an empty array if the document is disposed, has no form, or the page is not yet loaded.

      Returns Promise<PdfFormField[]>

      The resolved Promise.

    • Loads link annotations on the page and, when enableAutoLinkDetection is true (the default), URL-like text detected in the page content. Pending annotation-CRUD changes are returned instead of physical Link annotations while retaining transient detected URLs.

      Parameters

      • Optionaloptions: { enableAutoLinkDetection?: boolean }

        Options that customize the operation.

      Returns Promise<PdfLink[]>

      The resolved Promise.

    • Loads the full text of the page with one bounding rect per UTF-16 code unit (in page coordinates). Returns null if the document is disposed or the page is not yet loaded (progressive loading).

      Returns Promise<PdfPageRawText | null>

      The resolved Promise.

    • Internal

      Reserved for internal use only. Re-points this page at a freshly loaded base (same physical page, new metadata) while keeping any proxy overrides.

      Parameters

      Returns PdfPage

    • Removes the annotation identified by id; returns whether it was found.

      Parameters

      • id: string

        The PdfAnnotationObject.id returned by loadAnnotations, or the id returned by addAnnotation. This is normally the annotation dictionary's stable /NM ("annotation name") value, a PDF-standard string used to distinguish annotations on the page. For an existing annotation without /NM, loadAnnotations() returns a page-local @<index> fallback instead. Such a fallback is positional, so use it before any other annotation is added, removed, or replaced on this page; otherwise load the annotations again and use the new id.

      • Optionaloptions: PdfAnnotationMutationOptions

        Options that customize the operation.

      Returns Promise<boolean>

      The resulting Promise.

    • Renders (a part of) the page to a PdfImage of RGBA8888 pixels (Canvas/WebGL-ready; the worker converts from the engine's native BGRA).

      The page is scaled to fullWidth x fullHeight (defaulting to the page size in points, i.e. 72 dpi) and the x/y/width/height sub-region of that scaled page is returned. Use PdfImage.toImageData / PdfImage.toImageBitmap to draw the result. Returns null if the document is already disposed, or if PdfPageRenderOptions.cancellationToken was cancelled.

      Renders are queued (one in the worker at a time by default) rather than all posted at once, so a render that is no longer wanted can be dropped before it starts — see createCancellationToken.

      Parameters

      Returns Promise<PdfImage | null>

      The rendered Promise.

    • Creates a page-placement proxy rotated 180 degrees relative to this page.

      Calling this method does not change PdfDocument.pages. Apply the result with PdfDocument.setPage or PdfDocument.setPages.

      Returns PdfPage

      The resulting PdfPage.

      const pages = doc.pages.map((page, index) =>
      index === 0 || index === 2 ? page.rotated180() : page,
      );
      doc.setPages(pages);
    • Creates a page-placement proxy rotated clockwise by delta relative to its current rotation property.

      This does not modify the document by itself. Apply the returned proxy with PdfDocument.setPage or PdfDocument.setPages; use PdfDocument.encodePdf or PdfDocument.materialize only when the in-memory arrangement must be written into the physical PDF.

      Parameters

      Returns PdfPage

      The resulting PdfPage.

      doc.setPage(1, doc.pages[0]!.rotatedBy(90));
      
    • Creates a page-placement proxy rotated 90 degrees counter-clockwise relative to this page.

      Calling this method does not change PdfDocument.pages. Apply the result with PdfDocument.setPage or PdfDocument.setPages.

      Returns PdfPage

      The resulting PdfPage.

      doc.setPage(1, doc.pages[0]!.rotatedCCW90());
      
    • Creates a page-placement proxy rotated 90 degrees clockwise relative to this page.

      Calling this method does not change PdfDocument.pages. Apply the result with PdfDocument.setPage or PdfDocument.setPages.

      Returns PdfPage

      The resulting PdfPage.

      doc.setPage(1, doc.pages[0]!.rotatedCW90());
      
    • Creates a page-placement proxy with the requested absolute rotation.

      Calling this method alone does not modify the PDF or PdfDocument.pages. Pass the returned page to PdfDocument.setPage to replace one placement, or include it in the array passed to PdfDocument.setPages. Those methods update the in-memory arrangement synchronously; PdfDocument.encodePdf or PdfDocument.materialize later writes the arrangement into the physical PDF.

      rotation is clockwise and absolute: 90 means the page is displayed at 90 degrees regardless of the page's current rotation property. If it already has the requested rotation, this method returns this.

      Parameters

      • rotation: PdfPageRotation

        The clockwise page rotation, in 90-degree steps.

      Returns PdfPage

      The resulting PdfPage.

      const page = doc.pages[2]!;
      doc.setPage(3, page.rotatedTo(90));
    • Internal

      Stages the complete Link list used by ordinary annotation CRUD.

      Parameters

      • links: readonly PdfLinkSpec[]

      Returns void

    • Internal

      Reserved for internal use only. This page as a source slot for PdfDocument.materialize.

      Returns PdfAssembleSource

    • Internal

      Reserved for internal use only. Converts a bounding-box-relative page point (as used by PdfFormField.rects / loadLinks) back to raw PDF page coordinates, which the form-fill FORM_On* input APIs expect.

      Parameters

      • x: number
      • y: number

      Returns [number, number]

    • Internal

      Returns WorkerPageInfo

    • Replaces annotation id with a fresh annotation built from the complete spec, preserving the id. PDFium has no in-place geometry setter.

      Parameters

      • id: string

        The PdfAnnotationObject.id returned by loadAnnotations, or the id returned by addAnnotation. This is normally the annotation dictionary's /NM ("annotation name") value: a PDF-standard string used to distinguish annotations on the page. Existing PDFs whose annotation has no /NM use a page-local @<index> fallback; use that fallback only with the unchanged result from the most recent loadAnnotations() call because page mutations can change the index.

      • spec: PdfAnnotationSpec

        The spec value (PdfAnnotationSpec).

      • Optionaloptions: PdfAnnotationMutationOptions

        Options that customize the operation.

      Returns Promise<string>

      The resulting Promise.

    • Internal

      Reserved for internal use only. Converts a wire rect to a bounding-box-relative PdfRect; used by the form invalidate relay.

      Parameters

      • r: WorkerRect

      Returns PdfRect

    • Internal

      Writes staged Link annotations to the physical page represented by this page.

      Parameters

      • links: readonly PdfLinkSpec[]

      Returns Promise<void>