Hi all,
I have now experienced with all the character styles are lost when I apply paragraph style using "appliedParagraphStyle".
| var myText = myTextFrame.parentStory.paragraphs.item(1); | |
| myText.appliedParagraphStyle = myDocument.paragraphStyleGroups.item("Text").paragraphStyles.item("FC "); |
any idea?
Thanks
Selva
Hi Selva,
The Ariel solution its working fine, please find the below snapshot & js code.
Selva_TRM wrote:
Sorry, its not working.
Selva
var myDoc = app.activeDocument;
var myTextFrame = myDoc.textFrames[0];
var myText = myTextFrame.parentStory.paragraphs.item(1);
//var myParaStyle = myDoc.paragraphStyles.item("1");
var myParaStyle = myDoc.paragraphStyleGroups.item("Text").paragraphStyles.item("FC");
myText.applyParagraphStyle(myParaStyle, false);
thx
csm_phil
Thanks phil.
Actually i gave piece of coding. I think you got idea to see my full coding. My goal is Import images using script. So first i collect the figure captions into a text box in a document, then run my script. it import the images with caption in a new page. all are work corretly but the character sytles are missing.Below is my code.
var myDocument = app.activeDocument;
var a = Folder.selectDialog ("Choose the Folder");
var b = a.getFiles("*.*");
myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
var top = 36;
var left = 36;
var bot = 144;
var right = 144;
for (var i = 0; i <= b.length-1; i++){
var inddFileName = b[i].name;
var myTextFrame = myDocument.pages.add().textFrames.add(myDocument.layers.item("ArtTabl es"), {geometricBounds:[top, left, bot, right]});
var img = myTextFrame.parentStory.insertionPoints.item(-1).place(File(b[i]));
myTextFrame.appliedObjectStyle = myDocument.objectStyles.item("ArtPortrait");
var myTextFrame1 = myDocument.pages.item(0).textFrames.item(0).parentStory.paragraphs.it em(i);
myTextFrame.parentStory.insertionPoints.item(-1).contents = "\r"+myTextFrame1.contents;
var myText = myTextFrame.parentStory.paragraphs.item(1);
// myText.appliedParagraphStyle = myDocument.paragraphStyleGroups.item("Text").paragraphStyles.item("FC ");
// myText.applyParagraphStyle(myDocument.paragraphStyleGroups.item("Text ").paragraphStyles.item("FC"), true);
var myParaStyle = myDocument.paragraphStyleGroups.item("Text").paragraphStyles.item("FC ");
myText.applyParagraphStyle(myParaStyle, false);
myTextFrame.fit(FitOptions.frameToContent);
}
Thanks
Selva
There is nothing left to be preserved, so that's why the 'preserve overrides' trick doesn't work for you:
Selva_TRM wrote:
myTextFrame.parentStory.insertionPoints.item(-1).contents = "\r"+myTextFrame1.contents;
BAM! All your formatting is gone.
See, for instance, this recent thread for more on this: replacing text that maintains styling issue
North America
Europe, Middle East and Africa
Asia Pacific