m1bCorrect answer
Community Expert
Sep 20, 2025 4:40 AM UTC
It isn't that complicated. You don't need `getGraphics` function if you already have the graphic some other way. You can move the `intersection` logic inside the `intersectionOfGraphicFrame` function. The whole thing—minus the checking and getting—boils down to this one operation:
graphic.parent.geometricBounds = [
graphic.geometricBounds[0] > graphic.parent.geometricBounds[0] ? graphic.geometricBounds[0] : graphic.parent.geometricBounds[0],
graphic.geometricBounds[1] > graphic.parent.geometricBounds[1] ? graphic.geometricBounds[1] : graphic.parent.geometricBounds[1],
graphic.geometricBounds[2] < graphic.parent.geometricBounds[2] ? graphic.geometricBounds[2] : graphic.parent.geometricBounds[2],
graphic.geometricBounds[3] < graphic.parent.geometricBounds[3] ? graphic.geometricBounds[3] : graphic.parent.geometricBounds[3],
];
The larger issue is you don't always do a very good job of giving us examples that cover all your needs. The code I wrote works perfectly on your example document. But now you are talking about the `fit` method—which has nothing to do with your example. I know it can be hard., but try to supply examples that cover all your cases.
- Mark

