Skip to main content
Participant
November 19, 2024
Question

Fetch comments, geometry on which comment is applied, giving error [the object no longer exists]

  • November 19, 2024
  • 3 replies
  • 147 views

I am using indesign version 20.0.0 ans UXP verison 8.0.1.

I want to fetch the location of comment in pdf where it is applied.

 

PdfComment's property commentPathGeometry is giving error.

Exception: Error: The requested action could not be completed because the object no longer exists. at PDFComment.invokeGetter (<anonymous>:6:32)

 

Below is the code snippet which I had used for fetching comments and screenshot of PDFComment object with exception..

 

const { entrypoints, storage } = require("uxp");
const { app } = require("indesign");

if (app.documents.length > 0) {
        const doc = app.activeDocument;
        if (doc.pdfComments.length > 0) {
          for (let i = 0; i < doc.pdfComments.length; i++) {
            const comment = doc.pdfComments.item(i);
            console.log(comment);
          }
        }
      }

 

 

This topic has been closed for replies.

3 replies

Peter Kahrel
Community Expert
Community Expert
November 20, 2024

Strange that const works in your script, because it isn't a const. But anyway, UXP thinks it's not a problem (ExtendScript correctly returns an error here).

 

But your script works fine over here. Though when I try some other properties and run the script as a UXP one, I get the same error you saw. commentPathGeometry, for instance, throws that error. Both in 2024 and 2025 on Windows. Strange situation.

Participant
November 20, 2024

It doesn't work either with var.

Peter Kahrel
Community Expert
Community Expert
November 19, 2024

In this line:

const comment = doc.pdfComments.item(i);

should const not be a var (or a let)?