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

cut paste image

Guest
Aug 31, 2011 Aug 31, 2011

Copy link to clipboard

Copied

Hi,

Is there a way we can cut paste an image rectangle into a text frame without using app.cut() & app.paste() ?

Thanks,

TOPICS
Scripting

Views

953
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
Contributor ,
Aug 31, 2011 Aug 31, 2011

Copy link to clipboard

Copied

Hi

Is what you want do create Anchored Object without using cut() and paste()

try this code.

/** *  without using cut() and paste() * * env> * a document has one textframe and graphicframe(rectangle) * */ var doc = app.documents[0]; var org = doc.rectangles[0];// has an image var tf = doc.textFrames[0]; var dup = tf.parentStory.insertionPoints[-1].rectangles.add(); for (var j in org.properties) {   try {     dup = org.properties;   }   catch(e){} }; var relative_posi = [   dup.geometricBounds[1] - org.geometricBounds[1],   dup.geometricBounds[0] - org.geometricBounds[0] ]; dup.place(org.graphics[0].itemLink.filePath); for (var i in org.graphics[0].properties) {   try {     dup.graphics[0] = org.graphics[0].properties;   }   catch(e){} }; dup.graphics[0].move(undefined, relative_posi); // if you want move! // org.remove();

thank you

mg

Votes

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
Guest
Sep 15, 2011 Sep 15, 2011

Copy link to clipboard

Copied

That is fine. But not working with documents created elsewhere. It throw the exception 'Can not find the folder --'. This is because it looks for the image path from where the image has been originaly placed. Is there any other alternatives?

Thanks.

Votes

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
Contributor ,
Sep 16, 2011 Sep 16, 2011

Copy link to clipboard

Copied

LATEST

Hi.

is your operation system "Windows"?

try this code

var doc = app.documents[0]; var org = doc.rectangles[0];// has an image var tf = doc.textFrames[0]; // bigger than image var dup = tf.parentStory.insertionPoints[-1].rectangles.add(); for (var j in org.properties) {   try {     dup = org.properties;   }   catch(e){} }; var relative_posi = [   dup.geometricBounds[1] - org.geometricBounds[1],   dup.geometricBounds[0] - org.geometricBounds[0] ]; // mac or win? if (Folder.fs === "Macintosh") {   dup.place(org.graphics[0].itemLink.filePath); } else {   dup.place(encodeURI(File(org.itemLink.filePath).fullName); } for (var i in org.graphics[0].properties) {   try {     dup.graphics[0] = org.graphics[0].properties;   }   catch(e){} }; dup.graphics[0].move(undefined, relative_posi);

Votes

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