grefel
11/18/2015 - 3:39 PM

Read clipboard contents with InDesign

Read clipboard contents with InDesign

try {
	var pstwp = app.clipboardPreferences.preferStyledTextWhenPasting;
	app.clipboardPreferences.preferStyledTextWhenPasting = false;
	var doc = app.documents[0];
	var typoQ = doc.textPreferences.typographersQuotes;
	doc.textPreferences.typographersQuotes = false;

	var tf = doc.textFrames.add();
	tf.insertionPoints[-1].select();
	app.paste();

	var clipboard = tf.parentStory.contents;
	$.writeln(clipboard);
}
catch (e) {
	alert (e + " \nLine " + e.line);	
}
finally {
	app.clipboardPreferences.preferStyledTextWhenPasting = pstwp;
	doc.textPreferences.typographersQuotes = typoQ;
}