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

HelP~Kai Rübsamen I miss you:Do not distinguish the text box or picture frame, automatically fit to blood(not pages), automatically fit to the 4margins

Advocate ,
Oct 10, 2014 Oct 10, 2014

Copy link to clipboard

Copied

Do not distinguish the text box or picture frame, automatically fit to blood(not pages), automatically fit to the 4margins (I want to use less of the script to complete more things)

Reference resources:https://forums.adobe.com/message/6146189

var curDoc = app.activeDocument;

if ( app.selection.length != 1 ) {

    ( alert ( "Something wrong with your selection!" ) );

    exit();

    }

var curSel = app.selection[0];

var curPage = curSel.parentPage;

// set the zeroPoint to 0

var zP = curDoc.zeroPoint;

if (zP != [0,0]) {

    curDoc.zeroPoint = [0,0];

}

var rO = curDoc.viewPreferences.rulerOrigin;

if (rO != 1380143215) {

    curDoc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;

}

var pW = curDoc.documentPreferences.pageWidth;

var y1, x1, y2, x2;

if ( curPage.side == PageSideOptions.leftHand ){

    x2 = curPage.marginPreferences.left;

    x1 = curPage.marginPreferences.right;

}

else {

    x1 = curPage.marginPreferences.left;

    x2 = curPage.marginPreferences.right;

}

x2 = pW - x2;

var gB = curSel.geometricBounds;

// fit to margins

/*gB[1] = x1;

gB[3] = x2;

curSel.geometricBounds = gB;

*/

// fit to page

gB[1] = 0;

gB[3] = pW;

curSel.geometricBounds = gB;

curSel.fit ( FitOptions.FRAME_TO_CONTENT );

resetAsBefore();

function resetAsBefore() {

    if ( rO != 1380143215 ) {

            curDoc.viewPreferences.rulerOrigin = rO;

    }

    // set the zeroPoint back to the origin state

    if (zP != [0,0]) {

        curDoc.zeroPoint = zP;

    }

}

TOPICS
Scripting

Views

200

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
no replies

Have something to add?

Join the conversation