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

PDF Embed API AddAnnotationsInPdf()

New Here ,
Feb 24, 2022 Feb 24, 2022

Copy link to clipboard

Copied

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

Views

221

Translate

Translate

Report

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

Copy link to clipboard

Copied

Please share your code.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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"
}

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Are you listening for any annotation events?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

all of them 

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

That'd be my recommendation.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Please share your code

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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)
              }
            })

Votes

Translate

Translate

Report

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