{"record":{"id":"326c4ceade950d14","repo":"toeverything/AFFiNE","slug":"pdfadapter-does-not-support-importing-docs-from-pd","errorCode":null,"errorMessage":"PdfAdapter does not support importing docs from PDF.","messagePattern":"PdfAdapter does not support importing docs from PDF\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"blocksuite/affine/shared/src/adapters/pdf/pdf.ts","lineNumber":150,"sourceCode":"    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,\n    assets?: FromDocSnapshotPayload['assets']\n  ): Promise<TDocumentDefinitions> {\n    const content = await this._buildContent(blocks, assets);\n    return this._createDocDefinition(title, content);","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/blocksuite/affine/shared/src/adapters/pdf/pdf.ts#L132-L168","documentation":"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.","triggerScenarios":"Thrown at blocksuite/affine/shared/src/adapters/pdf/pdf.ts:150 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":"// Only export docs to PDF:\nconst pdfBuffer = await pdfAdapter.fromDocSnapshot({ snapshot, assets });\n// Do not call pdfAdapter.toDocSnapshot — PDF import is not implemented.","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"}