简体   繁体   中英

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;

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM