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

pdfComments with commentType == UNDERLINE_TEXT_TYPE -- how to access

Explorer ,
Nov 13, 2018 Nov 13, 2018

How can I get the relevant text? (same question applies to other comment types -- replace and delete.)

I suspected commentPathGeometry -- but that just returns object no longer exists

myDoc=app.activeDocument;

i=278; // random comment -- it's underlined

    c=myDoc.pdfComments;

    $.writeln(c.commentType); // returns correct type

    $.writeln(c.commentContent); // content is blank

    $.writeln(c.commentPathGeometry); // crashes here

Thanks

TOPICS
Scripting
2.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

correct answers 1 Correct answer

Community Expert , Nov 14, 2018 Nov 14, 2018

Thanks.

Hm. Just tried explicitely this commenting type, but there is no way to show the comments on the page:

From Acrobat Pro:

UnderlineCommentsInAcrobatPro.PNG

Comments imported. No widget on the page:

UnderlineTextComment-Not-Showing-on-Page.PNG

Properties of comments:

0    commentReviewer    ADMIN

0    commentContent   

0    commentDate    Wed Nov 14 2018 17:10:46 GMT+0100

0    commentType    SQUIGGLY_TEXT_TYPE

0    commentFilePath    F:\…\UnderlineCommentImported-CC-2019-14.0.1.209-Commented.pdf

0    commentPathGeometry    Die angeforderte Aktion konnte nicht ausgeführt werde

...
Translate
Community Expert ,
Nov 14, 2018 Nov 14, 2018

Hi akiva_atwood ,

I guess that some properties are not available with certain types of comments.

What will a code snippet like the one below reveal?

var doc = app.documents[0];

var pdfCommentsArray = doc.pdfComments.everyItem().getElements();

var pdfCommentsArrayLength = pdfCommentsArray.length;

for( var n=0; n<pdfCommentsArrayLength; n++ )

{

    for( x in pdfCommentsArray)

    {

        try

        {

        $.writeln( n +"\t"+ x +"\t"+ pdfCommentsArray.toString() );

        }catch(e){ n +"\t"+ x +"\t"+ e.message }

      

    }

  

};

Regards,
Uwe

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
Explorer ,
Nov 14, 2018 Nov 14, 2018

Hi Uwe

I ran it for 5 comments to save time (getting the index takes a while):

275 commentReviewer משפחה

275 commentContent a

275 commentDate Thu Oct 25 2018 07:54:19 GMT+0300

275 commentType REPLACE_TEXT_TYPE

275 commentFilePath Macintosh HD:Users:akivaatwood:Documents:Documents - Akiva’s MacBook Air:books:Current Book Projects:Soskil:2019.pdf

275 commentStatus OPEN_STATUS

275 commentIsOrphan false

275 commentIsApplied false

275 id 11950

275 label

275 name

275 isValid true

275 parent [object Document]

275 index 275

275 properties [object Object]

275 events [object Events]

275 eventListeners [object EventListeners]

275 replies [object Replies]

275 isValid true

276 commentReviewer משפחה

276 commentContent

276 commentDate Thu Oct 25 2018 07:54:24 GMT+0300

276 commentType UNDERLINE_TEXT_TYPE

276 commentFilePath Macintosh HD:Users:akivaatwood:Documents:Documents - Akiva’s MacBook Air:books:Current Book Projects:Soskil:2019.pdf

276 commentStatus OPEN_STATUS

276 commentIsOrphan false

276 id 11958

276 label

276 name

276 isValid true

276 parent [object Document]

276 index 276

276 properties [object Object]

276 events [object Events]

276 eventListeners [object EventListeners]

276 replies [object Replies]

276 isValid true

277 commentReviewer משפחה

277 commentContent h

277 commentDate Thu Oct 25 2018 07:54:29 GMT+0300

277 commentType INSERT_TEXT_TYPE

277 commentFilePath Macintosh HD:Users:akivaatwood:Documents:Documents - Akiva’s MacBook Air:books:Current Book Projects:Soskil:2019.pdf

277 commentStatus OPEN_STATUS

277 commentIsOrphan false

277 commentIsApplied false

277 id 11971

277 label

277 name

277 isValid true

277 parent [object Document]

277 index 277

277 properties [object Object]

277 events [object Events]

277 eventListeners [object EventListeners]

277 replies [object Replies]

277 isValid true

278 commentReviewer משפחה

278 commentContent

278 commentDate Thu Oct 25 2018 07:54:35 GMT+0300

278 commentType UNDERLINE_TEXT_TYPE

278 commentFilePath Macintosh HD:Users:akivaatwood:Documents:Documents - Akiva’s MacBook Air:books:Current Book Projects:Soskil:2019.pdf

278 commentStatus OPEN_STATUS

278 commentIsOrphan false

278 id 11956

278 label

278 name

278 isValid true

278 parent [object Document]

278 index 278

278 properties [object Object]

278 events [object Events]

278 eventListeners [object EventListeners]

278 replies [object Replies]

278 isValid true

279 commentReviewer משפחה

279 commentContent

279 commentDate Thu Oct 25 2018 07:54:39 GMT+0300

279 commentType UNDERLINE_TEXT_TYPE

279 commentFilePath Macintosh HD:Users:akivaatwood:Documents:Documents - Akiva’s MacBook Air:books:Current Book Projects:Soskil:2019.pdf

279 commentStatus OPEN_STATUS

279 commentIsOrphan false

279 id 11948

279 label

279 name

279 isValid true

279 parent [object Document]

279 index 279

279 properties [object Object]

279 events [object Events]

279 eventListeners [object EventListeners]

279 replies [object Replies]

279 isValid true

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
Explorer ,
Nov 14, 2018 Nov 14, 2018

isValid seems to be repeated -- and there's no "commentPathGeometry" value

ID obviously can extract the selected text of the document from the comment -- and select the text referenced in the document.

commentPathGeometry is SUPPOSED to be an array with

Ordered array containing pathPointArray:Array of Ordered array containing anchor:Array of 2 Reals, leftDirection:Array of 2 Reals, rightDirection:Array of 2 Reals, pathOpen:Boolean.

which seems to be the only possible property that could be used to identify the text commented on.

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 ,
Nov 14, 2018 Nov 14, 2018

Hi,

I suppose that commentPathGeometry is an unfinished property ?!

Or a plain bug.

Did a new attempt with the following snippet that first collects all the results and then writes them to the JavaScript Console of the ESTK:

var doc = app.documents[0];

var pdfCommentsArray = doc.pdfComments.everyItem().getElements();

var pdfCommentsArrayLength = pdfCommentsArray.length;

var resultArray = [];

for( var n=0; n<pdfCommentsArrayLength; n++ )

{

    for( x in pdfCommentsArray)

    {

        try

        {

            resultArray[resultArray.length++] = n +"\t"+ x +"\t"+ pdfCommentsArray.toString() ;

        }catch(e)

        {

            resultArray[resultArray.length++] = n +"\t"+ x +"\t"+ e.message ;

        };

      

    };

  

};

var resultString = resultArray.join("\r");

$.writeln( resultString );

Now I can see property commentPathGeometry, but without a reasonable value; instead I had an error:

$ID/ObjectDeletedError

The German message is reading:

"Die angeforderte Aktion konnte nicht ausgeführt werden, da das Objekt nicht mehr existiert."

Translated to something like that:

"The requested action could not be accomplished, because the object does not exist anymore."

Regards,
Uwe

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
Explorer ,
Nov 14, 2018 Nov 14, 2018

That's the exact error I get.

And that's the only property I can find that would (theoretically) let a script access the document...

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 ,
Nov 14, 2018 Nov 14, 2018

Or we still did not find the right type of pdfComment where commentPathGeometry has a meaning.

Ah! Yep.There is one:

If you do a comment with the Pen Tool in Acrobat Pro DC commentPathGeometry gets an array of path point coordinates and a second boolean value, in my case set to true, because the path is open.

Something like that:

-89.2107089176879,132.560756273963,-89.2107089176879,132.560756273963,-85.514206232141,132.560756273963,-80.7967074528441,123.445674486854,-83.1674044743285,125.138972826697,-79.3483126774535,122.41106755326,-75.8886263981566,121.342158861854,-76.6847079411254,122.9341693599,-75.5751193180785,120.715083666541,-75.8886263981566,119.238673754432,-76.3844149723754,119.73446232865,-74.2445223942504,117.594569750525,-68.1759188786254,117.135158129432,-70.342819513391,117.7261615474,-60.7022250309691,115.096980639197,-62.5666049137816,114.330562182166,-64.649704279016,116.413783617713,-60.8729098454222,112.636867113807,-51.3480075016722,115.732875414588,-52.5531161442504,115.732875414588,-51.3480075016722,115.732875414588,true

An array of arrays.

Regards,
Uwe

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 ,
Nov 14, 2018 Nov 14, 2018

Forgot:

commentType is: FREEFORM_DRAWING_TYPE

Regards,
Uwe

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
Explorer ,
Nov 14, 2018 Nov 14, 2018

Interesting.

Is it possible pdfComment has other properties that aren't available?

parent would be the obvious way but that just gives the document, not the story/selected text, etc

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 ,
Nov 14, 2018 Nov 14, 2018

I would do an extensive test with all types of comments available with Acrobat Pro DC and inspect the values after import to the PDF Comments panel of an InDesign document.

