我正在尝试使用pdf2pic模块将PDF页面转换为图像。
import { fromPath } from "pdf2pic";
const options = {
density: 700,
saveFilename: "output_img",
savePath: "./images",
format: "jpeg",
width: 2480,
height: 3508,
};
const convert = fromPath("/path/to/pdf/sample.pdf", options);
const pageToConvertAsImage = 1;
convert(pageToConvertAsImage, { responseType: "image" })
.then((resolve) => {
console.log("Page 1 is now converted as image");
return resolve;
});
字符串
上述代码可以很好地转换单个图像,但我需要将整个PDF转换为图像。
1条答案
按热度按时间apeeds0o1#
你可以使用一个循环来遍历PDF的所有页面。试试这样做,
字符串