簡體   English   中英

在 gatsby 中讀取 docx 文件?

[英]Reading docx file in gatsby?

我正在嘗試在 Gatsby 網站上使用 Javascript 讀取並操作 docx 文件。

這是我到目前為止所擁有的:

const fileInput = require("../static/Hello.docx")
var reader = new FileReader()
reader.onload = function () {
  console.log(reader.result)
}
reader.readAsBinaryString(fileInput)

但是,我不斷收到此錯誤:

Unexpected character '♥' (1:2)

File: static\Hello.docx:1:2

實現此目的的正確方法是什么?

docx 是普通的 XML,但據我所知,它是壓縮的。

  1. 解壓docx文件
  2. 解析 XML
  3. 工藝 XML

您還可以查找 docx 解析器。 使用“npm docx parser”或類似的方式提供搜索引擎。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM