Copy link to clipboard
Copied
There are a lot of fit frame to content but I often resize frames to fit a page or bleed or slug. Does anyone know if this could be done?
Thanks
Hi Sketch_Ak,
The basic brick is:
myFrame.geometricBounds = myPage.bounds;
Now you'll find for sure many variants and adjusted snippets in browsing this forum.
@+
Marc
Copy link to clipboard
Copied
Please try this
var selFolder=Folder.selectDialog("Choose folder for Application File");
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
if (selFolder!=null)
{
var all_file=selFolder.getFiles("*.indd");
for (var no_file=0; no_file<all_file.length;no_file++)
{
var cur_doc=app.open(File(all_file[no_file],false));
cur_doc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.centimeters;
cur_doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.centimeters;
cur_doc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
cur_doc.zeroPoint =[0, 0];
cur_doc.documentPreferences.pageWidth =17;
cur_doc.documentPreferences.pageHeight =24;
cur_doc.masterSpreads.item(0).pages.item(0).marginPreferences.right = 2.8;
cur_doc.masterSpreads.item(0).pages.item(1).marginPreferences.right = 2.8;
for (no_pg=0;no_pg<cur_doc.masterSpreads.item(0).pages.length;no_pg++)
{
var mypage=cur_doc.masterSpreads.item(0).pages[no_pg];
for (no_tx=0;no_tx<mypage.textFrames.length;no_tx++)
{
if (mypage.textFrames[no_tx].geometricBounds[0]<mypage.marginPreferences.top-0.5)
{
txBound=mypage.textFrames[no_tx].geometricBounds;
mypage.textFrames[no_tx].move([txBound[1],1.4575]);
}
}
}
cur_doc.close(SaveOptions.YES);
}
}
alert("Process Completed");
Copy link to clipboard
Copied
Thank you for replying sreekarthik.k,
Sorry I should have given more details.
1. I'd use this script with a document already open.
2. The page size can be any size depending on the job.
3. I draw a frame, and I want to automatically fit this frame to the page edge width and height (which is a variable size).
I hope that makes sense?
Copy link to clipboard
Copied
Hi Sketch_Ak,
The basic brick is:
myFrame.geometricBounds = myPage.bounds;
Now you'll find for sure many variants and adjusted snippets in browsing this forum.
@+
Marc
Copy link to clipboard
Copied
Hi Marc Autret,
Here is the script I've ended up with to fit a frame to a document page size:
var doc = app.activeDocument;
var myPage = doc.pages[0];
var fit = myPage.bounds;
var myFrame = app.selection[0];
myFrame.geometricBounds = fit;
I was also able to find other scripts for bleed and slug thanks to your feedback.
Cheers
Os
Copy link to clipboard
Copied
For slug
doc.documentPreferences.slugTopOffset = "10mm";
Copy link to clipboard
Copied
Thanks so much -- this little script is saving me.
FYI: If doc has spreads rather than individual pages, ruler needs to be set to "ruler per page" to set the right-hand page coordinates correctly.
Copy link to clipboard
Copied
This script you have is fit to the side space (without the bleed cutout).
How do I write a script to make an image fit the column width, fit the center of the page, and fit the page?
Copy link to clipboard
Copied
Hello!
There is a script almost conforming your requirements, but it creates a new rectangle, does not transform an existing one:
https://sites.google.com/site/dtpscripting/indesign-scripts/makerectangle-jsx
Copy link to clipboard
Copied
For those that need these scripts now and don't have the time to learn how to write them this link will help greatly: