assuming your box is a inline frame
unfortunately this does not work. I receive an exception "Object does not support the property or method 'justification'".
this is what I've got:
box: [object Rectangle]
newObject: [object Image]
box.parent: [object Group]
I guess I have to somehow set the anchorXoffset of the anchored object (Image) to 0, but this is also not working:
newObject.anchoredObjectSettings.anchorXoffset = 0;
any other ideas?
@Mirko – and all of your settings, what's possible and what's going wrong (silently as well), are dependent of the anchored position of your container holding the image:
@Uwe: what is the "myImageContainer" in my case?
The anchored object.
I receive an exception at this line:
newObject.anchoredObjectSettings.anchoredPosition = AnchorPosition.ANCHORED;
Message: "undefined is not an object"
What am I doing wrong?
@Mirko – the method place() is returning an Array object.
See the documentation. Here an example for place() with the Text object:
var myInsertionPoint = myTextFrame.insertionPoints; var myArray = myInsertionPoint.place(myPDFfile,false,undefined); var myPlacedPDF = myArray.getElements(); var myPDFContainer = myPlacedPDF.parent; myPDFContainer.anchoredObjectSettings.anchoredPosition = AnchorPosition.ANCHORED;
I hope, that helps…
@Uwe: Thanks a lot for your help, but this still does not work :-(
I receive an exception a the code line: box.insertionPoints;
Error: Object does not support the property or method 'insertionPoints'
Replacing your line 02 with the following I receive the next exception: var myArray = box.place(myFile,false,undefined);
(german) Error: Diese Eigenschaft ist im aktuellen Status nicht zutreffend.
(translated) Error: This property is not applicable in the current state.
My exact code is now:
var myFile = File(path + "/" + fileName + "." + ending);
var myArray = box.place(myFile, false, undefined);
var myPlacedPDF = myArray.getElements();
var myPDFContainer = myPlacedPDF.parent;
myPDFContainer.anchoredObjectSettings.anchoredPosition = AnchorPosition.ANCHORED;
@Mirko – What I still don't know is what's behind your "box" variable.
And what you are excatly like to achieve.
Can you show the situation before/after in two screenshots doing what you want without scripting?
Hidden characters showing, frame edges showing. What is selected, if anything is selected before running your script.
If you are not working with a selection, draw in what that "box" is.
Mirko Janetzke napisał(-a):
I guess I have to somehow set the anchorXoffset of the anchored object (Image) to 0...
I am pretty sure for OP "anchored object" is just a placed image.
So there is an issue how to move graphic inside container.
If the target is newObject and it need to be move, let say, to container (box) left-up corner
//... newObject.move([ box.geometricBounds, box.geometricBounds ]); //...
Ah, you mean "box" was an empty text frame and placing the PDF to "box" was converting the text frame into a spline object?
Yes. This would be an answer.
Placing a file to a text frame, instead of using an insertion point of that text frame or its parent story, is a bit "dangerous".
1. If there is some text inside this text frame, it will be removed in the conversion process.
2. If the text frame is threaded, placing will fail altogether.
Thank you both for your help. I got it now. Mirko