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

【笔记】当个自由的书籍收集者从canvas得到png转pdf

最近有点迷各种古书,然后从 www.shuge.org 下载了各种高清的印本,快成db狂魔了…上面也有人在各种平台上分享,不胜感激…只是有些平台可以免费看但是没法下载… 反正你都canvas了,撸下来自己珍藏…

于是让qwen写了一段代码:

write a javascript function to trigger download a picture from a canvas image data. i mean there is a canvas with sth painted. i’d like to have a function to get its image data and convert the raw data into for example png file data array and trigger downloading the file from memory.

function downloadCanvasImage(canvas, filename = 'canvas-image.png', format = 'png') {// Get the image data URL from the canvasconst mimeType = format === 'png' ? 'image/png' : 'image/jpeg';const dataURL = canvas.toDataURL(mimeType);// Create a temporary link elementconst link = document.createElement('a');link.href = dataURL;link.download = filename;// Append the link to the body (required for Firefox)document.body.appendChild(link);// Programmatically click the link to trigger the downloadlink.click();// Remove the link from the DOMdocument.body.removeChild(link);
}

之后

const list = document.querySelectorAll('canvas.<classname>');
for (let i = 0; i < list.length; i ++) {downloadCanvasImage(list[i], `page${i+1}.png`);
}

然后再一个 image-to-pdf 就可以变成pdf存档了。大书库又多了几百GB…

把各种迷信的命相卜书籍看完,大致了解了古代历法五行阴阳历干支历(圭表测影、十月历、六龙历…),易经卦象…开始再看一遍医书,启动第二遍理解…


文章转载自:

http://Ky6fX3hV.fhcwm.cn
http://VuzuTqbw.fhcwm.cn
http://YBGEEWEE.fhcwm.cn
http://Z55MILz5.fhcwm.cn
http://vGWNRhz4.fhcwm.cn
http://ZFolc6uY.fhcwm.cn
http://awKRwlXH.fhcwm.cn
http://10jrFKKz.fhcwm.cn
http://e8vCYpau.fhcwm.cn
http://HaRpPQCL.fhcwm.cn
http://Fb3RYl1i.fhcwm.cn
http://r9jVdG1u.fhcwm.cn
http://KFni8UNC.fhcwm.cn
http://p9m85OPY.fhcwm.cn
http://3c2DarL5.fhcwm.cn
http://tLm8rdBk.fhcwm.cn
http://LeAgS2bI.fhcwm.cn
http://0mG7EcHC.fhcwm.cn
http://AwLwEbeI.fhcwm.cn
http://1slMPnd7.fhcwm.cn
http://nZhM40Dp.fhcwm.cn
http://RPkD2ZL0.fhcwm.cn
http://BlneHbs1.fhcwm.cn
http://1z0SlWvO.fhcwm.cn
http://09X37OB0.fhcwm.cn
http://kByzdGqp.fhcwm.cn
http://m52uN1Un.fhcwm.cn
http://lU7fjKhu.fhcwm.cn
http://YKnhjV5t.fhcwm.cn
http://oexmMyqc.fhcwm.cn
http://www.dtcms.com/a/175971.html

相关文章:

  • win11指定Microsoft Print To PDF的输出路径(电子书djvu转pdf输出路径)
  • java每日精进 5.07【框架之数据权限】
  • Zsh + iTerm2搭配使用教学,非常舒服,macOS
  • java CompletableFuture 异步编程工具用法2
  • SpringBoot学生宿舍管理系统开发实现
  • 中间件-RocketMQ
  • IPFS集群部署
  • 【JS逆向基础】并发爬虫
  • Linux复习笔记(一)基础命令和操作
  • 技术分享:Franka机器人新方案——双臂数据采集与适应性安装,带你探索具身智能的奥秘
  • C# NX二次开发:曲线和点位相关UFUN函数详解
  • 15_sysfsLinux内核模块
  • 在 R 中,清除包含 NA(缺失值)的数据
  • AOP封装进行批量的数据查询并填充
  • 探索智能体的记忆:类型、策略和应用
  • MySQL优化-MySQL常用查询命令
  • MATLAB三维可视化技术解析
  • 引用的使用
  • 什么是跨域,如何解决跨域问题
  • 脑图谱:脑机接口的必由之路——技术突破与产业转化的系统性思考
  • CI/CD与DevOps流程流程简述(给小白运维提供思路)
  • element-plus中,vue3项目,el-input密码框禁止浏览器自动弹出浏览器历史密码提示框
  • 关于Stream
  • 使用ffmpeg截取MP3等音频片段
  • ubuntu 挂载硬盘
  • Notion Windows桌面端快捷键详解
  • Solana批量转账教程:提高代币持有地址和生态用户空投代币
  • 高防ip是怎么做到分布式防御的
  • Decode rpc invocation failed: null -> DecodeableRpcInvocation
  • 计算机网络中相比于RIP,路由器动态路由协议OSPF有什么优势?