PejmanNik/puppeteer-report

BUG : Error: EPERM: operation not permitted, unlink...

Closed this issue · 2 comments

Hi,

First of all, thanks a lot for creating this package, I've been looking for something like this for a while !
I was previously using PhantomJS instead of Puppeteer for generating PDFs, but the fack that PhantomJS is no longer maintained, plus the non-support of flexbox pushed me to switch for a more modern alternative.

Unfortunately, I've not been able to use you package because of an error. Here's my code, and the output message :

  • CODE :
const fs = require("fs");
const path = require("path");
const report = require('puppeteer-report');
const puppeteer = require('puppeteer');

const PuppeteersPdfBuild = async (assessId, fileType) => {
    const html = fs.readFileSync('./sample.html', {encoding: "utf8"})
    const fileName = `${assessId}_${Date.now()}.pdf`
    var options = {
        format: 'A4',
        displayHeaderFooter: true,
        landscape: fileType === 'official_certificate' ? true : false,
        margin: {
            top: "3cm",
            left: "1cm",
            right: "1cm",
            bottom: "3cm"
        },
        printBackground: true,
        path: fileName
    }    
    report.pdf(options)
}

PuppeteersPdfBuild('score_report')
  • ERROR MESSAGE :
{
[Error: EPERM: operation not permitted, unlink 'C:\Users\cypri\AppData\Local\Temp\puppeteer_dev_chrome_profile-Tp4WZd\CrashpadMetrics-active.pma'] {
  errno: -4048,
  code: 'EPERM',
  syscall: 'unlink',
  path: 'C:\\Users\\cypri\\AppData\\Local\\Temp\\puppeteer_dev_chrome_profile-Tp4WZd\\CrashpadMetrics-active.pma'
}

If anything is element is missing to my message for you to help me, please tell me and I'll add it ASAP.
Thanks by advance !

Thank you for using this library 😁

Can you please use Puppeteer pdf method directly (page.pdf())? without this package? I think the error is from Puppeteer itself. This package just helps you to have a header and footer.

Please feel free to open the issue if you have more info.