Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert image into selected frame #5

Closed
robertjiang77 opened this issue Nov 18, 2019 · 3 comments
Closed

Insert image into selected frame #5

robertjiang77 opened this issue Nov 18, 2019 · 3 comments
Labels

Comments

@robertjiang77
Copy link

Hi Lohrrialo,

I need to insert an image (png/jpg) into a frame. But I am struggling with how to read the image in. Could you kindly review the below code and show me a way to fix it?

app = win32com.client.Dispatch('InDesign.Application.CC.2019')
myInddFile = r'C:\Users\zhijia\Documents\Robertjiang\Tracker\In-Design Project\Tracker Template_test_old.indd'
myDocument = app.Open(myInddFile)
myPage = myDocument.Pages.Item(1)

myRectangle = myPage.Rectangles.Add()
myRectangle.GeometricBounds = ["6p", "6p", "18p", "18p"]
myRectangle.StrokeWeight = 0
myRectangle.place('C:\Users\zhijia\Documents\Robertjiang\Tracker\In-Design Project\AA.jpg'')

The problem occurred at the end line of the above code.
What I need is to

  1. place a picture into the rectangle frame
  2. and then fit content to frame.

Could you kindly teach me how to achieve both in python please?

Great thanks!

@robertjiang77
Copy link
Author

Hi Lohrii, could you kindly show me how to solve the problem? I tried to read in the image by Plotly but the place function doesn't work. Should I use the PlaceIntoFrame function? Please help, thanks!

@lohriialo
Copy link
Owner

@robertjiang77 the place method should start with an upper case myRectangle.Place()
See, scripting reference line #64592

@lohriialo
Copy link
Owner

And to fit content to frame

idContentToFrame = 1668575078   # from enum idFitOptions
myRectangle.Fit(idContentToFrame)

See, scripting reference line #802

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants