marcbachmann / node-html-pdf

This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to headless chrome/puppeteer.
MIT License
3.56k stars 545 forks source link

Output pdf is not same as input index.html #591

Open aniruddhasm opened 4 years ago

aniruddhasm commented 4 years ago

Hello,

I am trying to implement it in nodejs.

const fs = require('fs')
const pdf = require('html-pdf')
const inputFileName = '/input.html'
const html = fs.readFileSync(inputFileName, 'utf8')
const outputFileName = '/output.pdf'

const options = { format: 'A4' }
pdf.create(html, options).toFile(outputFileName, function (err, res) {
   if (err) return console.log(err)
   console.log(res) // { filename: '/app/businesscard.pdf' }
}) 

The output pdf is not proper. output pdf - output-img

Expected output input-img

Any help will be appreciated.

canhpc commented 3 years ago

Did you manage to fix it? I have ran into same problem.

canhpc commented 3 years ago

I found the solution. Incase anyone else run into same problem, you need to disable the chart animation. Set the option object similar with below to disable your chart animation. new Chart(chartElement, { type: 'line', data: {'your data'}. options: { animation: { duration: 0, }, hover: { animationDuration: 0, }, responsiveAnimationDuration: 0, });