当前位置:网站首页>Save pdf2image PDF file as JPG nodejs implementation
Save pdf2image PDF file as JPG nodejs implementation
2022-07-25 09:43:00 【Flying time machine】
Simple test PDF To JPG
const path = require('path');
const pdf = require('pdf-poppler');
const fs = require('fs');
// let file = '/Users/yd-sz-dn0588/1.pdf'
function convert(file){
let opts = {
format: 'jpeg',
out_dir: path.dirname(file),
out_prefix: path.basename(file, path.extname(file)),
page: null
}
pdf.convert(file, opts)
.then(res => {
console.log('Successfully converted: '+res);
})
.catch(error => {
console.error(error);
})
}
let dir="/Users/yd-sz-dn0588/ Product picture "
fs.readdir(dir, function (err, files) {
if (err) {
return console.log(' directory does not exist ')
}
console.log(files)
files.forEach(function (file) {
let newFile = dir + "/"+file
console.log("new File: "+newFile)
convert(newFile)
})
})
Richer use references : https://www.npmjs.com/package/pdf-poppler
Treasure dependency Library
边栏推荐
- 作业7.15 shell脚本
- 【cf】Round 128 C. Binary String
- How many regions can a positive odd polygon be divided into
- 初识Opencv4.X----图像模板匹配
- Data control language (DCL)
- Kotlin协程:协程的基础与使用
- UI prototype resources
- Data preprocessing
- In depth interpretation of C language random number function and how to realize random number
- *6-1 CCF 2015-03-2 numerical sorting
猜你喜欢

【数据挖掘】第四章 分类任务(决策树)

Redis string 结构命令

How many regions can a positive odd polygon be divided into

学习 Redis linux 安装Redis

A picture explains SQL join left and right

Prim minimum spanning tree (diagram)

OC--Foundation--字典

OC--对象复制

Kotlin collaboration: foundation and use of collaboration

@4-1 CCF 2020-06-1 linear classifier
随机推荐
A picture explains SQL join left and right
[code source] daily one question non decreasing 01 sequence
UI prototype resources
浏览器访问swagger失败,显示错误ERR_UNSAFE_PORT
laravel 调用第三方 发送邮件 (php)
Neural network method -- Boston house price (regression problem)
【数据挖掘】第四章 分类任务(决策树)
基于人脸识别的树莓派门禁系统
【cf】Round 128 C. Binary String
初识Opencv4.X----为图像添加椒盐噪声
cell的定义
How to configure SSH after changing the computer
Basic network knowledge
Learning new technology language process
OC--Foundation--字符串+日期和时间
初识Opencv4.X----图像模板匹配
About C and OC
OC -- Foundation -- dictionary
初识Opencv4.X----为图像添加高斯噪声
学习 Redis linux 安装Redis