Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress of pdf creation #837

Closed
emanuelschuetze opened this issue Jan 23, 2017 · 5 comments · Fixed by #851
Closed

Progress of pdf creation #837

emanuelschuetze opened this issue Jan 23, 2017 · 5 comments · Fixed by #851

Comments

@emanuelschuetze
Copy link

I'm searching for a generic progress callback in pdfmake which gets the current progress while the pdf generation (in percentage). Then an application can show a progress bar of pdf creation. Such a user feedback is really required if you create huge pdf documents.

@lachok
Copy link
Contributor

lachok commented Feb 1, 2017

I'd like this feature as well and have been looking at implementing it. The idea is to allow passing a progressCallback function in the options parameter to PdfPrinter.createPdfKitDocument. This will then be passed to renderPages.

In renderPages we can get the total number of items to be rendered and call the progressCallback every time a new item is rendered.

If this sounds like a good idea I'd be happy to do a pull request.

@liborm85
Copy link
Collaborator

liborm85 commented Feb 4, 2017

Merged PR #851

@darrinholst
Copy link
Contributor

@lachok are you using this in the browser or server? I'm trying to use this server side and posting the progress to an external store (redis in this case) and it seems that the actual building of the pdf is all cpu bound so none of my I/O to redis gets processed until everything is done. In other words, I have a progress bar that goes directly from 0 to 100. Any ideas?

@lprusch
Copy link

lprusch commented Apr 3, 2017

@darrinholst I've been trying to add a progress bar at client side (bootstrap) to pdfmake, but got the same issue you report. I've tried different sleep techniques inside the progressCallback function to try to let angular update the DOM, but no use.

Also if I update the $scope var that holds the percentage only at 10% intervals (using $apply accordingly), to avoid too many $scope updates it still doesnt work. But if I hit a breakpoint each time the $scope is updated, then the progress bar updates by 10%.

So the problem seems to be about what threads need to be suspended and how. Any ideas I could try?

@darrinholst
Copy link
Contributor

I looked at it for a few hours and couldn't find a solution. I'm thinking the problem is in pdfkit, not here, but I don't know for sure. It would be nice to have this work. Possibly related - foliojs/pdfkit#269?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants