当前位置:网站首页>js创建pdf文件
js创建pdf文件
2022-06-30 06:59:00 【学习使我快乐——玉祥】
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Blobs</title>
<script src="http://localhost:81/0_plus-in/jspdf/jspdf.debug.js"></script>
</head>
<body>
<button id="button">Link</button>
</body>
<script>
const download = (fileName, blob) => {
const element = document.createElement('a');
const url = window.URL.createObjectURL(blob);
element.href = url;
element.download = fileName;
element.target = '_blank';
element.click();
element.remove();
}
document.addEventListener('click', async event => {
if (event.target.id === 'button') {
const doc = new jsPDF();
const fileName = 'test.pdf';
doc.text('Hello world!', 10, 10);
const blob = new Blob([doc.output()]);
download(fileName, blob);
}
});
</script>
</html>
边栏推荐
- memcpy内存重叠的解决
- Assembly language learning I (with stack co process, 32-bit registers and related instructions, to be continued 06/29)
- 社招两年半10个公司28轮面试面经
- 手机开户一般哪个证券公司好?还有,在线开户安全么?
- 【我的OpenGL学习进阶之旅】关于OpenGL的着色器的向量和矩阵分类的访问方式: xyzw/rgba/stpq以及数组下标
- Vscode returns the previous cursor (previous browse position)
- Go项目目录结构介绍
- Ffmplay is not generated during the compilation and installation of ffmpeg source code
- 【每日一题】535. TinyURL 的加密与解密
- [semidrive source code analysis] [x9 chip startup process] 33 - Analysis of related concepts of display module
猜你喜欢
Four tips in numpy
Why does ETL often become ELT or even let?
Google Earth engine (GEE) - Murray global tidal wetland change V1 (1999-2019) data set
Connection Flood攻击原理
Google Earth Engine(GEE)——墨累全球潮汐湿地变化 v1 (1999-2019) 数据集
SOC项目AHB_SD_HOST控制器设计
GO安装以及配置(1)
CPU到底是怎么识别代码的?
0基础转行软件测试,如何实现月薪9.5k+
Win10踩坑-开机0xc0000225
随机推荐
【转】存储器结构、cache、DMA架构分析
CPU到底是怎么识别代码的?
【已解决】ERROR 1290 (HY000): Unknown error 1290
[semidrive source code analysis] [x9 chip startup process] 34 - RTOS side display module SDM_ display_ Init display initialization source code analysis
成品升级程序
第一行代码(第三版)学习笔记
Out of class implementation of member function of class template
Ffmplay is not generated during the compilation and installation of ffmpeg source code
How to set the hot deployment of idea web project
免实名域名是什么意思?
Install the components corresponding to setup
RT thread migration to s5p4418 (III): static memory pool management
【json-tutorial】第一章学习笔记
【Hot100】11. 盛最多水的容器
汇编语言学习一(有栈协程铺垫,32位寄存器和相关指令学习,未完待续06/29)
Redis cache
Four great happenings on earth
[Hot100]回文子串 与 最长回文子串
The solution of memcpy memory overlap
How does the CPU recognize the code?