lyg
2024-06-15 a58adbb99f5e3283f495e8aa9db6f7b84e02592b
PDF页数获取出错处理
1个文件已修改
4 ■■■■ 已修改文件
src/main.mjs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.mjs
@@ -43,7 +43,7 @@
 */
async function getPdfPages(filepath) {
  const buf = fs.readFileSync(filepath);
  const pdfDoc = await pdfLib.PDFDocument.load(buf);
  const pdfDoc = await pdfLib.PDFDocument.load(buf, { ignoreEncryption: true });
  const pages = pdfDoc.getPages().length;
  return pages;
}
@@ -344,7 +344,7 @@
          book.format = ext;
          book.file = filepath;
          book.url = url;
          book.pages = await getPdfPages(filepath);
          book.pages = await getPdfPages(filepath).catch(e => 0);
          resolve(true);
        });
        stream.on("error", (err) => {