当前位置:网站首页>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>边栏推荐
- 【Hot100】11. 盛最多水的容器
- Performance comparison of random network, scale-free network, small world network and NS small world matlab simulation
- [semidrive source code analysis] [x9 chip startup process] 33 - Analysis of related concepts of display module
- JS null judgment operators | and? Usage of
- 踩坑记录:supervisor 日志返回信息:redis扩展未安装
- SOC_AHB_SD_IF
- 【Mask-RCNN】基于Mask-RCNN的目标检测和识别
- Running lantern effect JS text rotation effect realization
- [docsify basic use]
- [Hot100]10. 正则表达式匹配
猜你喜欢
随机推荐
Mysql5.7 compressed version installation tutorial
【模糊神经网络】基于模糊神经网络的移动机器人路径规划
【每日一题】535. TinyURL 的加密与解密
编写并运行第一个Go语言程序
SOC_ AHB_ SD_ IF
Finished product upgrade procedure
RT thread migration to s5p4418 (III): static memory pool management
成品升级程序
Write about your feelings about love and express your emotions
[Hot100]回文子串 与 最长回文子串
MySQL优化:从十几秒优化到三百毫秒
Ffmplay is not generated during the compilation and installation of ffmpeg source code
Graphic octet, really top
2022年6月29日--使用C#迈出第一步--使用 C# 中的“if”、“else”和“else if”语句向代码添加决策逻辑
Qstring to const char*
0 basic job transfer software test, how to achieve a monthly salary of 9.5k+
Win10踩坑-开机0xc0000225
First line of code (Third Edition) learning notes
JS widget wave JS implementation of wave progress bar animation style
Running lantern effect JS text rotation effect realization









