Back

If your email is not recognized and you believe it should be, please contact us.

Forum Replies Created

Viewing 14 posts - 16 through 29 (of 29 total)
  • Author
    Posts
  • in reply to: Image Fitting options on Anchored Graphic Frames #14323970
    Robert Ploch
    Member

    Hi Masood,

    1. I’m affraid, I don’t understend your previous post about centering inline grapgics. Would you eplain it more precise ?
    2. try this code to process all the inline graphics in all the texts in active document:

    if ( app.documents.length > 0 ) {

    var mySelections = app.activeDocument.stories.everyItem().texts[0].splineItems.everyItem().getElements(); // this is an array of anchored items of the story in seleccted textFrame

    alert ( “There are/is ” + mySelections.length + ‘ anchored elements in the document.’ );

    main( mySelections );

    }

    function main( sel ){
    var i = sel.length;
    while ( i– ) {
    try { var myObject = sel[i];
    myObject.fit(FitOptions.contentToFrame);
    myObject.fit(FitOptions.proportionally);
    myObject.fit(FitOptions.centerContent);
    myObject.fit(FitOptions.frameToContent);
    } catch ( err ) {}
    }
    }

    best regards
    r.

    in reply to: Script for putting pages 4up #14323996
    Robert Ploch
    Member

    Hello Jelle,

    If you have prepared template (e.g. A3) full of graphic frames in certain grid this piece of code will put choosen file into all the frames. If orientation of choosen file won’t conform shape of the graphic frame, script will rottate imported file.

    I’ve tested it shortly on Indd files – template A3 and A5. The script should work regardless of format if formats will conform eachother

    best
    Robert

    PS. If you will have problems with copying and pasting code to ExtendScript toolkit write my your e-mail, so I’ll send you a script file.

    var toPlace = File.openDialog (‘Select file to place.’, ‘*.*’, false);
    if ( !toPlace ) { exit(); }

    place ( toPlace );

    function place ( file ) {

    app.activeWindow.transformReferencePoint = AnchorPoint.CENTER_ANCHOR;

    var f = app.activeDocument.rectangles, i = f.length;
    while ( i– ) {
    try { f[i].graphics[0].remove(); } catch (err) {}
    with ( f[i] ) {
    place ( file ),
    clearTransformations(),
    clearFrameFittingOptions(),
    fit( FitOptions.CENTER_CONTENT )
    }

    if ( ( ( f[i].geometricBounds[3]-f[i].geometricBounds[1] ) < ( f[i].graphics[0].geometricBounds[3]-f[i].graphics[0].geometricBounds[1] ) ) ||
    ( ( f[i].geometricBounds[2]-f[i].geometricBounds[0] ) < ( f[i].graphics[0].geometricBounds[2]-f[i].graphics[0].geometricBounds[0] ) ) ) {
    f[i].graphics[0].rotationAngle = 90;
    }
    }
    }

    in reply to: Image Fitting options on Anchored Graphic Frames #14324009
    Robert Ploch
    Member

    Hello again :)

    try this little work snippet of code. I hope I’ve undersood your idea :)
    I’ve changed a little your code in case of potential errors and/or further actions ( e.g. deleting anchored elements )

    if ( !app.selection[0] || app.selection[0].constructor.name != ‘TextFrame’ ) { alert ( ‘There is no TEXT FRAME selected !Select a textFrame contaning text please :)’); exit() }
    var mySelections = app.selection[0].parentStory.splineItems.everyItem().getElements(); // this is an array of anchored items of the story in seleccted textFrame

    alert ( “There are/is ” + mySelections.length + ‘ anchored elements in the frame.’ );

    main();

    function main(){
    var sel = mySelections, i = sel.length;
    while ( i– ) {
    var myObject = sel[i];
    myObject.fit(FitOptions.contentToFrame);
    myObject.fit(FitOptions.proportionally);
    myObject.fit(FitOptions.centerContent);
    myObject.fit(FitOptions.frameToContent);
    }
    }

    best
    m.

    in reply to: Apply [Unconditional] condition to Conditional Text #14324027
    Robert Ploch
    Member

    Hi Masood,

    try this, it work for me :)

    var s = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements(), i = s.length;

    while ( i– ) {
    s[i].applyConditions( [], true );
    }

    best regards
    m.

    in reply to: Paragraph Based on style script #14324030
    Robert Ploch
    Member

    Hello again Rick,

    there is a modified and improoved, more elegant version of the script :-)

    I hope it will work fine for you …

    The changes are:
    1. script returns only styles if they have baseOn style
    2. if there are no baseOn styles in character styles, script opens only one paged document
    3. I put the original numbers of the styles in source document

    If you will have still problems with the script write your e-mail, so I will send you a file.

    regards
    m.

    #target indesign-14

    if ( !app.documents.length ) { alert ( “Open document, please !” ); exit(); }

    var ps = app.activeDocument.allParagraphStyles, cs = app.activeDocument.allCharacterStyles, parstyles = [], charstyles = [];

    processStyles ( ps, 2, parstyles );
    processStyles ( cs, 1, charstyles );

    if ( parstyles.length > 0 && charstyles.length == 0 ) {
    var doc = app.documents.add();
    addTitleStyle (); addSubTitleStyle();
    with ( doc.documentPreferences ) { pagesPerDocument = 1; }
    var p = doc.pages[0];
    with ( p.marginPreferences ) { top = 10; left = 10; bottom = 10; right = 10; }
    p.textFrames.add( { geometricBounds : [ p.marginPreferences.top, p.marginPreferences.left, doc.documentPreferences.pageHeight – p.marginPreferences.bottom, doc.documentPreferences.pageWidth – p.marginPreferences.right ] } ).contents = “Paragraph styles: \rNo. Style based on\r” + parstyles.join( “\r” );
    titleSubtitleBold( p.textFrames[0] );
    alert (‘There is no basedOn character styles.’ );
    }
    else if ( parstyles.length > 0 && charstyles.length > 0 ) {
    var doc = app.documents.add();
    addTitleStyle (); addSubTitleStyle();
    with ( doc.documentPreferences ) { pagesPerDocument = 2; }
    var p = doc.pages; i = p.length;
    while ( i– ) {
    with ( p[i].marginPreferences ) { top = 10; left = 10; bottom = 10; right = 10; }
    p[i].textFrames.add( { geometricBounds : [ p[i].marginPreferences.top, p[i].marginPreferences.left, doc.documentPreferences.pageHeight – p[i].marginPreferences.bottom, doc.documentPreferences.pageWidth – p[i].marginPreferences.right ] } );
    }
    p[0].textFrames[0].contents = “Paragraph styles: \rNo. Style based on\r” + parstyles.join( “\r” );
    p[1].textFrames[0].contents = “Character styles: \rNo. Style based on\r” + charstyles.join( “\r” );
    titleSubtitleBold ( p[0].textFrames[0] ); titleSubtitleBold ( p[1].textFrames[0] );
    }

    // ++++++++++++++++++++++++ func ++++++++++++++++++++++++++

    function processStyles( s, x, a ) {
    for ( var i = x; i < s.length; i++ ) {
    var bs = s[i].basedOn.name;
    if ( bs != undefined ) {
    a.push( i + “\. ” + s[i].name + ‘ ——— ‘ + bs );
    }
    }
    }
    function titleSubtitleBold ( frame ) {
    frame.parentStory.paragraphs[0].applyParagraphStyle( doc.paragraphStyles.item( “Title” ) );
    frame.parentStory.paragraphs[1].applyParagraphStyle( doc.paragraphStyles.item( “SubTitle” ) );
    }
    function addTitleStyle ( ) {
    doc.paragraphStyles.add( { name : “Title”, fontStyle : “Bold”, pointSize : 16 } );
    }
    function addSubTitleStyle ( ) {
    doc.paragraphStyles.add( { name : “SubTitle”, fontStyle : “Bold”, pointSize : 14, fillTint : 50 } );
    }

    in reply to: Paragraph Based on style script #14324037
    Robert Ploch
    Member

    Rick
    I made a big mistake yesterday. Replace line 8 with this code :

    doc = app.documents().documentPreferences.pagesPerDocument = 2;

    It should make the script to run properly :)

    best
    m.

    in reply to: Paragraph Based on style script #14324047
    Robert Ploch
    Member

    my solution is in fact not as elegant as it could be, but my goal was to give you a quick solution. I very happy it help you :)

    in reply to: Paragraph Based on style script #14324049
    Robert Ploch
    Member

    the error on line 10 must mean something elese
    if there is no “basement” :) style you should get UNDEFINED

    try to delete line 10 :)

    in reply to: Paragraph Based on style script #14324051
    Robert Ploch
    Member

    Hmmmmm,
    I’ve tried this script on a few different documents and it works !

    try to exchange sigle quotes to double quotes – I use single but it is not exactly correct :)

    do you use it om mac or pc?

    in reply to: Paragraph Based on style script #14324053
    Robert Ploch
    Member

    undefined means – there is no basedOn style …. ofcorse :)

    in reply to: Paragraph Based on style script #14324054
    Robert Ploch
    Member

    Hi Rick,

    try this:

    #target indesign-14

    var ps = app.activeDocument.allParagraphStyles, cs = app.activeDocument.allCharacterStyles, parstyles = [], charstyles = [];

    processStyles ( ps, 2, parstyles );
    processStyles ( cs, 1, charstyles );

    var doc = app.documents.add( { pages : 2 } );
    doc.pages[0].textFrames.add( { geometricBounds : [ ‘0mm’,’0mm’,’150mm’,’150mm’ ] } ).contents = ‘Paragraph styles: ‘ + parstyles.join( ”);
    doc.pages[1].textFrames.add( { geometricBounds : [ ‘0mm’,’0mm’,’150mm’,’150mm’ ] } ).contents = ‘Character styles: ‘ + charstyles.join( ”);

    function processStyles ( s, x, a ) {
    for ( var i = x; i < s.length; i++ ) {
    var bs = s[i].basedOn.name;
    a.push( s[i].name + ‘ ——— ‘ + bs );
    }
    }

    Just open your template and run the script from ExtendScript Toolkit
    It is very simple solution that produces two lists in two frames in new document.

    I hope it will help you :)

    redards
    m.

    in reply to: TomaxxiGREP — still available? #113348
    Robert Ploch
    Member

    Hi,
    Write me please on priv. I can help you :-)
    Regards
    Marc

    in reply to: Objects and properties, and methods and parameters #97062
    Robert Ploch
    Member

    … and if you like a graphic version of some of most important indesign DOM elements see this:

    https://www.indesignjs.de/auflage2/wp-content/uploads/2015/04/InDesign_Skripting_Kurzreferenz.pdf

    in reply to: Objects and properties, and methods and parameters #97061
    Robert Ploch
    Member

    I like this link very much :-)

    https://www.indesignjs.de/extendscriptAPI/

    I is very helpful and it is indexed.

Viewing 14 posts - 16 through 29 (of 29 total)