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

processing instructions paragraphs

Community Beginner ,
Aug 03, 2017 Aug 03, 2017

Copy link to clipboard

Copied

I need to store some value for each and every paragraphs in the file.

Any user defined property available for paragraphs.

TOPICS
Scripting

Views

711

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 Beginner ,
Aug 03, 2017 Aug 03, 2017

Copy link to clipboard

Copied

Need a bit more information.

Are you wanting to make a data file with some unique value for each paragraph? Or append a unique value to the end of paragraph for identification purposes?

A text frame can have multiple paragraphs as well (plus hard and soft return paragraphs present another issue), do you need the id of the text frame each and every paragraph is associated with as well?

What is the end goal for such a script? What will and how will this be used?

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 Beginner ,
Aug 03, 2017 Aug 03, 2017

Copy link to clipboard

Copied

I want to append a unique value to the end of paragraph for identification purposes

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 ,
Aug 04, 2017 Aug 04, 2017

Copy link to clipboard

Copied

Hi,

you could add a Note object.


See into this:

Adobe InDesign CS6 (8.0) Object Model JS: Note

Adobe InDesign CS6 (8.0) Object Model JS: Notes

Two ways to go:

1. Your unique value could be stored to the label property of the Note object. Use note.insertLabel( "keystring" , "valuestring") for providing a string. Read out its value by using note.extractLabel( "keystring" ) .


2. You can even add formatted text ( plus anchored frames etc.pp.) with the Note object itself.
Just provide some text in a text frame and move or duplicate it to the note.

Whatever fit your needs.

Search the forum for some code adding and using note objects to an insertion point.

Regards,
Uwe

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 ,
Aug 04, 2017 Aug 04, 2017

Copy link to clipboard

Copied

Here a snippet that will add a Note object to the end of a paragraph.
Just select an insertion point and run the snippet:

// Insertion point of some text selected:

var paragraph = app.selection[0].paragraphs[0];

// Two cases:

// 1. Paragraph ends with a paragraph marker:

if(paragraph.characters[-1].contents == "\r")

{

    var lastInsertionPoint = paragraph.insertionPoints[-2];

}

else

// 2. Paragraph does not end with a paragraph marker:

{

    var lastInsertionPoint = paragraph.insertionPoints[-1];

}

// Add a note at last insertion point:

var note = lastInsertionPoint.notes.add({ collapsed : false });

// Add some instructions inside the note, that can be read in Story Editor Window:

note.texts[0].contents =

Date.now().toString() +"\r"+

"Processing Instruction: Do something with that paragraph!";

If you open the the text in Story Window you'll see this:

NoteAddedToParagraph.png

One could debate if Date.now().toString() will create a unique string, but for the moment it will fit.

Regards,
Uwe

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 ,
Aug 04, 2017 Aug 04, 2017

Copy link to clipboard

Copied

The id of the note itself is guaranteed to be unique, right?

(I was thinking of its index first, but the id is even better, as in the document model every single object must have a unique id, guaranteed to occur never elsewhere, in the current document.

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 ,
Aug 05, 2017 Aug 05, 2017

Copy link to clipboard

Copied

LATEST

https://forums.adobe.com/people/%5BJongware%5D  wrote

The id of the note itself is guaranteed to be unique, right? …

Wrong.
It's only unique in the scope of that particular document.

Regards,
Uwe

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 Beginner ,
Aug 05, 2017 Aug 05, 2017

Copy link to clipboard

Copied

good

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