Quantcast
Channel: Adobe Community : All Content - InDesign Scripting
Viewing all 8771 articles
Browse latest View live

Indesign CC 2015 doesn't understand "place" applescript error -1708

$
0
0

If you could help me to solve my problem, that would be very kind! Thank you very much in advance.

 

My script (yes, an old Indesign CS3-one that still worked well in CS5):

 

tellapplication "Adobe InDesign CC 2015"

 

  activate-- switch naar indesign

 

  -- display dialog "..."

 

  -- creëer de dialoogbox voor invoer

  setmyDialogtomakedialog

  tellmyDialog

  setnameto "CTP Plaatsing Enve"

  setmyDialogColumntomakedialog column

  tellmyDialogColumn

  setmyBorderPaneltomakeborder panel

  tellmyBorderPanel

  setmyDialogColumntomakedialog column

  tellmyDialogColumn

  -- make static text with properties {static label:"Ordernummer:"}

  setingevoerd_ordernummertomaketext editboxwith properties {edit contents:"Werkordernummer", min width:150}

  endtell

  endtell

  setmyBorderPaneltomakeborder panel

  tellmyBorderPanel

  --make static text with properties {static label:"Machine:"}

  setdrukpersentomakedropdownwith properties {string list:{"HA3I", "HA6I", "HA4K", "571", "H3", "H6", "WenD", "522"}, selected index:0}

  endtell

  setmyBorderPaneltomakeborder panel

  tellmyBorderPanel

  --make static text with properties {static label:"Opmaak roteren:"}

  setopmaakroterentomakedropdownwith properties {string list:{"Opmaak niet roteren", "90° met de klok mee", "90° tegen de klok in"}, selected index:0}

  endtell

  setmyBorderPaneltomakeborder panel

  tellmyBorderPanel

  --make static text with properties {static label:"Weerdruk:"}

  setschoonweertomakedropdownwith properties {string list:{"Geen weerdruk", "Weerdruk", "Weerdruk op tweede plaat"}, selected index:0}

  endtell

  endtell

  show

  endtell

 

  setordernummertoedit contentsofingevoerd_ordernummer

 

  -- bepaal machine met bijbehorende variabelen

  ifselected indexofdrukpersen = 0 then-- HA3I

  setplaatbreedteto 311

  setplaathoogteto 251

  setplaatformaat_correctieto 0

  setdrukaanvangto 30

  setweerdrukafstandto 120

  setmachinelabelto "xHA3I"

  setpagina_orientatietolandscape

  elseifselected indexofdrukpersen = 1 then-- HA6I

  setplaatbreedteto 387

  setplaathoogteto 494

  setplaatformaat_correctieto 0

  setdrukaanvangto 30

  setweerdrukafstandto 240

  setmachinelabelto "xH6br"

  setpagina_orientatietoportrait

  elseifselected indexofdrukpersen = 2 then-- HA4K

  setplaatbreedteto 400

  setplaathoogteto 251

  setplaatformaat_correctieto 0

  setdrukaanvangto 12

  setweerdrukafstandto 0

  setmachinelabelto "xHA4K"

  setpagina_orientatietolandscape

  elseifselected indexofdrukpersen = 3 then-- 571

  setplaatbreedteto 311

  setplaathoogteto 251

  setplaatformaat_correctieto 0

  setdrukaanvangto 12

  setweerdrukafstandto 0

  setmachinelabelto "x571"

  setpagina_orientatietolandscape

  elseifselected indexofdrukpersen = 4 then-- H3

  setplaatbreedteto 311

  setplaathoogteto 251

  setplaatformaat_correctieto 0

  setdrukaanvangto 30

  setweerdrukafstandto 120

  setmachinelabelto "xH3"

  setpagina_orientatietolandscape

  elseifselected indexofdrukpersen = 5 then-- H6

  setplaatbreedteto 311

  setplaathoogteto 494

  setplaatformaat_correctieto 0

  setdrukaanvangto 30

  setweerdrukafstandto 241

  setmachinelabelto "xH6"

  setpagina_orientatietoportrait

  elseifselected indexofdrukpersen = 6 then-- WenD

  setplaatbreedteto 420

  setplaathoogteto 491

  setplaatformaat_correctieto 0

  setdrukaanvangto 42

  setweerdrukafstandto 0

  setmachinelabelto "xWenD"

  setpagina_orientatietoportrait

  elseifselected indexofdrukpersen = 7 then-- 522

  setplaatbreedteto 420

  setplaathoogteto 491

  setplaatformaat_correctieto 0

  setdrukaanvangto 42

  setweerdrukafstandto 241

  setmachinelabelto "x522"

  setpagina_orientatietoportrait

  endif

 

  -- opmaak roteren

  ifselected indexofopmaakroteren = 0 then-- opmaak niet roteren

  setgradento 0

  elseifselected indexofopmaakroteren = 1 then-- opmaak met de klok mee roteren

  setgradento -90

  elseifselected indexofopmaakroteren = 2 then-- opmaak tegen de klok in roteren

  setgradento 90

  endif

 

  -- schoon/weer

  setaantal_paginastopages per documentofdocument preferencesofactive document

  ifselected indexofschoonweer = 0 then

  setweerdrukto 0

  setaantal_loopstoaantal_paginas

  elseifselected indexofschoonweer = 1 then

  setweerdrukto 1

  setaantal_loopsto (aantal_paginas / 2) asinteger

  setaantal_paginasto (aantal_paginas / 2) asinteger

  elseifselected indexofschoonweer = 2 then

  setweerdrukto 2

  setaantal_loopsto (aantal_paginas / 2) asinteger

  endif

 

  -- verwijder nu de dialoogbox uit het geheugen

  destroymyDialog

 

  -- display dialog aantal_paginas

 

  -- initieer de rest van de variabelen

  setsnijteken_offsetto 8.2915 -- zie de CTP : verschuiving is 3 mm

  setordernummer_regelto "Werkorder: " & ordernummer

  setgeexporteerde_pdf_bestandsnaamto "ssd:Users:enve2:Desktop:CTP:" & ordernummer& machinelabel& ".pdf"

  setctp_document_bestandsnaamto "ssd:Users:enve2:Desktop:CTP:" & ordernummer& machinelabel& ".indd"

  setregistratiekleurto "Registration"

  setzwartto "Black"

  setwitto "White"

 

  -- exporteer de pdf die in het plaat-stramien geplaatst gaat worden

  -- let op! er wordt geen controle uitgevoerd!

  -- bijvoorbeeld: de 'koppelingen' worden niet gecontroleerd!

  tellactive document

  exportformatPDF typetogeexporteerde_pdf_bestandsnaamusing "CTP" withoutshowing options

  endtell

 

  -- maak een nieuw indesign document met de gewenste plaatafmetingen en het juiste aantal pagina's

  setctp_documenttomakedocument

 

  settransform reference pointofactive windowtocenter anchor

  sethorizontal measurement unitsofview preferencestomillimeters

  setvertical measurement unitsofview preferencestomillimeters

  setPDF cropofPDF place preferencestocrop PDF-- hoe wordt de pdf geplaatst ; in dit geval 'bijsnijden'

  settransparent backgroundofPDF place preferencestotrue

 

  telldocument preferencesofctp_document

  setfacing pagesto 0

  setpage heighttoplaatbreedte-- height=breedte lijkt raar; maar anders werkt page orientation niet :-)

  setpage widthtoplaathoogte-- idem

  setpage orientationtopagina_orientatie

  setpages per documenttoaantal_paginas

  endtell

  tellmargin preferencesofctp_document

  setcolumn countto 1

  settopto 0

  setbottomto 0

  setleftto 0

  setrightto 0

  endtell

  telltext defaultsofactive document

  setfill colortoregistratiekleur

  setfill tintto 100

  setpoint sizeto "8pt"

  endtell

 

  setpdf_paginato 1

  setctp_paginato 1

 

  repeatwithtellerfrom 1 toaantal_loops

  setpage numberofPDF place preferencestopdf_paginaasnumber-- selecteer de pdf pagina die geplaatst dient te worden

  tellpagectp_paginaofctp_document

  setillustratiekadertomakerectanglewith properties {geometric bounds:{0, 0, plaathoogte, plaatbreedte}} -- maak illustratiekader

  setgeplaatste_pdf_paginatoplacegeexporteerde_pdf_bestandsnaamonillustratiekader-- plaats de pdf pagina IN het illustratiekader

  set {dummy1, dummy2, pdfhoogte, pdfbreedte} togeometric boundsofgeplaatste_pdf_pagina-- vraag de afmetingen van de pdf op

  «event InESkdrt» geplaatste_pdf_paginagiven«class by  »:graden-- roteer eventueel de pdf in het illustratiekader (dus niet het illustratiekader zelf)

  ifgraden = 0 then-- pdf is niet geroteerd

  setmovexto ((plaatbreedte - plaatformaat_correctie) / 2) - (pdfbreedte / 2) asnumber-- bereken de horizontale verplaatsing

  setmoveyto (plaathoogte - pdfhoogte - drukaanvang + snijteken_offset) asnumber-- bereken de verticale verplaatsing

  elseifgraden = -90 then-- pdf is geroteerd; met de klok mee

  setmovexto ((plaatbreedte - plaatformaat_correctie) / 2) + (pdfhoogte / 2) asnumber-- bereken de horizontale verplaatsing

  setmoveyto {plaathoogte - pdfbreedte - drukaanvang + snijteken_offset} asnumber-- bereken de verticale verplaatsing

  elseifgraden = 90 then-- pdf is geroteerd; tegen de klok in

  setmovexto ((plaatbreedte / 2) - (pdfhoogte / 2) - plaatformaat_correctie) asnumber-- bereken de horizontale verplaatsing

  setmoveyto {plaathoogte - drukaanvang + snijteken_offset} asnumber-- bereken de verticale verplaatsing

  endif

  movegeplaatste_pdf_paginato {movex, movey} -- voer de verplaatsing uit

  ifmachinelabel = "xHA4K" andgraden = 0 then

  «event InESkdrt» geplaatste_pdf_paginagiven«class by  »:180

  endif

  ifmachinelabel = "xWenD" andgraden = 0 then

  «event InESkdrt» geplaatste_pdf_paginagiven«class by  »:180

  endif

  ifmachinelabel = "x522" andgraden = 0 then

  «event InESkdrt» geplaatste_pdf_paginagiven«class by  »:180

  endif

  endtell

  ifweerdruk = 1 then

  setpdf_paginatopdf_pagina + 1

  setpage numberofPDF place preferencestopdf_paginaasnumber-- selecteer de pdf pagina die als weerdruk geplaatst dient te worden

  tellpagectp_paginaofctp_document

  setillustratiekadertomakerectanglewith properties {geometric bounds:{0, 0, plaathoogte, plaatbreedte}} -- maak illustratiekader

  setgeplaatste_pdf_paginatoplacegeexporteerde_pdf_bestandsnaamonillustratiekader-- plaats de pdf pagina IN het illustratiekader

  set {dummy1, dummy2, pdfhoogte, pdfbreedte} togeometric boundsofgeplaatste_pdf_pagina-- vraag de afmetingen van de pdf op

  «event InESkdrt» geplaatste_pdf_paginagiven«class by  »:graden-- roteer eventueel de pdf in het illustratiekader (dus niet het illustratiekader zelf)

  ifgraden = 0 then-- pdf is niet geroteerd

  setmovexto ((plaatbreedte - plaatformaat_correctie) / 2) - (pdfbreedte / 2) asnumber-- bereken de horizontale verplaatsing

  setmoveyto {plaathoogte - pdfhoogte - drukaanvang - weerdrukafstand + snijteken_offset} asnumber-- bereken de verticale verplaatsing

  elseifgraden = -90 then-- pdf is geroteerd; met de klok mee

  setmovexto ((plaatbreedte - plaatformaat_correctie) / 2) + (pdfhoogte / 2) asnumber-- bereken de horizontale verplaatsing

  setmoveyto {plaathoogte - pdfbreedte - drukaanvang - weerdrukafstand + snijteken_offset} asnumber-- bereken de verticale verplaatsing

  elseifgraden = 90 then-- pdf is geroteerd; tegen de klok in

  setmovexto ((plaatbreedte / 2) - (pdfhoogte / 2) - plaatformaat_correctie) asnumber-- bereken de horizontale verplaatsing

  setmoveyto {plaathoogte - drukaanvang - weerdrukafstand + snijteken_offset} asnumber-- bereken de verticale verplaatsing

  endif

  movegeplaatste_pdf_paginato {movex, movey} -- voer de verplaatsing uit

  ifgraden = 0 then

  flip itemgeplaatste_pdf_paginagiven«constant flpohorz»

  else

  flip itemgeplaatste_pdf_paginagiven«constant flpovert»

  endif

  endtell

  endif

  ifweerdruk = 2 then

  setctp_paginatoctp_pagina + 1

  setpdf_paginatopdf_pagina + 1

  setpage numberofPDF place preferencestopdf_paginaasnumber-- selecteer de pdf pagina die als weerdruk geplaatst dient te worden

  tellpagectp_paginaofctp_document

  setillustratiekadertomakerectanglewith properties {geometric bounds:{0, 0, plaathoogte, plaatbreedte}} -- maak illustratiekader

  setgeplaatste_pdf_paginatoplacegeexporteerde_pdf_bestandsnaamonillustratiekader-- plaats de pdf pagina IN het illustratiekader

  set {dummy1, dummy2, pdfhoogte, pdfbreedte} togeometric boundsofgeplaatste_pdf_pagina-- vraag de afmetingen van de pdf op

  «event InESkdrt» geplaatste_pdf_paginagiven«class by  »:graden-- roteer eventueel de pdf in het illustratiekader (dus niet het illustratiekader zelf)

  ifgraden = 0 then-- pdf is niet geroteerd

  setmovexto ((plaatbreedte - plaatformaat_correctie) / 2) - (pdfbreedte / 2) asnumber-- bereken de horizontale verplaatsing

  setmoveyto {plaathoogte - pdfhoogte - drukaanvang + snijteken_offset} asnumber-- bereken de verticale verplaatsing

  elseifgraden = -90 then-- pdf is geroteerd; met de klok mee

  setmovexto ((plaatbreedte - plaatformaat_correctie) / 2) + (pdfhoogte / 2) asnumber-- bereken de horizontale verplaatsing

  setmoveyto {plaathoogte - pdfbreedte - drukaanvang + snijteken_offset} asnumber-- bereken de verticale verplaatsing

  elseifgraden = 90 then-- pdf is geroteerd; tegen de klok in

  setmovexto ((plaatbreedte / 2) - (pdfhoogte / 2) - plaatformaat_correctie) asnumber-- bereken de horizontale verplaatsing

  setmoveyto {plaathoogte - drukaanvang + snijteken_offset} asnumber-- bereken de verticale verplaatsing

  endif

  movegeplaatste_pdf_paginato {movex, movey} -- voer de verplaatsing uit

  ifgraden = 0 then

  flip itemgeplaatste_pdf_paginagiven«constant flpohorz»

  else

  flip itemgeplaatste_pdf_paginagiven«constant flpovert»

  endif

  endtell

  endif

  setctp_paginatoctp_pagina + 1

  setpdf_paginatopdf_pagina + 1

  endrepeat

 

  repeatwithctp_paginafrom 1 toaantal_paginas

  tellpagectp_paginaofctp_document-- maak hulplijnen

  makeguidewith properties {orientationconstant flpovert», locationplaatbreedte - plaatformaat_correctie) / 2} -- verticaal midden van de (evt. gesneden) plaat

  makeguidewith properties {orientationconstant flpovert», locationplaatbreedte / 2)} -- verticaal midden van het bestand

  makeguidewith properties {orientationconstant flpohorz», location:plaathoogte - drukaanvang}

  makeguidewith properties {orientationconstant flpohorz», location:plaathoogte - drukaanvang - weerdrukafstand}

  endtell

  endrepeat

 

  -- sla het indesign document  met geplaatste pdf op

  tellactive documenttosavetoctp_document_bestandsnaam

 

