读取文本输入 .docx .pdf 文件
我想在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论