LucianoGanga / simple-headless-chrome

Simple abstraction to use Chrome as a Headless Browser with Node JS
MIT License
217 stars 50 forks source link

PDF is not generating?(printToPDF fn) #67

Closed iyyappan13391 closed 7 years ago

iyyappan13391 commented 7 years ago

const HeadlessChrome = require('../index') const browser = new HeadlessChrome({ headless: true }) async function navigateWebsite() { try { await browser.init()

    // Open a new Tab
    const mainTab = await browser.newTab({ privateTab: true })

    // Navigate to a URL
    await mainTab.goTo('https://github.com/cognitom/paper-css/issues/13')

    await mainTab.wait(10000)

await mainTab.printToPDF('/home/iyappan/Documents/iyy/software/node_modules/simple-headless-chrome/examples/simple-headless-chrome-files3')
  // Close the browser
    await browser.close()
} catch (err) {
    console.log('ERROR!', err)
}

} navigateWebsite()

This is my code.I've referred the documents,When i use the printToPDF function,not getting the PDF output.Can you provide the solutions of it?

LucianoGanga commented 7 years ago

Hi!

Try this, I just added it for you:

https://github.com/LucianoGanga/simple-headless-chrome/blob/master/examples/printToPdf.js

It's available since version v4.3.8.

The method printToPDF was to print the PDF buffer, but you needed to save it. The method savePdf() does that for you ;)

Cheers! Lucho

iyyappan13391 commented 7 years ago

Thanks,Its working fine.