-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Mallikarjun H T edited this page Aug 13, 2021
·
1 revision
Welcome to the Csharp-Adobe-Automation with Mallikarjun!
// instance of application (InDesign)
Type t = Type.GetTypeFromProgID("InDesign.Application");
InDesign.Application application = (InDesign.Application)Activator.CreateInstance(t);
// Create a document
Document doc = application.Documents.Add(false);//savig document
doc.Save("Folder\\File_Name.indd", false, "Comments here", false);// add frame to page
page.TextFrames.Add();
InDesign.TextFrame frames = (InDesign.TextFrame)page.TextFrames.FirstItem();
// set x,y and width, height for box
frames.GeometricBounds = new string[4] { "4p", "4p", "62p", "47p" };//place document to page
page.Place("Folder\\File_Name.docx", page ,layer, false, true);
//place document to frame
frames.Place("file path of the document", false);application.DoScript(@"Path to script \scripts\FindChangeByList.jsx", InDesign.idScriptLanguage.idJavascript);// apply grep to document
InDesign.FindGrepPreference findGrepPreference = (InDesign.FindGrepPreference)application.FindGrepPreferences;
findGrepPreference.FindWhat = "([\\S]+[.][\\S]+)";
InDesign.ChangeGrepPreference changeText = (InDesign.ChangeGrepPreference)application.ChangeGrepPreferences;
changeText.AppliedCharacterStyle = "[No character style]";
var results = doc.FindGrep();
doc.ChangeGrep();
// creating style object
InDesign.ParagraphStyle paragraphStyle = paragraph.AppliedParagraphStyle;
paragraphStyle.Name = "Title Center";
paragraphStyle.AppliedFont = "Sans";
paragraphStyle.FontStyle = "Bold";
paragraphStyle.Justification = InDesign.idJustification.idCenterAlign;
paragraphStyle.PointSize = 7;
paragraphStyle.Leading = 8.4;
paragraphStyle.SpaceAfter = 0.05;
paragraphStyle.Hyphenation = false;
// apply para style
paragraph.AppliedParagraphStyle = paragraphStyle;InDesign.Character characters = (InDesign.Character)paragraph.Characters[i];
if (characters.FontStyle == "Bold"){
characters.FontStyle = "Bold";
characters.AppliedFont = "Sans";
}