# Public API reference

Find public entry points and their source-derived signatures for sessions, templates, HTTP and printing.

Signatures below come from the public package exports. Mount the workspace in the browser. Template, HTTP and print subpaths are also available to backend integrations. [Mounting example](/en/integration/embed) · [Workstation HTTP](/en/integration/http)

## Browser workspace

### Editor

`@quirekit/ofd-editor` · Commercial

Commercial OFD workspace with its own browser session and view lifecycle.

```ts
export class Editor {
    constructor(options?: OFDEditorOptions);
    mount(target: string | Element): this;
    destroy(): void;
}
```

### OFDMountedEditorSession

`@quirekit/ofd-editor` · Commercial

File operations attached to the particular editor currently observed by the host.

```ts
export interface OFDMountedEditorSession extends OFDEditorSession {
    getBusinessDraft(): import("./drafts/types").OFDDraftEntry | undefined;
    openBusinessDraft(id: string): Promise<"opened" | "pending" | "failed">;
    saveBusinessDraft(id?: string): Promise<boolean>;
    readonly templateStore: import("./templates/types").OFDTemplateStore;
    getEditingTemplate(): import("./templates/types").OFDTemplateEntry | undefined;
    openTemplate(entry: import("./templates/types").OFDTemplateEntry, mode: "new-document" | "edit-template"): Promise<"opened" | "pending" | "failed">;
    saveAsTemplate(name: string): Promise<import("./templates/types").OFDTemplateEntry>;
    updateTemplate(): Promise<boolean>;
    printDocument(): import("./printing/types").OFDPrintDocument;
}
```

**getBusinessDraft** — @returns Last confirmed business document identity for this session.

**openBusinessDraft** — @param id - Host business document ID.
@returns Result of the guarded document switch.

**saveBusinessDraft** — @param id - Stable ID to register on first save, or the current destination.
@returns Whether the host confirmed the save.

**templateStore** — The currently configured writable library.

**getEditingTemplate** — @returns Master edition when editing a template, or undefined for an independent file.

**openTemplate** — @param entry - Exact edition from templateStore.
@param mode - Create a document or update the master in place.
@returns Whether the editor opened the edition, deferred it for unsaved changes or could not open it.

**saveAsTemplate** — @param name - Name of the independent master.
@returns Its committed catalog entry.

**updateTemplate** — @returns Whether the currently edited edition was successfully updated.

**printDocument** — @returns The current document's native print input after committing active text and form values.

**editor** — Canonical command and save authority.

**view** — Mounted view of the same document.

## Templates and fill services

### instantiateOFDTemplate

`@quirekit/ofd-editor/templates` · Commercial

Creates a separate native document, leaving the stored master and its object/resource references intact.
@param bytes - Editable master OFD package.
@param prepare - Optional domain initialization after assigning file identities.
@param reference - Registered source edition persisted for shared field mappings.
@returns Independent package, with a fresh DocID for each document body.

```ts
function instantiateOFDTemplate(bytes: Uint8Array, prepare?: (source: OFDSourceDocument) => OFDSourceDocument, reference?: OFDTemplateReference): Uint8Array
```

### describeOFDTemplateFields

`@quirekit/ofd-editor/http` · Commercial

@param source - Versioned native master.
@returns Portable controls and a value-free request example.