FWIW: commentPathGeometry should never crash InDesign with e.g. UNDERLINE_TEXT_TYPE.

That's a bug, I think.

Regards,
Uwe

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
Explorer ,
Nov 14, 2018 Nov 14, 2018

I meant it crashes the script (unless there's a try/catch)

I need to specifically deal with UNDERLINE -- in order to Italicize the relevant text --

But I'll try other types just to see if I can figure out what's happening

Thanks
Akiva

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 ,
Nov 14, 2018 Nov 14, 2018

Hi Akiva,

I think there is no way to determine the position of a comment widget on the page.

Not with scripting.

Regards,
Uwe

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
Explorer ,
Nov 14, 2018 Nov 14, 2018

if there's no way then pdfComments is useless.

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 ,
Nov 14, 2018 Nov 14, 2018

akiva_atwood  wrote

if there's no way then pdfComments is useless.

Oh. I wouldn't say this.

What exactly did you hope to do with pdfComments?

Regards,
Uwe

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
Explorer ,
Nov 14, 2018 Nov 14, 2018

change underlined text to italics (underlining is the standard way of marking up PDFs by editors)

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 ,
Nov 14, 2018 Nov 14, 2018

Thanks.

Hm. Just tried explicitely this commenting type, but there is no way to show the comments on the page:

From Acrobat Pro:

UnderlineCommentsInAcrobatPro.PNG

Comments imported. No widget on the page:

UnderlineTextComment-Not-Showing-on-Page.PNG

Properties of comments:

0    commentReviewer    ADMIN

0    commentContent   

0    commentDate    Wed Nov 14 2018 17:10:46 GMT+0100

0    commentType    SQUIGGLY_TEXT_TYPE

0    commentFilePath    F:\…\UnderlineCommentImported-CC-2019-14.0.1.209-Commented.pdf

0    commentPathGeometry    Die angeforderte Aktion konnte nicht ausgeführt werden, da das Objekt nicht mehr existiert.

0    commentStatus    OPEN_STATUS

0    commentIsOrphan    true

0    commentIsApplied    Die angeforderte Aktion konnte nicht ausgeführt werden, da das Objekt nicht mehr existiert.

0    id    248

0    label   

0    name   

0    isValid    true

0    parent    [object Document]

0    index    0

0    properties    [object Object]

0    events    [object Events]

0    eventListeners    [object EventListeners]

0    replies    [object Replies]

0    isValid    true

1    commentReviewer    ADMIN

1    commentContent   

1    commentDate    Wed Nov 14 2018 17:15:34 GMT+0100

1    commentType    SQUIGGLY_TEXT_TYPE

1    commentFilePath    F:\…\UnderlineCommentImported-CC-2019-14.0.1.209-Commented.pdf

1    commentPathGeometry    Die angeforderte Aktion konnte nicht ausgeführt werden, da das Objekt nicht mehr existiert.

1    commentStatus    OPEN_STATUS

1    commentIsOrphan    true

1    commentIsApplied    Die angeforderte Aktion konnte nicht ausgeführt werden, da das Objekt nicht mehr existiert.

1    id    250

1    label   

1    name   

1    isValid    true

1    parent    [object Document]

1    index    1

1    properties    [object Object]

1    events    [object Events]

1    eventListeners    [object EventListeners]

1    replies    [object Replies]

1    isValid    true

Sigh. I'll file a bug report on this.

Regards,
Uwe

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
Explorer ,
Nov 14, 2018 Nov 14, 2018

In ID there should be a green underline (There is on my mac)

And when you select the comment in the panel the related text is selected

Thanks

Akiva

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
Explorer ,
Nov 14, 2018 Nov 14, 2018

Any idea why isValid is duplicated in the properties? Also a bug?

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 ,
Nov 14, 2018 Nov 14, 2018

No. You'll find isValid two times with a lot of ( every? ) object in the DOM.

Hm. You mentioned color green for underline. Could be that I customized the color with my Acrobat Pro DC. And that could be the cause that InDesign CC 2019 is not showing the widgets. Just a guess…

Regards,
Uwe

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
Explorer ,
Nov 14, 2018 Nov 14, 2018

Question> pdfComment.properties returns an object

Any way to find out what's in that object?

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 ,
Nov 14, 2018 Nov 14, 2018

You can try method toSource().

That would better show how the value of commentPathGeometry is structured as array.

But I was not able to get the enumeration value for e.g. commentType.

commentType:({})

The thing that works better is the for( x in object ) method.

commentType    FREEFORM_DRAWING_TYPE

Regards,
Uwe

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
LEGEND ,
Mar 10, 2024 Mar 10, 2024
LATEST

FDF file is required:

 

RobertTkaczyk_1-1710079557040.png

 

More play with margins is needed.

 

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