我试过pdf2json:
const PDFParser = require("pdf2json");
let pdfParser = new PDFParser();
pdfParser.loadPDF("./30x40.pdf"); // ex: ./abc.pdf
pdfParser.on("pdfParser_dataReady", pdfData => {
width = pdfData.formImage.Width; // pdf width
height = pdfData.formImage.Pages[0].Height; // page height
console.log(`Height : ${height}`) // logs 70.866
console.log(`Width : ${width}`) // logs 53.15
});但它给出了一个未知单位的尺寸!
以像素为单位的尺寸将帮助我将它们包含在pdf-poppler模块中,该模块将pdf文件转换为图像,它需要以像素为单位的pdf文件高度。
发布于 2020-07-09 11:34:47
发布于 2022-02-23 15:23:52
聚会有点晚了,但正如这里所讨论的:stackoverflow pdf2json单元可以将您的宽度和高度乘以24,如下所示:
width = pdfData.formImage.Width * 24; // pdf width
height = pdfData.formImage.Pages[0].Height * 24; // page height你得到了皮克斯。
https://stackoverflow.com/questions/62813225
复制相似问题