{"record":{"id":"2f99b179c8fa5831","repo":"toeverything/AFFiNE","slug":"pdfadapter-does-not-support-importing-blocks-from","errorCode":null,"errorMessage":"PdfAdapter does not support importing blocks from PDF.","messagePattern":"PdfAdapter does not support importing blocks from PDF\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"blocksuite/affine/shared/src/adapters/pdf/pdf.ts","lineNumber":146,"sourceCode":"  }: FromSliceSnapshotPayload): Promise<\n    FromSliceSnapshotResult<PdfAdapterFile>\n  > {\n    const content = await this._buildContent(snapshot.content, assets);\n    const definition = this._createDocDefinition(undefined, content);\n    const blob = await this._createPdfBlob(definition);\n    return {\n      file: {\n        blob,\n        fileName: 'slice.pdf',\n      },\n      assetsIds: [],\n    };\n  }\n\n  toBlockSnapshot(\n    _payload: ToBlockSnapshotPayload<PdfAdapterFile>\n  ): BlockSnapshot {\n    throw new Error('PdfAdapter does not support importing blocks from PDF.');\n  }\n\n  toDocSnapshot(_payload: ToDocSnapshotPayload<PdfAdapterFile>): DocSnapshot {\n    throw new Error('PdfAdapter does not support importing docs from PDF.');\n  }\n\n  toSliceSnapshot(\n    _payload: ToSliceSnapshotPayload<PdfAdapterFile>\n  ): SliceSnapshot | null {\n    throw new Error('PdfAdapter does not support importing slices from PDF.');\n  }\n\n  /**\n   * Get the pdfmake document definition (for testing purposes)\n   */\n  async getDocDefinition(\n    blocks: BlockSnapshot[],\n    title?: string,","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/blocksuite/affine/shared/src/adapters/pdf/pdf.ts#L128-L164","documentation":"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.","triggerScenarios":"Thrown at blocksuite/affine/shared/src/adapters/pdf/pdf.ts:146 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":"// Guard before attempting a PDF-to-blocks import:\nif (!pdfAdapter.fromBlockSnapshot) {\n  notify('Importing blocks from PDF is not supported');\n  return;\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}