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

Does not display annotations in a pdf document. #712

Open
Kyython opened this issue May 18, 2020 · 2 comments
Open

Does not display annotations in a pdf document. #712

Kyython opened this issue May 18, 2020 · 2 comments

Comments

@Kyython
Copy link

Kyython commented May 18, 2020

I use a pdf.js for displaying a pdf document. I needed to create annotations in this document, so I used your library of the latest version to implement my task.

I came across a problem that when there is a request to get annotations, they are not shown in the document. There are no errors or warnings. The incoming Json matches the one specified in the documentation. I do everything as specified in your documentation, but I can't understand what the problem is.

This is my connection script

<script>
    var pageUri = function () {
      return {
        beforeAnnotationCreated: function (ann) {
          ann.uri = window.location.href;
        }
      };
    };

    var app = new annotator.App()
      .include(annotator.ui.main, {
        viewerExtensions: [
          annotatormeltdown.viewerExtension
        ],
        editorExtensions: [
          annotatormeltdown.getEditorExtension({ min_width: '200px' })
        ]
      })
      .include(annotator.storage.http, {
        prefix: 'http://localhost/api/annotator'
      })
      .include(pageUri);

    app.start()
      .then(function () {
        app.annotations.load({ uri: window.location.href });
      });

  </script>

This is my json that comes with a get query search

{
  "id": "ad8415fd-b40b-48c9-a2a9-6ad1a2728b59",
  "text": "text",                  
  "quote": "someone text",   
  "uri": "http://localhost...",        
  "ranges": [                               
    {
      "start":"/div[4]/div[2]/div[4]/div[1]/div[1]/div[2]/div[1]",
      "end":"/div[4]/div[2]/div[4]/div[1]/div[1]/div[2]/div[1]",   
      "startOffset": 0,                
      "endOffset": 120
    }
  ]
}

Any help would be welcome, thank you.

@zahqresh
Copy link

Exactly same problem im facing using it with pdf.js

@zahqresh
Copy link

I solved this issue, so you have to put this inside the promise when it renders the text layers thats when it should initialize the annotatorjs and fetch the annotation data and annotations will be shown while there is a gotcha if you are using or rendering multiple pages at the same time you have to somehow render the annotations when the last text layer is rendered and thats how annotations will be loaded when your document gets loaded. Hope this will help.

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

No branches or pull requests

2 participants