ajihakim201 commited on
Commit
e06475d
·
verified ·
1 Parent(s): 565f5d0

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +11 -10
server.js CHANGED
@@ -29,17 +29,18 @@ app.post("/ocr", async (req, res) => {
29
 
30
  const { fromPath } = require("pdf2pic");
31
 
32
- const options = {
33
- density: 150,
34
- saveFilename: "page",
35
- savePath: uploadDir,
36
- format: "png",
37
- width: 1024,
38
- height: 1024
39
- };
40
 
41
- const storeAsImage = fromPath(pdfPath, options);
42
- const result = await storeAsImage(1);
 
 
 
 
 
 
 
 
43
 
44
  // Loop semua halaman PDF
45
  for (let page = 1; page <= totalPages; page++) {
 
29
 
30
  const { fromPath } = require("pdf2pic");
31
 
32
+ const { PDF2Pic } = require("pdf2pic");
 
 
 
 
 
 
 
33
 
34
+ const pdf2pic = new PDF2Pic({
35
+ density: 150,
36
+ saveFilename: "page",
37
+ savePath: uploadDir,
38
+ format: "png",
39
+ width: 1024,
40
+ height: 1024
41
+ });
42
+
43
+ const result = await pdf2pic.convert(pdfPath, 1);
44
 
45
  // Loop semua halaman PDF
46
  for (let page = 1; page <= totalPages; page++) {