here is all the code that I'm using to try download an PDF file that was created previously:
import puppeteer, { PDFOptions } from 'puppeteer';
interface Request {
pageContent: string;
pdfOptions?: PDFOptions;
}
class GeneratePDFFileService {
async execute({ pageContent, pdfOptions }: Request): Promise<Buffer> {
const browser = await puppeteer.launch ({
headless: true,
args:['--no-sandbox']
});
const page = await browser.newPage();
await page.setContent(pageContent);
const pdfFileOptions = pdfOptions || {
printBackground: true,
format: 'a4',
margin: {
top: '2cm',
left: '2cm',
bottom: '2cm',
right: '2cm',
},
preferCSSPageSize: true,
};
const pdf = await page.pdf(pdfFileOptions);
await browser.close();
return pdf;
}
}
export { GeneratePDFFileService };
Here is the error:
application | Error: Failed to launch the browser process! spawn /usr/bin/chromium-browser ENOENT
application |
application |
application | TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
application |
application | at onClose (/usr/app/node_modules/puppeteer/src/node/BrowserRunner.ts:261:9)
application | at ChildProcess.<anonymous> (/usr/app/node_modules/puppeteer/src/node/BrowserRunner.ts:250:9)
application | at ChildProcess.emit (events.js:400:28)
application | at Process.ChildProcess._handle.onexit (internal/child_process.js:280:12)
application | at onErrorNT (internal/child_process.js:469:16)
application | at processTicksAndRejections (internal/process/task_queues.js:82:21)
Puppeteer version:
"puppeteer": "^13.1.3",
I've tried some tips in troubleshooting.md, but have no idea if I'm doing it right.