1 person found this helpful
In what way could the documentation NOT help? This is a sample which assumes an open document with at least 1 rectangle present on the first page.
#target indesign var f = new File('~/Desktop/Picture_3.tif'); var doc = app.activeDocument; doc.pages.rectangles.place(f, false); doc.pages.rectangles.images.fit(FitOptions.FILL_PROPORTIONALLY); doc.pages.rectangles.images.fit(FitOptions.centerContent);
The file path string I used is mac style but changing the string is straight forward enough…
2 people found this helpful
There's no need first to create a rectangle:
That filename format works on Windows, too, by the way.
Peter, I know about as close to 0 about windows as you can get. I thought that '~' (home) was mandatory on the unix/mac but optional on the pc depending on what version of the os you have is that write or wrong?
Thanks, was great help.
~ = Home Folder is not in any version of Windows, it's a typical Mac/Unix thing. Someone at Adobe must have thought it was a good idea to have ID automatically translate it. That's A Good Thing, too, because (1) user's paths on Windows have always been a mess, and (2) Windows 7 made it yet even worse.
Well, I'm not sure, in fact. I use
which works on any version.
-- and I can place it into my document using this:
var f = new File('~/Pictures/homeFolder.PNG');
This is where I picked this up from… Adobe PDF…
The home directory
A path name can start with a tilde (~) to indicate the user's home directory. It corresponds to the platform’s HOME environment variable.
UNIX and Mac OS assign the HOME environment variable according to the user login. In Mac OS, the default home directory is /Users/username. In UNIX, it is typically /home/username or /users/username. Extend Script assigns the home directory value directly from the platform value.
In Windows, the HOME environment variable is optional. If it is assigned, its value must be a Windows path name or a path name referring to a remote server (such as \\myhost\mydir). If the HOME environment variable is undefined, the Extend Script default is the user's home directory, usually the C:\Documents and Settings\username folder.
Although the more Im using this extendscript the guides are looking less of a bible…