@pptx-editor.dev/pptx-to-pdf

v0.3.1 · 1 published subpath with full TypeScript signatures and JSDoc.

Package root

@pptx-editor.dev/pptx-to-pdf: PPTX to PDF on Node.js through the PPTX Editor engine.

The names follow DOCX Editor's @docx-editor.dev/docx-to-pdf where the concept is the same.

Functions (3)

exportPdffunctionSource ↗

Convert PPTX bytes to a PDF, one page per slide, on Node.js. Disposes its session after success or failure.

The default fidelityPolicy is strict: if a slide has content the PDF cannot reproduce, the conversion throws PdfFidelityError with every diagnostic. Pass fidelityPolicy: 'best-effort' to get the PDF and read diagnostics instead.

declare function exportPdf(source: Uint8Array, options?: PdfExportOptions): Promise<PdfExportResult>;

exportPdfFromfunctionSource ↗

Encode a caller-owned session from openDocumentForExport without reopening the deck. Each slide is laid out once per session, so a second export reuses the layout. Does not dispose the session: the caller disposes it after all exports. Cancellation stops this export only; the session's own signal controls the session.

declare function exportPdfFrom(session: PdfExportSession, options?: PdfProjectionOptions): Promise<PdfExportResult>;

openDocumentForExportfunctionSource ↗

Open a reusable PDF session over immutable PPTX bytes. Pass the session to exportPdfFrom as many times as you need: each slide is laid out once. The caller must dispose the session. Its signal controls the entire session lifetime.

declare function openDocumentForExport(source: Uint8Array, options?: OpenPdfDocumentForExportOptions): Promise<OpenPdfDocumentForExportResult>;

Classes (7)

ExportResourceErrorclassSource ↗

A caller-owned export session cannot serve an export: it was disposed, or the signal given to openDocumentForExport aborted (which also disposes it). For aborted, cause is the signal's reason. DOCX Editor throws the same name from its Core.

declare class ExportResourceError extends Error
MemberTypeSummary
(constructor)Constructs a new instance of the `ExportResourceError` class
code'disposed' | 'aborted'Stable error code: the session was disposed, or its signal aborted.

PdfDocumentOpenErrorclassSource ↗

Core refused the input package.

declare class PdfDocumentOpenError extends Error
MemberTypeSummary
(constructor)Constructs a new instance of the `PdfDocumentOpenError` class
codeStable error code.
detail?stringMore detail, when core gives it.
reasonOpenError['reason']Why core refused the package, as `openPresentation` reports it.

PdfEncodingErrorclassSource ↗

PDF encoding failed after a document was opened.

declare class PdfEncodingError extends Error
MemberTypeSummary
(constructor)Constructs a new instance of the `PdfEncodingError` class
code'encodingFailed' | 'outputTooLarge'Stable error code: `outputTooLarge` on the [PdfOutputLimitError](PdfOutputLimitError) subclass.

PdfFidelityErrorclassSource ↗

Requested content could not be represented faithfully.

declare class PdfFidelityError extends Error
MemberTypeSummary
(constructor)Constructs a new instance of the `PdfFidelityError` class
codeStable error code.
diagnosticsreadonly PdfDiagnostic[]Every diagnostic of the conversion; the blocking ones name the slide and feature.

PdfOutputLimitErrorclassSource ↗

Encoded output exceeds the configured byte limit.

declare class PdfOutputLimitError extends PdfEncodingError
MemberTypeSummary
(constructor)Constructs a new instance of the `PdfOutputLimitError` class
actualnumberThe encoded size in bytes.
codeStable error code.
limitnumberThe `maxOutputBytes` option.

PdfPageLimitErrorclassSource ↗

The deck exceeds the configured page limit.

declare class PdfPageLimitError extends RangeError
MemberTypeSummary
(constructor)Constructs a new instance of the `PdfPageLimitError` class
actualnumberThe number of pages the deck would export.
codeStable error code.
limitnumberThe `maxPages` option.

PdfWorkLimitErrorclassSource ↗

The conversion passed its deadline, was cancelled, or ran past its paint budget. For aborted, cause is the signal's reason.

declare class PdfWorkLimitError extends Error
MemberTypeSummary
(constructor)Constructs a new instance of the `PdfWorkLimitError` class
code'timeout' | 'aborted' | 'operations'Stable error code: past `timeoutMs`, cancelled through `signal`, or past the paint budget (paint operations or PDF content bytes).

Interfaces (6)

PdfDiagnosticinterfaceSource ↗

A bounded explanation of content the PDF cannot reproduce.

interface PdfDiagnostic
MemberTypeSummary
codestringMachine-readable diagnostic identifier, from a fixed set. Handle unknown codes by severity.
messagestringHuman-readable explanation. Do not use this text for program control.
pageIndex?numberZero-based PDF page index. Omitted when the slide produced no page.
pageNumber?numberOne-based PDF page number for display.
severity'unsupported' | 'approximation' | 'information'Strict export permits only information diagnostics.
slideIndex?numberZero-based slide index in the deck, hidden slides included. Omitted for document-wide diagnostics.
slideNumber?numberOne-based slide number in the deck, hidden slides included.

PdfExportOptionsinterfaceSource ↗

Node conversion controls.

interface PdfExportOptions
MemberTypeSummary
fidelityPolicy?'strict' | 'best-effort'Reject unsupported or approximate content. Defaults to `strict`.
fonts?PdfFontsSourceFont faces tried before embedded and substitute fonts.
includeHiddenSlides?booleanInclude slides marked hidden (`p:sld/@show="0"`). Defaults to false.
maxOutputBytes?numberMaximum encoded bytes, from 1 to 67108864. Defaults to 67108864.
maxPages?numberMaximum output pages, from 1 to 10000. Defaults to 10000.
signal?AbortSignalCancels the conversion. Its `reason` is the `cause` of the thrown `PdfWorkLimitError`.
substitutes?booleanLoad the metric-compatible substitutes from `@docx-editor.dev/fonts`. Defaults to true. DOCX Editor configures this through its font sources instead.
timeoutMs?numberCooperative conversion deadline. Defaults to 60000 milliseconds.

PdfExportResultinterfaceSource ↗

Result owns its bytes.

interface PdfExportResult
MemberTypeSummary
bytesUint8ArrayOwned, mutable PDF bytes. Use application/pdf when serving them.
diagnosticsreadonly PdfDiagnostic[]Immutable output limitations and informational notices.
fontResolutionPdfFontResolutionSelected faces and substitutions.
pageCountnumberPhysical PDF page count: one page per exported slide.
slideNumbersreadonly number[]The one-based deck slide number of each page, in page order. Hidden slides (unless `includeHiddenSlides` is true) and slides that could not be laid out have no page, so page `i` shows slide `slideNumbers[i]`.
timingsPdfExportTimingsWall-clock milliseconds spent opening, laying out, painting, and saving.

PdfExportSessioninterfaceSource ↗

An open deck with its fonts and slide layouts, for exportPdfFrom. Each slide is laid out once and reused by every export. The caller owns the session and must call dispose().

interface PdfExportSession
MemberTypeSummary
disposeRelease the session. Later exports reject with `ExportResourceError` (`disposed`).
fontResolutionPdfFontResolutionThe faces the session measures with, and the families it substituted.

PdfExportTimingsinterfaceSource ↗

Elapsed milliseconds for each conversion phase.

interface PdfExportTimings
MemberTypeSummary
layoutMsnumberLaying out every exported slide.
openMsnumberReading and opening the deck.
paintMsnumberPainting every page into the PDF.
saveMsnumberEncoding the PDF bytes.

PdfFontResolutioninterfaceSource ↗

The faces the conversion drew with, and the families it substituted.

interface PdfFontResolution
MemberTypeSummary
facesreadonly { readonly family: string; readonly origin: string; }[]Each face drawn with: its family, and its origin (for example `embedded`, `provided`, or `substitute`).
refusedEmbeddedreadonly string[]Embedded faces the deck carries that may not be used, with the reason.
substituteFailuresreadonly SubstituteFontFailure[]Packaged substitute faces that failed to load, each with its family, file, and reason.
substitutionsreadonly FontSubstitution[]Families the deck asked for that no face covered, with the family used instead.

Type aliases (4)

OpenPdfDocumentForExportOptionstypeSource ↗

Font controls for a reusable session over immutable PPTX bytes.

type OpenPdfDocumentForExportOptions = Omit<PdfExportOptions, 'fidelityPolicy' | 'includeHiddenSlides' | 'timeoutMs' | 'maxOutputBytes' | 'maxPages' | 'signal'> & {
    readonly signal?: AbortSignal;
};

OpenPdfDocumentForExportResulttypeSource ↗

Open result, with DOCX Editor's success and refusal shape.

type OpenPdfDocumentForExportResult = {
    readonly ok: true;
    readonly session: PdfExportSession;
} | {
    readonly ok: false;
    readonly reason: OpenError['reason'] | 'aborted';
    readonly detail?: string;
};

PdfFontsSourcetypeSource ↗

One font face or several. Earlier faces win.

type PdfFontsSource = FontSource | readonly FontSource[];

PdfProjectionOptionstypeSource ↗

Output controls for a caller-owned PDF session.

type PdfProjectionOptions = Pick<PdfExportOptions, 'fidelityPolicy' | 'includeHiddenSlides' | 'timeoutMs' | 'maxOutputBytes' | 'maxPages' | 'signal'>;