Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

PDF Embed API AddAnnotationsInPdf()

New Here ,
Feb 24, 2022 Feb 24, 2022
Hi I'm currently using the PDF Embed API and I'm adding a hundred of shape annotations to a PDF (with a single addAnnotationsInPDF() call)  and it adds all the annotations visually, then adds one annotation at a time very slowly, that I can see following the triggered events and during this action it locks the application screen and take several minutes to complete. This makes the viewer barely usable for my application...
 
A JSON example of an annotation that is added:
{
    "@context": [
    ],
    "id""a3e2414b-1cef-4c4b-8447-1d143b42a79a",
    "type""Annotation",
    "motivation""commenting",
    "bodyValue""-",
    "target": {
        "source": "17",
        "selector": {
            "node": {
                "index": 0
            },
            "opacity": 0.4,
            "subtype": "shape",
            "boundingBox": [
                66,
                731.9199829101562,
                326,
                740.9199829101562
            ],
            "inkList": [
                [
                    66,
                    731.9199829101562,
                    326,
                    731.9199829101562
                ],
                [
                    326,
                    731.9199829101562,
                    326,
                    740.9199829101562
                ],
                [
                    326,
                    740.9199829101562,
                    66,
                    740.9199829101562
                ],
                [
                    66,
                    740.9199829101562,
                    66,
                    731.9199829101562
                ]
            ],
            "strokeColor": "#b80000",
            "strokeWidth": 3,
            "type": "AdobeAnnoSelector"
        }
    },
    "creator": {
        "name": "Beatriz P.",
        "type": "Person"
    },
    "created""2022-02-21T15:51:25Z",
    "modified""2022-02-21T15:51:25Z"
}
TOPICS
General , How to , PDF Embed API , PDF Extract API , PDF Services API
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 24, 2022 Feb 24, 2022

Please share your code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2022 Mar 04, 2022

It's a single call to AddAnnotationsInPdf with an array with more than 100 annotations like this one:

{
    "@context": [
    ],
    "id""a3e2414b-1cef-4c4b-8447-1d143b42a79a",
    "type""Annotation",
    "motivation""commenting",
    "bodyValue""-",
    "target": {
        "source": "17",
        "selector": {
            "node": {
                "index": 0
            },
            "opacity": 0.4,
            "subtype": "shape",
            "boundingBox": [
                66,
                731.9199829101562,
                326,
                740.9199829101562
            ],
            "inkList": [
                [
                    66,
                    731.9199829101562,
                    326,
                    731.9199829101562
                ],
                [
                    326,
                    731.9199829101562,
                    326,
                    740.9199829101562
                ],
                [
                    326,
                    740.9199829101562,
                    66,
                    740.9199829101562
                ],
                [
                    66,
                    740.9199829101562,
                    66,
                    731.9199829101562
                ]
            ],
            "strokeColor": "#b80000",
            "strokeWidth": 3,
            "type": "AdobeAnnoSelector"
        }
    },
    "creator": {
        "name": "Beatriz P.",
        "type": "Person"
    },
    "created""2022-02-21T15:51:25Z",
    "modified""2022-02-21T15:51:25Z"
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Mar 04, 2022 Mar 04, 2022

Are you listening for any annotation events?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2022 Mar 04, 2022

all of them 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Mar 04, 2022 Mar 04, 2022

Ok - That's what's accounting for the slowdown. For each of the 100 annotations being added, as each one is being added, the callbacks are firing.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2022 Mar 04, 2022

So what do I do, start listening only after I add the annotations?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Mar 04, 2022 Mar 04, 2022

That'd be my recommendation.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 08, 2022 Mar 08, 2022

When I put after the addAnnotationsInPDF() call, it listens to all the annotation_added events..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 08, 2022 Mar 08, 2022

Even if I listen after I call addAnnotationsInPDF(), it listens to all the annotation_added events

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 08, 2022 Mar 08, 2022

Please share your code

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 08, 2022 Mar 08, 2022

I fixed the problem with the listening... but the problem of adding more than 100 annotations being slow, still there. When I add a few annotations, it adds really fast, but when it a pdf with more than 100 pages and more than 100 annotations distributed in those pages, gets really slow

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 08, 2022 Mar 08, 2022
LATEST
viewSDKClient.ready().then(() => {
              const files = info.fileList
              if (files.length > 0 && isValidPDF(files[0])) {
                const fileName = files[0].name
                const reader = new FileReader()
                reader.onloadend = e => {
                  const filePromise = Promise.resolve(e.target.result)
                  viewSDKClient.previewFileUsingFilePromise('pdf-div', filePromise, fileName, id, account).then(async adobe => {
                    annotationManager = await adobe.getAnnotationManager()
                    annotationManager.setConfig({
                      showCommentsPanel: false,
                      downloadWithAnnotations: true,
                      printWithAnnotations: true
                    })
    annotationManager.addAnnotationsInPDF(annotations)
    .then(() => annotationManager.registerEventListener(eventAnnotation => {
                        annotationEventListener(eventAnnotation)
                      }))
                  })
                }
                reader.readAsArrayBuffer(files[0].originFileObj)
              }
            })
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources