sasan sepehrinejad:
//@indesign
// Automatically vertically center inline graphics
app.scriptPreferences.enableRedraw = false;
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Adjust Inline Graphics Baseline");
function main() {
var myDoc = app.activeDocument;
with (myDoc.viewPreferences){
var myOldXUnits = horizontalMeasurementUnits;
var myOldYUnits = verticalMeasurementUnits;
horizontalMeasurementUnits = MeasurementUnits.points;
verticalMeasurementUnits = MeasurementUnits.points;
}
var mySelection = app.selection[0];
if (app.selection.length == 1){
//Evaluate the selection based on its type.
switch (app.selection[0].constructor.name){
case "InsertionPoint":
case "Character":
case "Word":
case "TextStyleRange":
case "Line":
case "Paragraph":
case "TextColumn":
case "Text":
case "Story":
//The object is a text object; pass it on to a function.
myAdjustBaseline(app.selection[0]);
break;
case "TextFrame":
myAdjustBaseline(app.selection[0].texts.item(0));
break;
default:
alert("The selected object is not a text object. Select some text and try again.");
break;
}
}
function myAdjustBaseline(text){
app.findChangeGrepOptions.includeLockedLayersForFind = false;
app.findChangeGrepOptions.includeLockedStoriesForFind = false;
app.findChangeGrepOptions.includeHiddenLayers = false;
app.findChangeGrepOptions.includeMasterPages = false;
app.findChangeGrepOptions.includeFootnotes = true;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "~a";
var myFound = text.findGrep(true);
for (i=0; i < myFound.length; i++){
var myGraphicPosition = myFound[i];
if (myGraphicPosition.texts[0].pageItems[0].allGraphics[0].constructor.name == "EPS")
continue;
var myPointSize = myGraphicPosition.pointSize;
var myBounds = myGraphicPosition.texts[0].pageItems[0].geometricBounds;
var myHeight = myBounds[2] - myBounds[0];
if (myHeight >= myPointSize)
myGraphicPosition.baselineShift = -(myHeight/3);
else if (myHeight >= (0.75 * myPointSize))
myGraphicPosition.baselineShift = -(myHeight/4);
else if (myHeight >= (.6 * myPointSize))
myGraphicPosition.baselineShift = -(myHeight/5)
else if (myHeight <= (0.25 * myPointSize))
myGraphicPosition.baselineShift = (myHeight/4);
}
app.findGrepPreferences = app.changeGrepPreferences = null;
}
with (myDoc.viewPreferences){
try{
horizontalMeasurementUnits = myOldXUnits;
verticalMeasurementUnits = myOldYUnits;
}
catch(myError){
alert("Could not reset custom measurement units.");
}
}
}
//@indesign
// Automatically vertically center inline graphics
app.scriptPreferences.enableRedraw = false;
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Adjust Inline Graphics Baseline");
function main() {
var myDoc = app.activeDocument;
with (myDoc.viewPreferences){
var myOldXUnits = horizontalMeasurementUnits;
var myOldYUnits = verticalMeasurementUnits;
horizontalMeasurementUnits = MeasurementUnits.points;
verticalMeasurementUnits = MeasurementUnits.points;
}
var mySelection = app.selection[0];
if (app.selection.length == 1){
//Evaluate the selection based on its type.
switch (app.selection[0].constructor.name){
case "InsertionPoint":
case "Character":
case "Word":
case "TextStyleRange":
case "Line":
case "Paragraph":
case "TextColumn":
case "Text":
case "Story":
//The object is a text object; pass it on to a function.
myAdjustBaseline(app.selection[0]);
break;
case "TextFrame":
myAdjustBaseline(app.selection[0].texts.item(0));
break;
default:
alert("The selected object is not a text object. Select some text and try again.");
break;
}
}
function myAdjustBaseline(text){
app.findChangeGrepOptions.includeLockedLayersForFind = false;
app.findChangeGrepOptions.includeLockedStoriesForFind = false;
app.findChangeGrepOptions.includeHiddenLayers = false;
app.findChangeGrepOptions.includeMasterPages = false;
app.findChangeGrepOptions.includeFootnotes = true;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "~a";
var myFound = text.findGrep(true);
for (i=0; i < myFound.length; i++){
var myGraphicPosition = myFound[i];
if (myGraphicPosition.texts[0].pageItems[0].allGraphics[0].constructor.name == "EPS")
continue;
var myPointSize = myGraphicPosition.pointSize;
var myBounds = myGraphicPosition.texts[0].pageItems[0].geometricBounds;
var myHeight = myBounds[2] - myBounds[0];
if (myHeight >= myPointSize)
myGraphicPosition.baselineShift = -(myHeight/3);
else if (myHeight >= (0.75 * myPointSize))
myGraphicPosition.baselineShift = -(myHeight/4);
else if (myHeight >= (.6 * myPointSize))
myGraphicPosition.baselineShift = -(myHeight/5)
else if (myHeight <= (0.25 * myPointSize))
myGraphicPosition.baselineShift = (myHeight/4);
}
app.findGrepPreferences = app.changeGrepPreferences = null;
}
with (myDoc.viewPreferences){
try{
horizontalMeasurementUnits = myOldXUnits;
verticalMeasurementUnits = myOldYUnits;
}
catch(myError){
alert("Could not reset custom measurement units.");
}
}
}
//@indesign
// Automatically vertically center inline graphics
app.scriptPreferences.enableRedraw = false;
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Adjust Inline Graphics Baseline");
function main() {
var myDoc = app.activeDocument;
with (myDoc.viewPreferences){
var myOldXUnits = horizontalMeasurementUnits;
var myOldYUnits = verticalMeasurementUnits;
horizontalMeasurementUnits = MeasurementUnits.points;
verticalMeasurementUnits = MeasurementUnits.points;
}
var mySelection = app.selection[0];
if (app.selection.length == 1){
//Evaluate the selection based on its type.
switch (app.selection[0].constructor.name){
case "InsertionPoint":
case "Character":
case "Word":
case "TextStyleRange":
case "Line":
case "Paragraph":
case "TextColumn":
case "Text":
case "Story":
//The object is a text object; pass it on to a function.
myAdjustBaseline(app.selection[0]);
break;
case "TextFrame":
myAdjustBaseline(app.selection[0].texts.item(0));
break;
default:
alert("The selected object is not a text object. Select some text and try again.");
break;
}
}
function myAdjustBaseline(text){
app.findChangeGrepOptions.includeLockedLayersForFind = false;
app.findChangeGrepOptions.includeLockedStoriesForFind = false;
app.findChangeGrepOptions.includeHiddenLayers = false;
app.findChangeGrepOptions.includeMasterPages = false;
app.findChangeGrepOptions.includeFootnotes = true;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "~a";
var myFound = text.findGrep(true);
for (i=0; i < myFound.length; i++){
var myGraphicPosition = myFound[i];
if (myGraphicPosition.texts[0].pageItems[0].allGraphics[0].constructor.name == "EPS")
continue;
var myPointSize = myGraphicPosition.pointSize;
var myBounds = myGraphicPosition.texts[0].pageItems[0].geometricBounds;
var myHeight = myBounds[2] - myBounds[0];
if (myHeight >= myPointSize)
myGraphicPosition.baselineShift = -(myHeight/3);
else if (myHeight >= (0.75 * myPointSize))
myGraphicPosition.baselineShift = -(myHeight/4);
else if (myHeight >= (.6 * myPointSize))
myGraphicPosition.baselineShift = -(myHeight/5)
else if (myHeight <= (0.25 * myPointSize))
myGraphicPosition.baselineShift = (myHeight/4);
}
app.findGrepPreferences = app.changeGrepPreferences = null;
}
with (myDoc.viewPreferences){
try{
horizontalMeasurementUnits = myOldXUnits;
verticalMeasurementUnits = myOldYUnits;
}
catch(myError){
alert("Could not reset custom measurement units.");
}
}
}
// Automatically vertically center inline graphics
app.scriptPreferences.enableRedraw = false;
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Adjust Inline Graphics Baseline");
function main() {
var myDoc = app.activeDocument;
with (myDoc.viewPreferences){
var myOldXUnits = horizontalMeasurementUnits;
var myOldYUnits = verticalMeasurementUnits;
horizontalMeasurementUnits = MeasurementUnits.points;
verticalMeasurementUnits = MeasurementUnits.points;
}
var mySelection = app.selection[0];
if (app.selection.length == 1){
//Evaluate the selection based on its type.
switch (app.selection[0].constructor.name){
case "InsertionPoint":
case "Character":
case "Word":
case "TextStyleRange":
case "Line":
case "Paragraph":
case "TextColumn":
case "Text":
case "Story":
//The object is a text object; pass it on to a function.
myAdjustBaseline(app.selection[0]);
break;
case "TextFrame":
myAdjustBaseline(app.selection[0].texts.item(0));
break;
default:
alert("The selected object is not a text object. Select some text and try again.");
break;
}
}
function myAdjustBaseline(text){
app.findChangeGrepOptions.includeLockedLayersForFind = false;
app.findChangeGrepOptions.includeLockedStoriesForFind = false;
app.findChangeGrepOptions.includeHiddenLayers = false;
app.findChangeGrepOptions.includeMasterPages = false;
app.findChangeGrepOptions.includeFootnotes = true;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "~a";
var myFound = text.findGrep(true);
for (i=0; i < myFound.length; i++){
var myGraphicPosition = myFound[i];
if (myGraphicPosition.texts[0].pageItems[0].allGraphics[0].constructor.name == "EPS")
continue;
var myPointSize = myGraphicPosition.pointSize;
var myBounds = myGraphicPosition.texts[0].pageItems[0].geometricBounds;
var myHeight = myBounds[2] - myBounds[0];
if (myHeight >= myPointSize)
myGraphicPosition.baselineShift = -(myHeight/3);
else if (myHeight >= (0.75 * myPointSize))
myGraphicPosition.baselineShift = -(myHeight/4);
else if (myHeight >= (.6 * myPointSize))
myGraphicPosition.baselineShift = -(myHeight/5)
else if (myHeight <= (0.25 * myPointSize))
myGraphicPosition.baselineShift = (myHeight/4);
}
app.findGrepPreferences = app.changeGrepPreferences = null;
}
with (myDoc.viewPreferences){
try{
horizontalMeasurementUnits = myOldXUnits;
verticalMeasurementUnits = myOldYUnits;
}
catch(myError){
alert("Could not reset custom measurement units.");
}
}
}
طریقه ایجاد section
حتما پیش آمده کتاب هایی را دیدید که به طور مثال 10 صفحه اول کتاب یا شماره صفحه نداشته یا مدل شماره گذاری آن با بقیه صفحات فرق داشته است. برای درک بهتر فرض کنید 10 صفحه ابتدایی کتاب؛ که معرفی و فهرست مطالب است با شماره های یونانی نام گذاری شده و از صفحه شروع مقدمه از شماره 1 نام گذاری شده است.
برای ایجاد این مدل از شماره گذاری شما نیاز دارید از Section استفاده کنید.
حال بیایید شروع کنیم انجام دهیم: ابتدا پنل Pages را باز کنید میبینید که در بالای صفحه اول یک مثلث کوچک برعکس است. از طریق ایجاد همین مثلث ها می توانیم Section ایجاد کنیم اگر دقت کنید مشاهده میفرمایید که در کل صفحات داخل پنل فقط یک عدد از این مثلث ها میباشد این یعنی سند شما در حال حاضردارای یک Section است. برای ایجاد یک Section جدید بر روی هر صفحه ای از پنل Pages که میخواهید Section بعدی را اضافه کنید راست کلیک بفرمایید و گزینه Numbering & Section Option را انتخاب کنید. در صفحه باز شده تیک گزینه Start Section را زده و در پایان OK کنید. تبریک عرض میکنم!! اکنون سند شما دارای دو بخش یا Section شده است، اما کار اصلی ازین جا شروع میشود زیرا فقط ایجاد Section کافی نیست حال باید کاری انجام دهید که بخاطر آن Section ایجاد کرده اید یعنی تغییر استایل شماره صفحات در قسمتی از سند که میخواهید. با اجازه ازین جا به بعد سخن را کوتاه کرده و برای اینکه کمتر خسته تان بکنم و درک مطلب نیز برایتان آسانتر شود بر روی شکل توضیح میدهم. اما قبل از آن روی مثلث ایجاد شده دبل کلیک نمایید تا پنجره مذکور دوباره بازشود و باقی تنظیمات را توضیح دهیم.
حتما پیش آمده کتاب هایی را دیدید که به طور مثال 10 صفحه اول کتاب یا شماره صفحه نداشته یا مدل شماره گذاری آن با بقیه صفحات فرق داشته است. برای درک بهتر فرض کنید 10 صفحه ابتدایی کتاب؛ که معرفی و فهرست مطالب است با شماره های یونانی نام گذاری شده و از صفحه شروع مقدمه از شماره 1 نام گذاری شده است.
برای ایجاد این مدل از شماره گذاری شما نیاز دارید از Section استفاده کنید.
حال بیایید شروع کنیم انجام دهیم: ابتدا پنل Pages را باز کنید میبینید که در بالای صفحه اول یک مثلث کوچک برعکس است. از طریق ایجاد همین مثلث ها می توانیم Section ایجاد کنیم اگر دقت کنید مشاهده میفرمایید که در کل صفحات داخل پنل فقط یک عدد از این مثلث ها میباشد این یعنی سند شما در حال حاضردارای یک Section است. برای ایجاد یک Section جدید بر روی هر صفحه ای از پنل Pages که میخواهید Section بعدی را اضافه کنید راست کلیک بفرمایید و گزینه Numbering & Section Option را انتخاب کنید. در صفحه باز شده تیک گزینه Start Section را زده و در پایان OK کنید. تبریک عرض میکنم!! اکنون سند شما دارای دو بخش یا Section شده است، اما کار اصلی ازین جا شروع میشود زیرا فقط ایجاد Section کافی نیست حال باید کاری انجام دهید که بخاطر آن Section ایجاد کرده اید یعنی تغییر استایل شماره صفحات در قسمتی از سند که میخواهید. با اجازه ازین جا به بعد سخن را کوتاه کرده و برای اینکه کمتر خسته تان بکنم و درک مطلب نیز برایتان آسانتر شود بر روی شکل توضیح میدهم. اما قبل از آن روی مثلث ایجاد شده دبل کلیک نمایید تا پنجره مذکور دوباره بازشود و باقی تنظیمات را توضیح دهیم.