Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate editable PDF using puppeteer

I am trying to generate PDF using puppeteer, everything works fine but input & checkboxes are not editable. In documentation i can't find how to make it editable, or elsewhere.

is it possible ? if so how ?

// ... 
const _conf = _.merge(conf, {
    format: 'A4',
    margin: {
       left: '15px',
       top: '15px',
        right: '15px',
        bottom: '15px'
                    }
   });
   const browser = await puppeteer.launch({ headless: true })
   const page = await browser.newPage()
   await page.setContent(html)
   const buffer = await page.pdf()

   await browser.close()


   return buffer;

like image 977
Maielo Avatar asked Mar 02 '23 23:03

Maielo


1 Answers

Puppeteer is a Node library which provides a high-level API to control Chromium over the DevTools Protocol. The API allows you to call Chromium functionality to generate PDF. The API doesn't do anything special, just providing the layer to the functionality of Chromium. As of the above, this is not the question for Puppeteer team indeed. They already answered this @ Pdf form inputs not editable.

Now to the Chromium ... "Save as PDF" option is designed to generate PDF for printing and does not support HTML form controls mapping to PDF AcroForms elements. They are not going to implement it any time soon per answer from the project member @ Issue 1024713: save-as-pdf doesn't generate editable form inputs.

Bottom line: It is not possible with Puppeteer.

like image 147
Slava Ivanov Avatar answered Mar 05 '23 15:03

Slava Ivanov