toeverything/AFFiNE · error · Error
PdfAdapter does not support importing blocks from PDF.
Error message
PdfAdapter does not support importing blocks from PDF.
What it means
Guard clause: PdfAdapter is export-only. toBlockSnapshot unconditionally throws because converting a PDF file back into an AFFiNE block snapshot is not implemented; any call to import PDF data as blocks fails by design.
Source
Thrown at blocksuite/affine/shared/src/adapters/pdf/pdf.ts:146
}: FromSliceSnapshotPayload): Promise<
FromSliceSnapshotResult<PdfAdapterFile>
> {
const content = await this._buildContent(snapshot.content, assets);
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,View on GitHub (pinned to b4c8548c09)
Solutions
- PDF import is not supported by PdfAdapter; extract the text/images from the PDF first (e.g. with pdf.js) and import the extracted content via the Markdown or HTML adapter.
- Check the adapter's supported import direction before calling fromBlockSnapshot; wrap the call in a capability check and show an 'import not supported' message to the user.
Example fix
// Guard before attempting a PDF-to-blocks import:
if (!pdfAdapter.fromBlockSnapshot) {
notify('Importing blocks from PDF is not supported');
return;
} Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at blocksuite/affine/shared/src/adapters/pdf/pdf.ts:146 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/2f99b179c8fa5831.
Report an issue: GitHub.