vue3 前端实现导出下载pdf文件

这样的数据实现导出 yourArrayBufferOrByteArray 就是后端返回数据

复制代码
// 创建Blob对象
    const blob = new Blob([new Uint8Array(res)], { type: 'application/pdf' })

    // 创建一个表示该Blob的URL
    const url = URL.createObjectURL(blob);

    // 创建一个a标签用于下载
    const a = document.createElement('a');
    a.href = url;
    a.download = 'yourfile.pdf'; // 设置下载文件名
    document.body.appendChild(a);
    a.click(); // 触发下载

    // 释放URL对象
    URL.revokeObjectURL(url);
    document.body.removeChild(a);
相关推荐
恋猫de小郭5 分钟前
Firebase 如何让全球 Android 和 Flutter 开发者集体 Build Fail
android·前端·flutter
墨白曦煜6 分钟前
智能体架构范式总结(React、Plan-And-Solve、Reflection)
前端·react.js·前端框架
qq_426003969 分钟前
多语言新增语种全量测试策略的测试范围
前端·javascript·python·自动化
SamChan9012 分钟前
Python+ReportLab自动生成PDF翻译质量审计报告:从数据到可视化的完整方案
开发语言·python·ai·pdf·wpf
一晌小贪欢14 分钟前
Python办公18:PDF 转 Word——利用 OCR 技术批量提取不可编辑的文档内容
开发语言·python·pdf·word·excel·数据可视化·python办公
frjc21 分钟前
Node.js 与 npm 极简安装教程
前端·npm·node.js
IMPYLH22 分钟前
HTML 的 <main> 元素
前端·html
深念Y24 分钟前
微服务抽取路线图:从胖单体到 ARM 集群
前端·arm开发·数据库·后端·微服务·云原生·架构
SamChan9031 分钟前
用Prometheus+Grafana搭建PDF翻译服务监控看板:指标采集与告警实战
python·ai·pdf·grafana·prometheus·机器翻译
雪芽蓝域zzs41 分钟前
Vue3 + Vite本地模拟数据(读取 JSON 数据)
前端