Skip to content

DOCXKIT_PREVIEW_RENDER_FAILED: 预览渲染失败 ​

本地 docx-preview 渲染器未能处理此文档。

修复步骤 ​

  1. 确认输入是有效的 DOCX ZIP 归档。
  2. 检查渲染器原始 cause,并尝试用 Word 打开同一文件。

问题示例 ​

ts
import { createDocx, createDocxPreview } from 'docx-kit'

const container = document.createElement('div')
document.body.append(container)

const preview = createDocxPreview(container)
try {
  await preview.render(new Blob(['plain text']))
} finally { preview.destroy() }

修复示例 ​

ts
import { createDocx, createDocxPreview } from 'docx-kit'

const container = document.createElement('div')
document.body.append(container)

const preview = createDocxPreview(container)
try {
  await preview.render(await createDocx().p('Hello').toBlob())
} finally { preview.destroy() }

常见原因 ​

  • 归档损坏、内容不受支持,或渲染器异常。

诊断字段 ​

消息示例 ​

text
Failed to render DOCX preview

源码与相关指南 ​

Released under the MIT License.