• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Is there a javascript to resize a frame to Page, Margin, Bleed or Slug?

Explorer ,
Jun 11, 2015 Jun 11, 2015

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

TOPICS
Scripting

Views

3.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Jun 12, 2015 Jun 12, 2015

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

Votes

Translate

Translate
Engaged ,
Jun 11, 2015 Jun 11, 2015

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");

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 11, 2015 Jun 11, 2015

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 12, 2015 Jun 12, 2015

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 13, 2015 Jun 13, 2015

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 14, 2015 Jun 14, 2015

Copy link to clipboard

Copied

For slug

doc.documentPreferences.slugTopOffset = "10mm"; 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 27, 2015 Jul 27, 2015

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 13, 2015 Jun 13, 2015

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 23, 2017 Jul 23, 2017

Copy link to clipboard

Copied

LATEST

For those that need these scripts now and don't have the time to learn how to write them this link will help greatly:

https://sellfy.com/p/JMJu/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines