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

Cannot read properties of undefined (reading 'length')' Error on adding annotation on pdf

New Here ,
Jan 30, 2023 Jan 30, 2023

Copy link to clipboard

Copied

Hi,

I'm getting the following errors :

'Uncaught TypeError: Cannot read properties of undefined (reading 'length')'

 

Steps to reprodue :

- on the embedded pdf viewer open the pdf and select a portion of text

- on mouse hover over the selected text, console prints the above message

 

On further investigating, this is happening when _validateMinLength(propertyName, obj, minLength) in AnnotationValidatoeUtil.js file is trying to valide the minimum lenght of the object.source which is comming as undefined

 

Any suggestion, how to solve this ?

 

Thanks

Siddharth

TOPICS
PDF and browsers

Views

2.3K

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 ,
Jan 30, 2023 Jan 30, 2023

Copy link to clipboard

Copied

What happens when you open the file in Acrobat Reader?

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 ,
Jan 30, 2023 Jan 30, 2023

Copy link to clipboard

Copied

Attaching a screen record of the problem.

 

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 ,
Jan 30, 2023 Jan 30, 2023

Copy link to clipboard

Copied

This happens when we save the annotations. We are using Adobe Embed API to embed the pdf reader in our application.
Using the SAVE_API, we save the annotations of the pdf to our database.
Inside that we use getAnnotations to fetch the current annotations to be saved(this is where the error is coming)
 

Below is the code:
this.adobeDCView.registerCallback(
      window.AdobeDC.View.Enum.CallbackType.SAVE_API,
      async function (metaData, content, options) {
        console.log("inside register callback")
        try {
          await previewFilePromise.then(adobeViewer => {
            adobeViewer.getAnnotationManager().then(annotationManager => {
              annotationManager.getAnnotations()
                .then(result => {
                  setNewAnnotations(result)
                  console.log('annotation:', result)
                }
                )
                .catch(error => console.log(error));
            });
          });
        } catch (e) {
          console.log(e)
        }
        return new Promise((resolve, reject) => {
          resolve({
            code: window.AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
            data: {
              metaData: { fileName: url.slice(42) }
            }
          });
        });
      },
      {
        autoSaveFrequency: 0,
        enableFocusPolling: false,
        showSaveButton: true
      }
    );

 

Documentation we followed : https://developer.adobe.com/document-services/docs/overview/pdf-embed-api/howtos_ui/#save-callback

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 ,
Jan 30, 2023 Jan 30, 2023

Copy link to clipboard

Copied

Try the forum for this API.

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 ,
Jan 30, 2023 Jan 30, 2023

Copy link to clipboard

Copied

Can you please share with us the url for forums.
It would be really helpful. Thanks in advance!

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 ,
Aug 07, 2023 Aug 07, 2023

Copy link to clipboard

Copied

LATEST

I had the same issue. What I found is that the error is not with saving the file. The error is caused in the AnnotationManager.

As a workaround I stopped listening for Annotation events - ie removed this call and the error no longer occurs. Bug in the Adobe code. 

adobeDCView.getAnnotationManager().then(annotationManager => {
                    annotationManager.registerEventListener(

 

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