当前位置: 首页 > news >正文

网络科技公司网站首页怎么改网站关键词

网络科技公司网站首页,怎么改网站关键词,英文外贸网站设计,网站创建怎么做文章目录 mammothdocx4js mammoth 官网地址&#xff1a;https://github.com/mwilliamson/mammoth.js#readme 安装mammoth&#xff1a; npm i mammoth -S我们可以安装mammoth来实现上传的word文件的在线预览&#xff0c;我们以element的上传组件为示例&#xff1a; <temp…

文章目录

    • mammoth
    • docx4js

mammoth

官网地址:https://github.com/mwilliamson/mammoth.js#readme

安装mammoth:

npm i mammoth -S

我们可以安装mammoth来实现上传的word文件的在线预览,我们以element的上传组件为示例:

<template><div><el-upload class="upload-demo" drag action="#" :auto-upload="false" :on-change="changeFile"><el-icon class="el-icon--upload"><upload-filled /></el-icon><div class="el-upload__text">Drop file here or <em>click to upload</em></div><template #tip><div class="el-upload__tip">jpg/png files with a size less than 500kb</div></template></el-upload><div v-html="wordcontent"></div></div>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import type { UploadProps } from 'element-plus'
import mammoth from 'mammoth'const wordcontent = ref('')const changeFile: UploadProps['onChange'] = (uploadFile, uploadFiles) => {const file = uploadFile.rawconst myReader = new FileReader()myReader.readAsArrayBuffer(file as Blob)myReader.addEventListener('loadend', function (e) {const buffer = e?.target?.result // arraybuffer objectmammoth.convertToHtml({arrayBuffer: buffer}).then(function (result: { value: string; messages: any[] }) {const html = result.value // The generated HTMLconst messages = result.messages // Any mesarnings during conversionwordcontent.value = html}).done()})
}
</script>

详细的API参考官网地址。

docx4js

官网地址:https://github.com/lalalic/docx4js

使用docx4js实现获取docx文件有多少页码。

安装docx4js:

npm i docx4js -S

我们新建一个docx.mjs,代码如下:

import docx4js from 'docx4js'
import { TextDecoder } from 'util'docx4js.docx.load('./test2.docx').then((doc) => {const propsAppRaw = doc.parts['docProps/app.xml']._data.getContent()const propsApp = new TextDecoder('utf-8').decode(propsAppRaw)console.log(propsApp)const match = propsApp.match(/<Pages>(\d+)<\/Pages>/)if (match && match[1]) {const count = Number(match[1])console.log(count)}
})

执行命令: node docx.mjs

可以在控制台看到打印结果,第一个打印:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><Template>Normal.dotm</Template><Pages>4</Pages><Words>996</Words><Characters>1013</Characters><Lines>0</Lines><Paragraphs>0</Paragraphs><TotalTime>0</TotalTime><ScaleCrop>false</ScaleCrop><LinksUpToDate>false</LinksUpToDate><CharactersWithSpaces>1250</CharactersWithSpaces><Application>WPS Office_12.1.0.18543_F1E327BC-269C-435d-A152-05C5408002CA</Application><DocSecurity>0</DocSecurity></Properties>

第二个打印:

4

其中的4表示这个word文档是4页。

但是有时候,有的word文档解析的结果是不一样的,如下:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ap:Properties xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes" xmlns:ap="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"/>

该文件中就没有包含Pages的字段。

所以综上所示,如果通过docx4js获取word文件的页码数量是不准确的,并且需要在node环境中运行,且文件是docx格式的,doc格式的不支持。

http://www.yayakq.cn/news/468204/

相关文章:

  • 初中电脑做网站的软件软件公司做网站推广科目
  • 深圳国内网站建设建设网站教学
  • 做短视频网站用哪家cms网站挂服务器后图片不显示
  • 青海建设厅的门户网站网站修改关键字
  • asp建材公司网站源码龙岗网络营销网站制作哪里好
  • 小白如何搭建个人网站如何在网盘上做网站
  • 广德网站开发织梦网站首页错位
  • 建站大师阙梅娇简介wordpress悬浮框
  • 上饶建设局网站图书网站开发的实践意义
  • jsp网站项目在汕头的网络公司有哪些
  • wordpress代码运行插件吗seo按天计费系统源码
  • 青岛企业网站设计制作沧州做网站价格
  • 国外网站推广方法如何制作软件界面
  • 那些网站能够做推广网站建设业务好跑吗
  • 怎样在华为云服务器里建设网站ui设计就业方向
  • cc域名做网站怎么样衡水网站建设公司联系电话
  • 什么行业最需要网站建设百科网站程序
  • 宁波企业网站优化推广纯代码添加wordpress网站底部导航
  • 做影视网站什么cms好用重庆网络营销公司哪家好
  • 淄博网站seo职业生涯规划大赛项目名称
  • 机械类产品网站做优化深圳网站建设q.479185700惠
  • 在哪个网站做民营企业申报wordpress分享到 滑动
  • 网站改版方案环保主题的网站模板
  • 中国响应式网站建设渌口区市政建设局网站
  • 定制网站建设服务平台广东seo价格是多少钱
  • 海口 网站开发宁波男科医院哪家好
  • jQuery EasyUI网站开发实战app开发公司
  • 需要找做网站的威海北京网站建设
  • 网站只能用ip访问网站百度视频免费下载
  • 网站优化布局网页设计考试题目