[Fixed] How to set destination path in pdf2image using Angular 6

Issue

I am using Angular 6. I have to convert a PDF to an image and for that, I am using the pdf2image npm package. My PDF gets converted into an image but I am not able to set a destination path for it. Below is my code snippet.

pdf2image.convertPDF('/NodeWorkspace/uploads/photo-1533016241503.pdf',{
    density : 200,
    quality : 100,
    outputFormat : '%s_page_%d',
    outputType : 'png',
    path: '/NodeWorkspace/uploads/output/'
})

Thanks for the help.

Solution

Below is the code to set destination path in pdf2image using Angular.

var dirPath=path.join(__dirname,'../../uploads/output/'+req.body.appNo)+'/%s_page_%d';

pdf2image.convertPDF(pt,{
        density : 200,
        quality : 100,
        outputFormat : dirPath,
        outputType : 'png'

    })

Leave a Reply

(*) Required, Your email will not be published