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

Add load progress callback #94

Closed
pj-r opened this issue Jun 6, 2017 · 3 comments
Closed

Add load progress callback #94

pj-r opened this issue Jun 6, 2017 · 3 comments
Assignees
Milestone

Comments

@pj-r
Copy link

pj-r commented Jun 6, 2017

Would it be hard to add an event emitter for progress of loading pdf document?
I did quick research and looks like it could be done.

from pdfjs src/display/api.js we can find:

loadingTask.onProgress({
  loaded: data.loaded,
  total: data.total,
});

add an event emitter to pdf-viewer.component.ts:

@Output('on-progress') onProgress = new EventEmitter<any>();

change the line in pdf-viewer.component.ts to handle progress event:

PDFJS.getDocument(src).then((pdf: PDFDocumentProxy) => {

---->

PDFDocumentLoadingTask task = PDFJS.getDocument(src);
task.onProgress = (any) => { this.onProgress(any); };
task.then((pdf: PDFDocumentProxy) => {

Note: Just pseudo code. Havent tested if it works.

@VadimDez
Copy link
Owner

VadimDez commented Jun 6, 2017

You can use different approach, by just settings isLoading = true; before and then change to isLoading = false once after-load-complete event is called.

@pj-r
Copy link
Author

pj-r commented Jun 7, 2017

Thats good approach but in my case the problem is that for example with IE loading some bigger pdf files can take up to 3 minutes and it would be nice to show progress for the user so he/she can determine how long the coffee break will be.

There is one example file: https://github.com/mozilla/pdf.js/issues/7989

@VadimDez VadimDez self-assigned this Aug 16, 2017
@VadimDez VadimDez added this to the 1.2.2 milestone Aug 16, 2017
VadimDez added a commit that referenced this issue Aug 16, 2017
Closes #94, added on-progress callback
@pj-r
Copy link
Author

pj-r commented Sep 6, 2017

Nice work, Thanks!

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

No branches or pull requests

2 participants