eKoopmans / html2pdf.js

Client-side HTML-to-PDF rendering using pure JS.
MIT License
4.05k stars 1.37k forks source link

Track Progress of PDF Generation #355

Open kempsteven opened 3 years ago

kempsteven commented 3 years ago

You mentioned here, that the Worker object returned by html2pdf() has a built-in progress-tracking mechanism.

How exactly do we get the progress?

coderfin commented 1 year ago

Looking at the code the progress tracking definitely seems to be a work-in-progress. I wasn't able to yield any helpful results.

It appears that you need to use this.progress in one of the Worker API methods.

In my testing I didn't see this.progress change significantly.

Here is what I used to test it:


new html2pdf.Worker()
      .then(function() {
        let numIterations = 40
        const interval = setInterval(() => {
          if (numIterations <= 0) {
            clearInterval(interval)
            return
          }
          numIterations -= 1
          console.log(this.progress)
        }, 100)
      })
...