```ts
function describeOFDTemplateFields(source: OFDSourceDocument): { schema: { $schema: string; title: string; type: string; required: string[]; additionalProperties: boolean; properties: { version: { const: number; }; context: { type: string; additionalProperties: boolean; required: string[]; properties: { patientId: { type: string; minLength: number; maxLength: number; pattern: string; }; encounterId: { type: string; minLength: number; maxLength: number; pattern: string; }; }; }; values: { type: string; additionalProperties: boolean; properties: { [k: string]: { title: string; type: string; }; }; }; repeats: { type: string; additionalProperties: boolean; properties: { [k: string]: { title: string; type: string; minItems: number; maxItems: number; items: { type: string; additionalProperties: boolean; properties: { [k: string]: { title: string; type: string; }; }; }; }; }; }; rowKeys: { type: string; additionalProperties: boolean; properties: { [k: string]: { readonly enum: string[]; }; }; }; assets: { type: string; maxProperties: number; patternProperties: { "^[1-9][0-9]{0,9}$": { type: string; contentEncoding: string; }; }; additionalProperties: boolean; }; corrections: { type: string; maxItems: number; items: boolean | { oneOf: object[]; }; }; approved: { type: string; maxItems: number; items: { type: string; pattern: string; }; }; }; }; example: import("@quirekit/ofd-editor-core/forms").OFDFormFillData; documentType?: string | undefined; standard?: string | undefined; fields: { codeSystem?: string | undefined; element?: string | undefined; required?: boolean; key: string; label: string; kind: import("@quirekit/ofd-editor-core/forms").OFDFormControlKind; multiline?: boolean; maxLength?: number; preset?: import("@quirekit/ofd-editor-core/forms").OFDFormPreset; format?: string; options?: readonly import("@quirekit/ofd-editor-core/forms").OFDFormOption[]; }[]; groups: { fields: { codeSystem?: string | undefined; element?: string | undefined; required?: boolean; key: string; label: string; kind: import("@quirekit/ofd-editor-core/forms").OFDFormControlKind; multiline?: boolean; maxLength?: number; preset?: import("@quirekit/ofd-editor-core/forms").OFDFormPreset; format?: string; options?: readonly import("@quirekit/ofd-editor-core/forms").OFDFormOption[]; }[]; required?: boolean | undefined; key: string; label: string; capacity: number; }[]; }
```

### fillOFDTemplate

`@quirekit/ofd-editor/http` · Commercial

Fills a new editable file without opening a window or changing the source template.
@param master - Immutable bytes from an authorized versioned store.
@param input - Portable fill record or a previous snapshot.
@param fallbackFont - Complete font to cover new characters absent from an embedded subset.
@param reference - Exact source edition to retain on the generated document.
@returns Independent native document and any outstanding completion checks.

```ts
function fillOFDTemplate(master: Uint8Array, input: unknown, fallbackFont?: OFDFlowEmbeddedFont, reference?: import("../../templates/types").OFDTemplateReference): { document: OFDSourceDocument; issues: readonly import("@quirekit/ofd-editor-core/forms").OFDFormInputIssue[]; accepted: number; changed: boolean; conflicts: import("@quirekit/ofd-editor-core/forms").OFDFormFillChange[]; }
```

### handleOFDHttpRequest

`@quirekit/ofd-editor/http` · Commercial

Handles one request with services already scoped to the calling tenant, including print receipt access.
@param request - Web-standard request, including the current user's abort signal.
@param services - Authorized stores for this request.
@param mount - Absolute path prefix configured by the host.
@returns JSON metadata, OFD bytes, or an HTTP error.

```ts
function handleOFDHttpRequest(request: Request, services: OFDHttpServices, mount?: string): Promise<Response>
```

## Print service

### parseOFDPrintRange

`@quirekit/ofd-editor/print` · Commercial

@param text - One-based page ranges, for example 1,3-5.
@param count - Source page count.
@returns Unique physical page numbers in source order.

```ts
function parseOFDPrintRange(text: string, count: number): number[]
```

### OFDPrintService

`@quirekit/ofd-editor/print` · Commercial

Host integration for a native print queue or authenticated backend.

```ts
export interface OFDPrintService {
    readonly label: string;
    submit(job: OFDPrintJob, signal: AbortSignal): Promise<OFDPrintReceipt>;
    status?(jobId: string, signal: AbortSignal): Promise<OFDPrintJobStatus>;
}
```

**label** — Destination visible in the print dialog.

**submit** — @param job - Ordered native files and print settings.
@param signal - Request lifetime.
@returns Receipt once the spooler accepts the job. The service must recheck permissions at submission.

**status** — @param jobId - Receipt from this queue.
@param signal - Query lifetime.
@returns Latest spooler state.
