Differences in Paragraph/Text Style Ranges in CS3/4
I have code that exports the text from a frame into "block" and "inline" element. The code written for CS3 looks something like this below:
var doc = app.activeDocument;
var pageItems = doc.pageItems;
for (var i = 0; i < pageItems.count(); i++) {
var pageItem = pageItems.item(i);
var textFrame = pageItem;
$.writeln("Number of Paragraphs: " + textFrame.paragraphs.count());
for (var j = 0; j < textFrame.paragraphs.count(); j++) {
handleParagraph(textFrame.paragraphs.item(j), j);
}
}
function handleParagraph(para, count) {
if (para.constructor.name == "Story" ) {
$.writeln("Paragraph is a Story");
}
else {
for (var i = 0; i < para.textStyleRanges.count(); i++) {
var text = para.textStyleRanges.item(i);
$.writeln("PARAGRAPH[" + (count+1) + "] has text [" + para.contents + "]" );
}
}
}
'';
When you have 2 paragraphs of text that contain a single sentence in the default text format, this outputs something like:
Number of Paragraphs: 2
PARAGRAPH[1] has text [Paragraph 1
]
PARAGRAPH[2] has text [Paragraph 2]
However, when I run the same code against a document in CS4, I get:
Number of Paragraphs: 2
PARAGRAPH[1] has text [Paragraph 1
Paragraph 2]
PARAGRAPH[2] has text [Paragraph 2]