node.js - 将 PDF 缓冲区转换为 PNG 缓冲区
问题描述
有没有办法将 PDF 缓冲区转换为 png 图像缓冲区?
我所能做的就是将pdf缓冲区转换为base 64,但我不知道下一步该做什么。
谢谢 !
解决方案
我刚刚使用了https://github.com/yakovmeister/pdf2image,适用于我的用例,但需要一些本机 deps :
import { fromBuffer as convertPdfToPng } from 'pdf2pic'
const pdf2picOptions = {
format: 'png',
width: 2550,
height: 3300,
density: 330,
savePath: './output/from-buffer-to-base64',
}
const convert = convertPdfToPng(pdfBuffer, pdf2picOptions)
const pageOutput = await convert(pageNumber, true)
const pngBuffer = Buffer.from(pageOutput.base64, 'base64')
推荐阅读
- python-3.x - PyCharm 2019.1 CE:没有创建/编辑 Jupyter Notebook (*.ipynb) 文件的选项?
- sql - 如何根据clickhouse中的日期和时间段选择数据
- wildfly - Wildfly 的常见堆行为或应用程序内存泄漏?
- html - 更改范围滑块的颜色
- reactjs - 如何为动态创建的输入元素设置状态
- c# - 使用 SceneManager.LoadScene(int, LoadSceneMode.Additive) / SceneManager.UnloadSceneAsync(int) 加载/卸载关卡;删除默认级别
- c# - 如何卸载附加场景?
- database-design - 活动组织者的数据库架构设计
- tensorflow - 使用 tensorflowjs 进行联邦学习
- pygame - 游戏暂停时继续按钮不起作用