yakovmeister / pdf2image

A utility for converting pdf to image and base64 format.
MIT License
411 stars 139 forks source link

Cant convert image some file PDF #116

Open binhleon opened 3 years ago

binhleon commented 3 years ago
  const options = {
        density: 600,
        saveFilename: req.file.filename,
        savePath: `${appRoot}/${process.env.UPLOAD_PDF_DIR}`,
        format: "jpg",
        width: 600,
        height: 600
    };
    console.log("[pdf2pic] req.file.path = ", req.file.path);
    const convert = fromPath(req.file.path, options);

    convert.bulk(-1, true).then(resolve => {
        console.log(resolve)
        req.convertInfo = resolve;
        next();
    }).catch(err => {
        console.log("[pdf2pic][convert]", err);
        return next(err);
    });

I can convert some other PDF file with resolution around 5xx, but have 1 file with resolution 5xxx then it stuck and cant move to other step. It take long time and slow my PC but not return any error. I dont know why it happen , please help me what should i do in this case

binhleon commented 3 years ago

I found solution to update this file by set density:100 but anyway we can detect file pdf to set density?

vvnsze commented 3 years ago

Running into issue where even if I set density to 100, it errors out

binhleon commented 3 years ago

try to change format to png it work for me

Running into issue where even if I set density to 100, it errors out

yakovmeister commented 2 years ago
  const options = {
        density: 600,
        saveFilename: req.file.filename,
        savePath: `${appRoot}/${process.env.UPLOAD_PDF_DIR}`,
        format: "jpg",
        width: 600,
        height: 600
    };
    console.log("[pdf2pic] req.file.path = ", req.file.path);
    const convert = fromPath(req.file.path, options);

    convert.bulk(-1, true).then(resolve => {
        console.log(resolve)
        req.convertInfo = resolve;
        next();
    }).catch(err => {
        console.log("[pdf2pic][convert]", err);
        return next(err);
    });

I can convert some other PDF file with resolution around 5xx, but have 1 file with resolution 5xxx then it stuck and cant move to other step. It take long time and slow my PC but not return any error. I dont know why it happen , please help me what should i do in this case

It could probably be that the resolution is too big to handle. I will do some testing from my end to see if that is the case.

yakovmeister commented 2 years ago

Running into issue where even if I set density to 100, it errors out

@vvnsze which error message are you getting? can you send me the stack trace? thanks.