Copy link to clipboard
Copied
Hello,
I need help for two questions.
1) How to add paragraph (note) numbers related to the specific Paragraph style in to the master page? Please check the sample pages I attached ID and PDF. When this paragraph style found in three times in a single page, it should show all numbers like it show in PDF. And they should be automatically updatable.
If it is possible, then try to show fist and the last numbers only?
2. Anybody know, the shortcut to apply Text anchor? I need to select the word and press the shortcut to apply text anchor. Because I have to add lot of text anchors.
I am very greatfull to your kind attention about this matter.
Thank you.
Try this update:
app.doScript(Main, undefined, undefined, UndoModes.ENTIRE_SCRIPT,"Run Script");
function Main(){
// Declare variables
var myDoc = app.activeDocument;
var myPages = myDoc.pages;
var myPage;
var myFrames;
var myFrame;
var myParas;
var myPara;
var headerStyle = myDoc.paragraphStyles.item("Note_para");
var marginNumberParaStyle;
var marginNumberObjStyle;
var noteNumber;
var ip;
// If "Margin_number" para style doesn't exist, create it
if(myDoc.paragraphStyles.item("Margin_number")
...
Copy link to clipboard
Copied
Anybody have any iea about my above post? Please let me know it's posible or not.
Thanks.
Copy link to clipboard
Copied
1. In the paragraph style, go to the Bullets and Numbering tab and select the following options:
2. You can create your own keyboard shortcuts!
Copy link to clipboard
Copied
danaken3,
Thanks for your guide.
Somehow your first answer was based on a little misunderstanding.
Auto numbering to paragraph style is OK to me. But I want to use that paragraph style in masterpage to create text variable like running header. But it needs to show paragraph number only. I have an experience about use text variable to make first on the page, and last on the page. (Dictionaries use this methord mostly) But here I need to show all paragraph numbers of the page. Doesn't matter paragraph's are auto numbered or not. Please see the PDF and ID file I attached.
And thanks for your second answer about showrtcut key. It works well !!!!!!
Copy link to clipboard
Copied
I don't know of an easy way to do that. The only thing I can think of is the following:
Copy link to clipboard
Copied
If someone can give a solution for my first question, please let me know.
I explain it here again,
I have notes with numbers and I style them as a paragraph style.
I want to show all note numbers in each page in outer margin.
That means, if a page 05 found note number 5,6 and 7, then I want to show them in outer margin of the page 05. I want to do that automatically. I know that running variable with a character style can use for the first an the last. But I need all of the page. This is a big book and I want to do that automatically and smart.
Thanks for all your efforts.
Copy link to clipboard
Copied
The following script will set up an object style and paragraph style for the margin numbers (mimicking the format from your template) and will insert the numbers automatically (as an anchored object). If you want to update the appearance/position of the margin numbers, edit the paragraph style and/or object style.
The margin numbers will not automatically update when your pages shift; however, you can run the same script again and it will delete the existing margin numbers and insert new ones. Let me know if you run into any issues.
app.doScript(Main, undefined, undefined, UndoModes.ENTIRE_SCRIPT,"Run Script");
function Main(){
// Declare variables
var myDoc = app.activeDocument;
var myPages = myDoc.pages;
var myPage;
var myFrames;
var myFrame;
var myParas;
var myPara;
var headerStyle = myDoc.paragraphStyles.item("Note_para");
var marginNumberParaStyle;
var marginNumberObjStyle;
var noteNumber;
var ip;
// If "Margin_number" para style doesn't exist, create it
if(myDoc.paragraphStyles.item("Margin_number") == null) {
var paraProps = {
name: "Margin_number",
appliedFont: "Minion Pro",
basedOn: myDoc.paragraphStyles.item("[No Paragraph Style]"),
fillColor: myDoc.swatches.itemByName("Paper"),
fontStyle: "Regular",
justification: Justification.CENTER_ALIGN,
leading: Leading.AUTO,
paragraphShadingBottomOffset: "0p1",
paragraphShadingColor: myDoc.swatches.itemByName("C=75 M=5 Y=100 K=0"),
paragraphShadingOn: true,
paragraphShadingTint: 100,
paragraphShadingTopOffset: "0p5",
paragraphShadingWidth: ParagraphShadingWidthEnum.COLUMN_WIDTH,
pointSize: 14,
spaceAfter: "0p7.5"
};
myDoc.paragraphStyles.add(paraProps);
}
marginNumberParaStyle = myDoc.paragraphStyles.item("Margin_number");
// If "Margin_number" object style doesn't exist, create it
if(myDoc.objectStyles.itemByName("Margin_number") == null) {
var objProps = {
name: "Margin_number",
anchoredObjectSettings: {
anchorPoint: AnchorPoint.BOTTOM_RIGHT_ANCHOR,
anchorXoffset: "2p9",
anchorYoffset: "-0p5",
anchoredPosition: AnchorPosition.ANCHORED,
horizontalReferencePoint: AnchoredRelativeTo.PAGE_MARGINS,
spineRelative: true,
verticalReferencePoint: AnchoredRelativeTo.PAGE_MARGINS
},
appliedParagraphStyle: marginNumberParaStyle,
basedOn: myDoc.objectStyles.itemByName("[None]"),
enableAnchoredObjectOptions: true,
enableParagraphStyle: true,
enableStroke: false,
enableTextFrameAutoSizingOptions: true,
enableTextFrameGeneralOptions: true,
enableTransformAttributes: true,
textFramePreferences: {
autoSizingReferencePoint: AutoSizingReferenceEnum.BOTTOM_CENTER_POINT,
autoSizingType: AutoSizingTypeEnum.HEIGHT_AND_WIDTH,
minimumWidthForAutoSizing: "1p8",
useMinimumWidthForAutoSizing: true,
verticalJustification: VerticalJustification.BOTTOM_ALIGN
}
};
myDoc.objectStyles.add(objProps);
}
var marginNumberObjStyle = myDoc.objectStyles.itemByName("Margin_number");
// Delete all text frames with "Margin_number" object style applied
app.findObjectPreferences.appliedObjectStyles = marginNumberObjStyle;
var objectList = myDoc.findObject();
if (objectList.length >0) {
for (var i=objectList.length-1; i>=0; i--) {
objectList[i].remove();
}
alert("Deleted all existing margin numbers.");
}
// Loop through pages
for (var i=0; i<myPages.length; i++) {
myPage = myPages[i];
var noteNumbers = null;
// Loop through text frames
myFrames = myPage.textFrames;
for (var j=myFrames.length-1; j>=0; j--) {
myFrame = myFrames[j];
// Loop through paragraphs
myParas = myFrame.paragraphs;
for (var k=0; k<myParas.length; k++) {
myPara = myParas[k];
// Check if para has header style applied
if (myPara.appliedParagraphStyle == headerStyle) {
ip = myPara.insertionPoints[0];
// Get paragraph's number and add it to noteNumbers string
try {
noteNumber = myPara.numberingResultNumber.toString();
if(noteNumbers==null) {
noteNumbers = noteNumber;
}
else noteNumbers = noteNumbers.concat("\r" + noteNumber);
}
catch(err) {
}
}
}
}
// Create text frame and add noteNumbers string
if (noteNumbers != null) {
myTextFrame = ip.textFrames.add();
myTextFrame.appliedObjectStyle = marginNumberObjStyle;
myTextFrame.contents = noteNumbers;
}
}
alert ("Script complete");
}
Copy link to clipboard
Copied
Marvelous !!!!!! You are super creative....
This works fine.... Thank you very much danaken3.
And another little thing came to my mind to develop this, and also very usefull to all.
If you can try to behave margin numbers like running headers. That means, if note number 3 starting from page 2 and it continue upto page 4, then page 2 and 3 also need to show note number 3 on the margin. Normally running headers doing that.
Is it possible ?
Somehow you make my works so easy...... Thanks again and again........
Copy link to clipboard
Copied
Try this update:
app.doScript(Main, undefined, undefined, UndoModes.ENTIRE_SCRIPT,"Run Script");
function Main(){
// Declare variables
var myDoc = app.activeDocument;
var myPages = myDoc.pages;
var myPage;
var myFrames;
var myFrame;
var myParas;
var myPara;
var headerStyle = myDoc.paragraphStyles.item("Note_para");
var marginNumberParaStyle;
var marginNumberObjStyle;
var noteNumber;
var ip;
// If "Margin_number" para style doesn't exist, create it
if(myDoc.paragraphStyles.item("Margin_number") == null) {
var paraProps = {
name: "Margin_number",
appliedFont: "Minion Pro",
basedOn: myDoc.paragraphStyles.item("[No Paragraph Style]"),
fillColor: myDoc.swatches.itemByName("Paper"),
fontStyle: "Regular",
justification: Justification.CENTER_ALIGN,
leading: Leading.AUTO,
paragraphShadingBottomOffset: "0p1",
paragraphShadingColor: myDoc.swatches.itemByName("C=75 M=5 Y=100 K=0"),
paragraphShadingOn: true,
paragraphShadingTint: 100,
paragraphShadingTopOffset: "0p5",
paragraphShadingWidth: ParagraphShadingWidthEnum.COLUMN_WIDTH,
pointSize: 14,
spaceAfter: "0p7.5"
};
myDoc.paragraphStyles.add(paraProps);
}
marginNumberParaStyle = myDoc.paragraphStyles.item("Margin_number");
// If "Margin_number" object style doesn't exist, create it
if(myDoc.objectStyles.itemByName("Margin_number") == null) {
var objProps = {
name: "Margin_number",
anchoredObjectSettings: {
anchorPoint: AnchorPoint.BOTTOM_RIGHT_ANCHOR,
anchorXoffset: "2p9",
anchorYoffset: "-0p5",
anchoredPosition: AnchorPosition.ANCHORED,
horizontalReferencePoint: AnchoredRelativeTo.PAGE_MARGINS,
spineRelative: true,
verticalReferencePoint: AnchoredRelativeTo.PAGE_MARGINS
},
appliedParagraphStyle: marginNumberParaStyle,
basedOn: myDoc.objectStyles.itemByName("[None]"),
enableAnchoredObjectOptions: true,
enableParagraphStyle: true,
enableStroke: false,
enableTextFrameAutoSizingOptions: true,
enableTextFrameGeneralOptions: true,
enableTransformAttributes: true,
textFramePreferences: {
autoSizingReferencePoint: AutoSizingReferenceEnum.BOTTOM_CENTER_POINT,
autoSizingType: AutoSizingTypeEnum.HEIGHT_AND_WIDTH,
minimumWidthForAutoSizing: "1p8",
useMinimumWidthForAutoSizing: true,
verticalJustification: VerticalJustification.BOTTOM_ALIGN
}
};
myDoc.objectStyles.add(objProps);
}
marginNumberObjStyle = myDoc.objectStyles.itemByName("Margin_number");
// Delete all text frames with "Margin_number" object style applied
app.findObjectPreferences.appliedObjectStyles = marginNumberObjStyle;
var objectList = myDoc.findObject();
if (objectList.length >0) {
for (var i=objectList.length-1; i>=0; i--) {
objectList[i].remove();
}
alert("Deleted all existing margin numbers.");
}
// Loop through pages
for (var i=0; i<myPages.length; i++) {
myPage = myPages[i];
var noteNumbers = null;
if (!myPage.textFrames) {
break;
}
// Loop through text frames
myFrames = myPage.textFrames;
for (var j=myFrames.length-1; j>=0; j--) {
myFrame = myFrames[j];
// Loop through paragraphs
myParas = myFrame.paragraphs;
for (var k=0; k<myParas.length; k++) {
myPara = myParas[k];
// Check if para has header style applied
if (myPara.appliedParagraphStyle == headerStyle) {
ip = myPara.insertionPoints[0];
// Get paragraph's number and add it to noteNumbers string
try {
noteNumber = myPara.numberingResultNumber.toString();
if(noteNumbers==null) {
noteNumbers = noteNumber;
}
else noteNumbers = noteNumbers.concat("\r" + noteNumber);
}
catch(err) {
}
}
}
}
// If no paras on pg. are header, use final para as insertion point
if (ip==null && myPara != null) {
ip = myPara.insertionPoints[0];
}
// Create text frame and add noteNumbers string
if (ip!=null){
myTextFrame = ip.textFrames.add();
myTextFrame.appliedObjectStyle = marginNumberObjStyle;
if (noteNumbers != null) {
myTextFrame.contents = noteNumbers;
}
// If no paras on pg. are header, insert last note number of prev. pg.
else if (noteNumber != null) {
myTextFrame.contents = noteNumber;
}
}
// Reset insertion point variable to null
ip = null;
}
alert ("Script complete");
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now