Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/skia_canvas/src/pdfdocument.ts>PdfDocument

Fast HTML Canvas API implementation for Deno using Google Skia
Latest
class PdfDocument
import { PdfDocument } from "https://deno.land/x/skia_canvas@0.5.8/src/pdfdocument.ts";

Create a new PDF document to draw using Canvas 2D API.

Constructors

new
PdfDocument(options?: PdfMetadata)

Methods

encode(): Uint8Array

Encodes the PDF into a buffer and closes the stream. Changes cannot be made to PDF after this.

Writes the page into internal stream and destroys

newPage(
w: number,
h: number,
contentRect?: Rect,
): PdfRenderingContext2D

Creates a new page and returns a 2D rendering context for drawing on it. The context extends CanvasRenderingContext2D so it has same API.

You must not use the context after calling endPage.

save(path: string)

Saves PDF to the file and closes the stream. Changes cannot be made to PDF after this.