• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

app not defined Indesign CEP

New Here ,
Jan 27, 2021 Jan 27, 2021

Copy link to clipboard

Copied

Hi I hope that you're well, I'm new to CEP in Indesign (and in general) I am slightly confused to where i put the latter part of my script. I have put this into the bottom of my index.html file, but I'm not sure if this is the right place. At the moment creating an instance of CSInterface is working and I get the message it has been logged (I have done this for debugging purposes) and when the button is clicked I get the messgae it worked, however, the openDocument() function doesn't run. And when I write it through the console I get the error app not defined. I have a feeling that I need to put the last part of the script into a .jsx file but I am not sure where to put it or how to reference it. 

 

Any help would be much appreciated!

Cheers

 

<script type="text/javascript">
	/* 1) Create an instance of CSInterface. */
	var csInterface = new CSInterface();
	console.log(csInterface)
	console.log("cs interface has been logged!")

	/* 2) Make a reference to your HTML button and add a click handler. */
	var openButton = document.querySelector("#open-button");

	window.onload=function(){
		openButton.addEventListener("click", openDoc);
	}
	

	/* 3) Write a helper function to pass instructions to the ExtendScript side. */
	function openDoc() {
		console.log("It Worked")
	    csInterface.evalScript("openDocument()");
	}

	function openDocument(){
		var myDocument = app.documents.add();
		var myTextFrame = myDocument.pages.item(0).textFrames.add(); 
		myTextFrame.geometricBounds = ["6p", "6p", "24p", "24p"]; 
		myTextFrame.contents = "Hello World!";
		//console.log("hello"); 
	}
</script>

 

Views

335

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Feb 09, 2021 Feb 09, 2021

Copy link to clipboard

Copied

LATEST

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines