读取文本输入 .docx .pdf 文件

发布于 2025-01-19 08:46:59 字数 875 浏览 1 评论 0原文

我想在JS环境中读取.docx .pdf文件中的文本。

但在输入文件对象中没有阅读文本示例。 还有其他一些问题是从路径上的文件中读取文本。

这是我的代码

//模板

<v-file-input @change="uploadFile" />

//脚本

async uploadFile(file) {
  if (file != null) {
    // Extract file ext
    this.test_file = file;
    const ext = this.test_file.name.substring(this.test_file.name.lastIndexOf('.') + 1, this.test_file.name.length).toLowerCase();

    // Process by ext
    switch (ext) {
      case 'txt':
        let text = await this.test_file.text();
        this.file_text = text;
        break;
      case 'docx':
        // How can I process docx file
        break;
      case 'pdf':
        // How can I process pdf file
        break;
      default:
        break;
    }
  } else {
    this.file_text = '';
  }
}

I want to read text in .docx .pdf File in JS environment.

but No exist Reading Text Example from input File Object.
Some Other question's that Reading Text from File on path.

This is my code

// template

<v-file-input @change="uploadFile" />

// script

async uploadFile(file) {
  if (file != null) {
    // Extract file ext
    this.test_file = file;
    const ext = this.test_file.name.substring(this.test_file.name.lastIndexOf('.') + 1, this.test_file.name.length).toLowerCase();

    // Process by ext
    switch (ext) {
      case 'txt':
        let text = await this.test_file.text();
        this.file_text = text;
        break;
      case 'docx':
        // How can I process docx file
        break;
      case 'pdf':
        // How can I process pdf file
        break;
      default:
        break;
    }
  } else {
    this.file_text = '';
  }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文