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 document loading life cycle events #4448

Closed
datsis opened this issue Mar 13, 2014 · 4 comments
Closed

Add document loading life cycle events #4448

datsis opened this issue Mar 13, 2014 · 4 comments
Labels

Comments

@datsis
Copy link

datsis commented Mar 13, 2014

There is need for life cycle events in case if PDFJS is used to review multiple documents.

Here is scenario:

  1. User makes search and finds several documents with some keywords
  2. When user click on document PDFJS is loaded document with open(url) function
  3. When document is loaded and rendered it is necessary to highlight keywords

For now there is no way how to catch a moment when document has been rendered.

@yurydelendik
Copy link
Contributor

For now there is no way how to catch a moment when document has been rendered.

There is no exact moment "when document has been rendered". The pages are rendered when they become visible. Only one page documents are "fully" rendered.

To find keywords in the document, the find UI can be used, which will index PDF page by extracting the text content page-by-page. Do you mean to add event to signal when keyword is found or not found?

@datsis
Copy link
Author

datsis commented Mar 14, 2014

Hi, Yury!

Actually I try to use such code sample to highlight keywords:
PDFFindBar.findField.value = keywords;
PDFFindBar.dispatchEvent('')

I try to call it after each call of PDFView.open('url', 0) but it does not work because at the moment when PDFFindBar is called the document is not rendered yet

The perfect way would be to call something like that:
PDFView.open('url',..., {search: 'some-keywords'}) for each showing document

@datsis
Copy link
Author

datsis commented Mar 14, 2014

On the other hand more flexible way is to subscribe for some events which can looks in this way:
PDFView.addListener('already-can-highlight-something', function(){
PDFFindBar.findField.value = 'some-keywords';
PDFFindBar.dispatchEvent('')
}

@Snuffleupagus
Copy link
Collaborator

For now there is no way how to catch a moment when document has been rendered.

There's the documentinit event, which signals that the document is ready for user-interaction; this issue can probably be closed now.

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

No branches or pull requests

4 participants