I haven't tested what I'm about to say, but my gut instinct is that when
you set the rectangle contentType to text, it turns into a textFrame.
Then when you place a file, perhaps it turns back into a rectangle?
At any rate, you can't "place" an image into a text frame, and you can't
have text in a rectangle.
Hope that points you in the right direction.
Thanks for Reply
I try this
Script run sucessfully with answer Execution finished. Result : Indesign
But text "Indesign" is not written in Rectangle.
To create a rectangle, change its content type and place text into - it is not a shortest way;
you can do it easier by creating a textFrame instead of rectangle;
but if it is your way from some reason:
you have to resolve rectangle after changing content type to let InDesign know about this change.
So it should be like this:
var myDocument = app.documents.add();
var myRectangle = myDocument.pages.item(0).rectangles.add();
myRectangle.geometricBounds = ["70p", "20p", "40p", "40p"];
myRectangle.contentType = ContentType.TEXT_TYPE;
var myTextFrame = resolve(myRectangle.toSpecifier());
myTextFrame.contents = "InDesign";
Its work sucessfully.
@Jump_Over Would you tell me where this function resolve() is documented, please? Can't find anywhere. It's different from the PageItem.resolve() method, right?