Copy link to clipboard
Copied
Hi ,
I want to get all paragraphs of a document(where document has table and cell and it contains some para as well)
Here is my script.
var objDoc = app.activeDocument;
var objDocName= objDoc.fullName.toString();
var par=objDoc.stories.everyItem().paragraphs.everyItem().getElements();
var paraLength=par.length;
$.writeln(paraLength);
for (j = 0; j < par.length; j++)
{
$.writeln(j);
var text = par
var endIP = par
var endTF = endIP.parentTextFrames[0];
var endCitationPage = endTF.parentPage;
var index=endCitationPage.index;
var offset=endCitationPage.documentOffset;
//~ $.writeln(text + " Page : " + endCitationPage.name);
//~ $.writeln(index);
}
This script does not give me the text which is a part of Cells.
Is there a property where we can get all the para from doc like :
var par=objDoc.paragraphs.everyItem().getElements();
Try this,
...var objDoc = app.activeDocument;
var par=objDoc.stories.everyItem().paragraphs.everyItem().getElements();
var paraLength=par.length;
$.writeln(paraLength);
var b = 0;
for (j = 0;j<par.length; j++)
{
if(par
.tables.length >=1) {
var a = j;
for(var i=0;i<par
.tables.length;i++) {
var _cells = par
.tables.cells; for(var k=0;k<_cells.length;k++)
{
Copy link to clipboard
Copied
Hi,
var curDoc = app.activeDocument;
// all paras in stories
var allStoryParas = curDoc.stories.everyItem().paragraphs.everyItem().getElements();
// all paras in tables
var allTableParas = curDoc.stories.everyItem().tables.everyItem().cells.everyItem().paragraphs.everyItem().getElements();
Notice, that you get also paras that hold the tables!
– Kai
Copy link to clipboard
Copied
Or in a single line and getting a single array as a result:
var allStoryParas = curDoc.stories.everyItem().paragraphs.everyItem().getElements().concat(curDoc.stories.everyItem().tables.everyItem().cells.everyItem().paragraphs.everyItem().getElements());
(I think Marc or Peter K. suggested this for an extremely similar question.)
This will return all regular text, followed by all paragraphs that are in tables. It will not return text inside footnotes or in tables in tables ... or, for that matter, tables inside footnotes (and tables-in-tables-in-footnotes).
Apart from using Find to literally find all text, I don't know a reliable BUT fast way to get all text. Then again, to make further useful suggestions I think we need to know what the OP is going to do with 'all text'.
Copy link to clipboard
Copied
Thanks for your help
Copy link to clipboard
Copied
Thanks
Copy link to clipboard
Copied
Try this,
var objDoc = app.activeDocument;
var par=objDoc.stories.everyItem().paragraphs.everyItem().getElements();
var paraLength=par.length;
$.writeln(paraLength);
var b = 0;
for (j = 0;j<par.length; j++)
{
if(par
.tables.length >=1) {
var a = j;
for(var i=0;i<par
.tables.length;i++) {
var _cells = par
.tables.cells; for(var k=0;k<_cells.length;k++)
{
if(_cells
.contents != "") {
$.writeln(a + k)
b = k + 1;
}
}
}
}
$.writeln(b + j);
var text = par
.contents; var endIP = par
.insertionPoints.firstItem(); var endTF = endIP.parentTextFrames[0];
var endCitationPage = endTF.parentPage;
var index=endCitationPage.index;
var offset=endCitationPage.documentOffset;
}
Regards,
Chinna
Copy link to clipboard
Copied
Thanks
Copy link to clipboard
Copied
Hi Chinnadk,
Could you please help with your solution? It is giving an error not visible for LearnIndesignScripting
Copy link to clipboard
Copied
@camilo: Check whether all your text frames are placed in InDesign pages, if the frames are in the pasteboard it will return the index value as null.
You want to ignore the error, use try/catch function.
Vandy
Copy link to clipboard
Copied
vandy, yes, after cleaning the pasteboard the script is not giving error although the output... where is placed?
I am assuming this script is intended to collect stories instead of using other traditional threading scripts that don't include cell items.
Thanks.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now