4 Replies Latest reply on Jul 1, 2010 4:36 PM by choock

    coding interactive print button in Indesign


      we create pdf brochures from Indesign. A number of buttons appear on every page which have been coded in Indesign, coded using the 'interactive button options' function. We have a print button on every page and there is no option to code this within Indesign and is becoming a tedious chore to code in the final pdf every time we make a brochure. I have experimented with some js in Indesign but can't get anything to work.


      can anyone offer a solution please.

        • 1. Re: coding interactive print button in Indesign
          Kasyan Servetsky Level 5

          If you are on Windows, you can write a script that exports a pdf file from InDesign and opens it in Acrobat, does the tedious part of the job there, and finally saves and closes it. For examples check out this thread.



          • 2. Re: coding interactive print button in Indesign
            choock Level 1

            thanks, I went to the thread and used the script, changing email to print. I get an error though.




            error number: 14

            error string : no matching closing brace found


            source: function GetFileNameOnly(myFileName) {

            offending text: {


            #target indesign var myIndesignDoc = app.activeDocument; var myParentFolder = myIndesignDoc.fullName.parent; var myBaseName = GetFileNameOnly(myIndesignDoc.name); var myFilePath = myParentFolder.absoluteURI + "/" + myBaseName + ".pdf"; var myFile= new File(myFilePath); var mylayerText = myIndesignDoc.layers.item("Text") var mylayerGraphics = myIndesignDoc.layers.item("Graphics") var mylayerOnlinePdf = myIndesignDoc.layers.item("Online PDFs") var mylayerTagline = myIndesignDoc.layers.item("Print tagline") mylayerText.visible = true mylayerGraphics.visible = true mylayerOnlinePdf.visible = true mylayerTagline.visible = false var myPDFExportPreset = app.pdfExportPresets.item("EBLowRes"); app.activeDocument.exportFile(ExportFormat.pdfType, myFile, false, myPDFExportPreset); var myScript = AcrobatScript.toString() + '\r'; myScript += 'AcrobatScript(\"' + myFilePath + '\");'; var bt = new BridgeTalk; bt.target = "acrobat"; bt.body = myScript; bt.send(); function AcrobatScript(myFilePath) {     var myAcrobatDoc = app.openDoc(myFilePath);     var f = myAcrobatDoc.getField("Print");     f.setAction("MouseUp", "this.printDoc(true);");     myAcrobatDoc.saveAs(myFilePath);     myAcrobatDoc.closeDoc(true); } function GetFileNameOnly(myFileName) {      var myString = "";      var myResult = myFileName.lastIndexOf(".");      if (myResult == -1) {           myString = myFileName;      }      else {           myString = myFileName.substr(0, myResult);      }      return myString;
            • 3. Re: coding interactive print button in Indesign
              Kasyan Servetsky Level 5




              The error occurs because you failed to copy-paste the last line of the script -- a brace.

              However the script is not supposed to work as it is for you since it requires that the active document should have certain layers:"Text", "Graphics", "Online PDFs", "Printtagline" and PDF export preset called "EBLowRes"


              This is just an example that shows you an approach you can use to make your own script. In fact, you should write two scripts one for InDesign another for Acrobat, then combine them into a single script -- e.g. InDesign exports pdf file and sends the acrobat script via BridgeTalk message, which in turn may return a result, an error message if such occurs, etc. And this kind of job is for an advanced scripter -- you should know how to write scripts in InDesign, Acrobat and inter-application communication -- otherwise you'd better hire someone who can do this for you.



              • 4. Re: coding interactive print button in Indesign
                choock Level 1

                yes - created layers as per the code & added the closing curly bracket originally but as stated error applied


                didn't realise that additional coding in acrobat was required, will have to find someone to create the script, I am too snowed under with work to learn this at present