How do I place an image in a text frame using javascript in Indesign? -


i making scripted community directory, , using script labels find text boxes , fill them appropriate information json file. problem having cannot figure out how place image frame have reference to. filepath in json file, , know exists. know how load file , replace contents of box image have. also, if image fitted size of box, how work?

so have text frame (filled data) , want replace image?

use -- first line assumes selected text frame, of course can replace reference:

a_frame = app.selection[0]; a_frame.place (file(folder.mydocuments+'/yourimagename.png'), false); a_frame.fit (fitoptions.content_to_frame); a_frame.fit (fitoptions.proportionally); a_frame.fit (fitoptions.center_content); 

see textframe.place "place", , textframe.fit "fitting". doesn't matter using textframe commands here place , fit image -- id uses frame.

the 3 fitoptions in row ensure 1. entire image fits inside frame, out of proportion; 2. scales down proportionally; , 3. centers image inside frame. kind of odd, seems indesign's user interface fit options not reflected in scriptable fitoptions.


Comments

Popular posts from this blog

javascript - JS causing window size to be bigger than necessary - Dropdown bug -

php - Calling a template part from a post -

How to mention the localhost in android -