endtell

tellapplication "Adobe InDesign CC 2015"

  activate

  telltext defaults

  setfill colortozwart

  setfill tintto 100

  endtell

endtell


compare two xml attribute values and get their parent element

$
0
0

Hello All

 

I m stuck at a place.

I am getting the values of two xml element attributes using two separate functions. I want to compare these values and if they are equal i want to insert a textframe in it's first insertion point.

My code:

function Flow(){

  var myDoc = app.activeDocument;

  var myRuleSet = new Array (new flow1);

  with(myDoc){

  var elements = xmlElements;

  __processRuleSet(elements.item(0), myRuleSet);

  }

}

 

 

function flow1(){

    this.name = "flow1";

    this.xpath = "//xref";

    this.apply = function(myElement,myRuleProcessor)

        {

               __processChildren(myRuleProcessor);

               app.select(myElement);

               xref_att = myElement.xmlAttributes.item("rid").value;

            

}

function flow2(){

      this.name="fig";

      this.xpath="//fig";

      this.apply=function(elm,ruleproc)

      {

            __processChildren(ruleproc);

           app.select(elm);

            figele=elm.xmlattributes.item("id").value;

        }

      }

 

My requirement is:

if xref_att =figele, i have to insert textframe at the first insertionpoint of the element.

 

How can i do that?

 

Please help.

Thank You

Recording a script

$
0
0

How can I record a series of steps in InDesign and have them saved as a script?

I do this in Excel all the time and it's a great way to create at least the starting point for a script that may need some tweaking, but at least it's a good starting point.

 

I found a Rorohiko ActionRecorder that isn't supported anymore.  Surely there's a tool to do this function.

 

Thanks!

 

Urban

Importing Excel Cells into InDeisgn

$
0
0

Hello! New to the forum and to scripting InDesign.

 

Using InDeisgn CS6 and MS Office 2010 in a Windows 7 OS and scripting with VB Script.

 

What I have is an Excel file that contains columns of data that are serial numbers and activation codes for a clients software. I need to be able to read the data from, say A2:A2 and place it into a text frame. I need to bypass the Excel import options window. I've gone through the scripting tutorial and Scripting Guide and come up with this:

 

Set myInDesign = CreateObject("InDesign.Application")

Set myDocument = myIndesign.ActiveDocument

Set myTextFrame = myDocument.Pages.Item(1).TextFrames.Add

myTextFrame.GeometricBounds = Array("6p", "6p", "24p", "24p")

 

With myInDesign.ExcelImportPreferences

     .AlignmentStyle = idAlignmentStyleOptions.idSpreadsheet

     .DecimalPlaces = 4

     .PreserveGraphics = False

     .RangeName = "A2:A2"

     .SheetIndex = 1

     .SheetName = "Sheet1"

     .ShowHiddenCells = False

     .TableFormatting = idTableFormattingOptions.idExcelFormattedTable

     .UseTypographersQuotes = True

     .ViewName = ""

End With

 

myTextFrame.InsertionPoints.Item(-1).Place "C:\MyExcelFile.xlsx"

 

What is happening is that the entire Excel file is being placed, not just cell A2. It's as if the Excel import options dialog is being surpressed but the With block of code isn't being applied. What am I missing?

Read text frame contents?

$
0
0

Is it possible to get the contents of a text frame as a variable?

 

Basically, I need to loop through all text frames on a page, and if the user has made a text box with nothing but the text "apple5" for example, then place a file of the same name (if completed and exists) from say //docs/magazine/approved/apple5.pdf into that frame

 

Have found some guides about placing text into frames, but I need to read the text already in a frame really!

(if i'm going about this the best way!)

How to edit an existing script (ImageCatalog.jsx)

$
0
0

Hi,

 

I am using ImageCatalog.jsx to create bulk pages with images on them, however they are not coming out in name order.

 

I found this existing forum that answers how to do it, but I don't know how to work with scripts - do I create a new text doc. with the script or do I replace some text in the existing script (which I tried to do, but it didn't work).

By the way I'm using Windows, not Mac.

 

The existing forum is here:Re: imageCatalog image sorting before import

 

Any assistance would be much appreciated.

 

Thanks,

Amanda

add bold text to XML paragraph element

$
0
0

I'm trying to get the following output:

<book><p>hello now <bold>brown</bold> cow</p></book>

 

This is what I have:

var tagRoot = new XML("<book>");

tagRoot[0].p[0] = "hello now";

tagRoot[0].p[0].bold = "brown";

tagRoot[0].p[0] += " cow";

alert(tagRoot)

 

For some reason it turns the brackets from the bold tag into HTML entities.

 

How do I get the above output?

 

Thanks,

 

Kurtis

Help. InlineMerge script Stopped working

$
0
0

I use(d) InlineMerge scriptInDesignSecrets presents our InlineMerge script | Ozalto a lot in the past - and it's stopped working.

 

I create several annual reports and a membership directory with more than 2,000 entries - using this script has allowed me automate inputing all the data (the way data merge should work) but now it's not working.

 

I've upgraded to cc2015, and Im running on new mac - not sure what broke it.

 

When I click on the script, nothing happens  - no errors or anything. Is there a allow scripts setting some place that I;m overlooking?


How to moving the insertion point of editText from ScriptUI?

$
0
0

Hi.

 

How to moving the insertion point of editText from ScriptUI?

 

Please tell me JS code.

 

Thanks.

Scripting saving of [Converted] files

$
0
0

We are about to update to CC 2015 here at work, I'm tasked with running the preliminary testing. I'm hoping to script away a problem that occurs with every update. When I open a [previous version of InDesign] file, it opens with "[Converted]" in the title bar. Then I have to save the converted file over the old file which includes navigating to the correct location on our servers (which it never seems to know). I'd like a startup script that would detect that a file been converted, and save it in its original location, over the old file, automatically. It's not mission critical, but with hundreds of files and a dozen designers it would save a lot of time and keep the machine running smoothly. My experience is mostly with AppleScript and at a very basic level. Mostly I've altered existing scripts through trial and error. If someone could point me towards a similar script I could tinker with, that would be great. Thanks for any help.

How to using the "Bevel and Emboss" menu?

$
0
0

 

Hi.

 

I want to apply the effect to the rectangle.

 

How to using the "Bevel and Emboss" menu?

 

Please tell me JS code or jsx sample name.

 

Thanks.

Can’t seem to be able to change statictext font size

$
0
0

Help me out here. I cannot seem to be able to apply a larger font size to a multiline statictext object.

 

Here is the javascript function, which seems to work properly, except for interacting with the font properties. I want to use the default font, but want it a little larger, and for bonus points — bold. I will settle for just larger.

 

TIA

function message_dialog(message) {  //The dialog which displays a message and can also terminate the script  var the_dialog = new Window('dialog', 'SuperDuper Find Change'); //Make the window  the_dialog.alignChildren = 'fill'; // Make sure the child object have 100% width  the_dialog.orientation = 'row';  the_dialog.alignChildren = 'top';  the_message_group = the_dialog.add('group');  the_message_group.orientation = 'column';  the_message_group.alignChildren = 'left';  the_message_group.preferredSize.width = 300;  the_message_group.margins = 4; //Set the area around the children.  //Create a container for the message.  st_message = the_message_group.add('statictext', undefined, message, {multiline:true});  st_message.characters = 35; // WARNING: do not hit st.preferredSize before you set the characters property!
/** --- @TODO  The font change below appears to have no affect ---**/  st_message.graphics.font =  'dialog:21';  //Add the Okay button  the_button_group = the_dialog.add('group');  the_button_group.alignment = 'right';  the_button_group.alignment = 'top';  the_button_group.add("button", undefined, "OK");  the_dialog.show();
} //End message_dialog function

C#/JavaScript How to Set Primary Text Frame?

$
0
0

Hi,

 

I'm trying to work with InDesign scripting API with C# for my work. I'm new to both the InDesign scripting API, and using InDesign as well.

I'm trying to construct a master spread, with text frames in such a way that the text frame on the left page of the spready would flow into the text frame on the right page.


I've read there is the Primary Text Frame option for the master spread, but I can't seem to figure out how to use it.

Is there anyone who could show me an example scripting code to set the primary text frame for a master spread/page?


Here's the code I have so far.

The issue I have is in line 53, where when I try to run it, it gives me the very generic error "Invalid object for this request.", which leads me to believe I'm doing it wrong.

 

        public static byte[] CreatePageBasedOnCreatedMasterSpread(string savePath)        {            Application application = ActivateInDesign();            // Create new document            application.Documents.Add(true, application.DocumentPresets.FirstItem());            // Get active document and change some settings            Document document = application.ActiveDocument;            document.DocumentPreferences.FacingPages = true;            document.DocumentPreferences.PageWidth = 210;            document.DocumentPreferences.PageHeight = 297;            document.DocumentPreferences.CreatePrimaryTextFrame = true;            document.TextPreferences.SmartTextReflow = true;            MasterSpread masterSpread = document.MasterSpreads.Add();            masterSpread.BaseName = "CustomMasterSpread";            masterSpread.NamePrefix = "AC";            //Set the document's ruler origin to page origin. This is very important            //--if you don't do this, getting objects to the correct position on the            //page is much more difficult.            document.ViewPreferences.RulerOrigin = idRulerOrigin.idPageOrigin;            Page leftPage = masterSpread.Pages.FirstItem();            Page rightPage = masterSpread.Pages.LastItem();            leftPage.MarginPreferences.Top = rightPage.MarginPreferences.Top = 10;            leftPage.MarginPreferences.Bottom = rightPage.MarginPreferences.Bottom = 10;            leftPage.MarginPreferences.Left = rightPage.MarginPreferences.Left = 30;            leftPage.MarginPreferences.Right = rightPage.MarginPreferences.Right = 20;            // Create a text frame. Do not add text to this, as this is a master spread text frame.            // Link their flow together            TextFrame primaryFirstPageTextFrame = leftPage.TextFrames.Add(document.Layers.FirstItem(), idLocationOptions.idUnknown, leftPage);            TextFrame primarySecondPageTextFrame = rightPage.TextFrames.Add(document.Layers.FirstItem(), idLocationOptions.idUnknown, rightPage);            primaryFirstPageTextFrame.NextTextFrame = primarySecondPageTextFrame;            //Set primary text frame of master spread to be the two linked textframes            primaryFirstPageTextFrame.GeometricBounds = GetPageBoundsWithMargin(leftPage, document);            primarySecondPageTextFrame.GeometricBounds = GetPageBoundsWithMargin(rightPage, document);                    masterSpread.PrimaryTextFrame = primaryFirstPageTextFrame; //This causes the error                    return GetFileData(document, savePath);        }

 

I notice JavaScript API is very similar to C# as well, so it'd also help if I get a JavaScript answer.

Script Improvement Needed

$
0
0

Hi Everyone,

 

I'm hoping someone can help me improve my javascript.

 

I currently have a script that (inserted below), when executed on selected text, extracts the text, splits it and applies an object style. It works very well but leaves paragraph breaks and forced line break hanging around that I'd really rather not have. See the inserted images for my start state, current results and lastly preferred result.

 

Does anyone know how I can achieve this? I'm not an experience scripter at all so I don't know where to start!

 

Many thanks in advance,

Lewis

 

 

 

 

if (app.selection.length == 1 && app.selection[0].hasOwnProperty("baseline") && app.selection[0].length > 1)
{    mObjSt = app.activeDocument.objectStyles.item("Colour Label Grey");    app.selection[0].insertionPoints[0].contents = "\r";    app.findGrepPreferences = app.changeGrepPreferences = null;    app.findGrepPreferences.findWhat = "  (\\u)(?=~s)";    app.changeGrepPreferences.changeTo = "\\r\$1";    app.selection[0].changeGrep();    app.findGrepPreferences.findWhat = "\\n\\n\\r";    app.changeGrepPreferences.changeTo = "";    app.selection[0].changeGrep();    app.findGrepPreferences.findWhat = ", ";    app.changeGrepPreferences.changeTo = "";    app.selection[0].changeGrep();    p = app.selection[0].parentTextFrames[0];    lh = (p.lines[-1].baseline - p.lines[0].baseline) / (p.lines.length-1);    top = app.selection[0].lines[0].baseline - lh;    while (app.selection[0].length > 0)     {      f = app.activeDocument.layoutWindows[0].activePage.textFrames.add ({geometricBounds:[top, p.geometricBounds[3]+2*lh, top+lh, 2*(lh+p.geometricBounds[3])-p.geometricBounds[1] ]});      app.selection[0].lines[0].move (LocationOptions.AFTER, f.texts[0]);      top += lh;      f.appliedObjectStyle = mObjSt;     }     p.characters[-1].contents = "";   
} else
alert ("please select some text to shred");
if (f.lines[-1].contents.indexOf("\r") != -1) f.characters[-1].contents = "";

 

Screen Shot 2015-11-24 at 20.26.49.png

Screen Shot 2015-11-24 at 20.29.21.png

 

 

 

Screen Shot 2015-11-24 at 20.29.25.png

how to insert images from external folder into text frame using AppleScript

$
0
0

setmyFiletonull

 

tellapplication "Finder"

  setArtFoldertochoose folderwith prompt "Select Art Folder: ---->>"

  setchap1to (getfolder 1 offolderArtFolder)

  setmyFileto (getfile 1 offolder (chap1asalias))

endtell

 

tellapplication "Adobe InDesign CS5.5"

  setmyDoctoactive document

  tellmyDoc

       setfigureNodetoXML element 1 ofXML element 2 ofXML element 1 ofmyDoc

       setmyFrametomaketext framewith properties {geometric bounds:{3, -13, 13, -3}}

 

       tell text frame myFrame to place (file (myFile))

       markupmyFrameusingfigureNode

  endtell

endtell


==========================================

Requirement: I want to insert image from external folder & contents of current document node into text frame...

I am using above code, But belowe line not working....

          :- tell text frame myFrame to place (file (myFile))

Anyone can help me please.....

Thanks


APS : Folder Action Script and CS6 issue

$
0
0

Hi all,

 

I want to set a hotfolder where a txt file hosting a indesign file path being dropped runs InDesign CS6. Taken aside everything work. The folder action script is functional (ie dropping a file will run a script). The script that deals with InDesign too (run aside, InDesign opens the file and does what I am asking).

Once I try to run the indesign related script within the folder action script, the application isn't called at all. I am not sure this is something I could do wrong or if it's simply not possible :\

 

Has anyone of you completed this kind of challenge ? Any recommendations ?

 

Thanks in advance,

 

Loïc

populate selected tag from xml into dropdownlist SUI

$
0
0

hi guys,

I'm trying to display xml 1 tag type values only in dialogbox dropdownlist.

I can read and display content but whatever I'm trying to do to get wanted result getting the same results - dropdown displays all content with tags from file as a line (equal dropdown item) multiple by amount of signs or every sign from file appear in dropdown as item.

 

my xml stucture is:

<colours>

  <colour default="true">

    <name>color name 1</name>

    <value>my cmyk value 1</value>

  </colour>

  <colour default="true">

    <name>color name 2</name>

    <value>my cmyk value 2</value>

  </colour>

</colours>

do you know maybe how I can display only <name> of every colour as an dropdownlist item?

will appreciate any help...my idea to construct question to uncleG finished

 

the part of code responsible for reading xml is:

 

var colourNames = [];

var file_to_read = File("/myFilePath/test.xml");

var content;

file_to_read.open('r');

content = file_to_read.read();

     //var my_XML_object = null;

     //my_XML_object =  XMLList(content).toSource();

 

for (x = 0; x < content.length; x++) { 

    var xmlitem = content[x]; 

   colourNames.push (xmlitem);   

};

 

commented lines are something I've try as well, maybe will be useful.

Thank you

Differences Between IDMS Placing from Flex and HTML5?

$
0
0

I'm in the process of rewriting some InDesign plugins from Flex to HTML5 with AngularJS.

 

One of our plugins creates a library of IDMS files that can be placed from the plugin onto an InDesign document.

 

In the Flex version, when we do this, we get all the various components within the IDMS file, which can then be manipulated separately, edited, etc.

 

However, in the HTML5 version, only a raw image is place into the document, and no editing of separate components can be done.

 

In looking at the underlying Flex code, I can see where the IDMS file is being loaded into the placeGuns of the application:

 

app.activeDocument.placeGuns.loadPlaceGun(file);

 

...and in the corresponding JSX of the HTML5 version, I see the same command:

 

app.activeDocument.placeGuns.loadPlaceGun(aszFiles);

 

In the second case, it loads an array of files (in the event there are more than one), but the effect should be the same.

 

I can't figure out why they're being treated differently between Flex and HTML5.

 

Any help would be greatly appreciated!

Script to delete all images, text frames and page numbers on a layer

$
0
0

I have a 364 page book with 322 illustrations, mainly photographs, for offset printing.

The photographs will be overprinted with varnish on a fifth plate, and I set this up as follows:

On a new layer, (duplicate of Layer 1) all the photos are deleted, but not their frames.

The frames are then filled with 100% black.

All text frames and page numbers will also have to be deleted.

 

I realise I could have made this job easier if I had placed all images on their own layer to begin with, but unfortunately I didn't.

And I don't do scripting myself, so I was wondering if someone has a script that will do this ...

Using CC 2015.1 on Windows 7.

Quick key for horizontal distribute space with fixed width.

$
0
0

I'd like to create a quick key for horizontal distribute space - found at the bottom of the Align palette - with a fixed width, being zero millimetres.

 

I'm using InDesign CC.

 

Any ideas?

Viewing all 8771 articles
Browse latest View live