Advertisement
Guest User

Paste Snippet from Clipboard

a guest
Apr 15th, 2015
471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PlaceSnippetFromClipboard()
  2. function PlaceSnippetFromClipboard(){
  3.     var doc = app.documents[0];
  4.     if (!doc) {
  5.         alert("No document is open or the ExtendScript editor is not connected to InDesign");
  6.         return true;
  7.     }
  8.     doc.textPreferences.typographersQuotes = false;
  9.     var tf = doc.textFrames.add();
  10.     var story = tf.parentStory;
  11.     //story.appliedLanguage = app.languagesWithVendors[0];
  12.     story.insertionPoints[0].select();
  13.     app.paste();
  14.     var str = story.contents;
  15.     if (str.indexOf("‚Äú")!=-1 || str.indexOf("Äù")!=-1 || str.indexOf("‚Äô")!=-1) {
  16.         alert("Weird quotes were found. Try saving to an .idms file and then placing it.");
  17.         //str = str.replace("‚Äù", '"');
  18.         //alert(str.substr(0,200));
  19.      }
  20.  
  21.     //alert(str);
  22.     tf.remove();
  23.     var f = File(Folder.temp + "/temp_snippet.idms");
  24.     f.encoding = "UTF-8";
  25.     f.open('w');
  26.     f.write(str);
  27.     f.close();
  28.     doc.place(f);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement