toeverything/AFFiNE · error · Error
PdfAdapter does not support importing docs from PDF.
Error message
PdfAdapter does not support importing docs from PDF.
What it means
PdfAdapter implements only export (doc-to-PDF); toDocSnapshot is an intentionally unimplemented adapter method that throws because importing a BlockSuite doc from a PDF file is not supported. It fires whenever a caller routes a ToDocSnapshotPayload<PdfAdapterFile> into this adapter.
Source
Thrown at blocksuite/affine/shared/src/adapters/pdf/pdf.ts:150
const definition = this._createDocDefinition(undefined, content);
const blob = await this._createPdfBlob(definition);
return {
file: {
blob,
fileName: 'slice.pdf',
},
assetsIds: [],
};
}
toBlockSnapshot(
_payload: ToBlockSnapshotPayload<PdfAdapterFile>
): BlockSnapshot {
throw new Error('PdfAdapter does not support importing blocks from PDF.');
}
toDocSnapshot(_payload: ToDocSnapshotPayload<PdfAdapterFile>): DocSnapshot {
throw new Error('PdfAdapter does not support importing docs from PDF.');
}
toSliceSnapshot(
_payload: ToSliceSnapshotPayload<PdfAdapterFile>
): SliceSnapshot | null {
throw new Error('PdfAdapter does not support importing slices from PDF.');
}
/**
* Get the pdfmake document definition (for testing purposes)
*/
async getDocDefinition(
blocks: BlockSnapshot[],
title?: string,
assets?: FromDocSnapshotPayload['assets']
): Promise<TDocumentDefinitions> {
const content = await this._buildContent(blocks, assets);
return this._createDocDefinition(title, content);View on GitHub (pinned to b4c8548c09)
Solutions
- PdfAdapter only supports exporting docs to PDF. To import, convert the PDF to Markdown/HTML with an external tool first, then use the MarkdownAdapter or NotionHtmlAdapter.
- Surface a clear UI message that PDF import is unsupported and offer PDF export instead.
Example fix
// Only export docs to PDF:
const pdfBuffer = await pdfAdapter.fromDocSnapshot({ snapshot, assets });
// Do not call pdfAdapter.toDocSnapshot — PDF import is not implemented. Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at blocksuite/affine/shared/src/adapters/pdf/pdf.ts:150 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/326c4ceade950d14.
Report an issue: GitHub.