11 Replies Latest reply on Feb 10, 2015 3:32 PM by Laubender

    InDesign Server Automation

    shadymilkman01

      I'm looking into purchasing InDesign Server for the document automation features. One feature, Data Merge, would be a tremendous help for our company.

      I'm having some trouble setting it up with a script.

       

      Here's what I have running, just a basic test.

       

      var myDocument = app.open(File("C:\\inetpub\\wwwroot\\indesign\\test.indd"));
      
      
      with (app.dataMergeOptions) {
      linkImages = true;
      removeBlankLines = false;
      createNewDocument = true;
      documentSize = 100;
      } // (end of dataMergeOptions)
      
      
      myDocument.dataMergeProperties.mergeRecords();
      myDocument.exportFile(ExportFormat.PDF_TYPE, File ("c:\\inetpub\\wwwroot\\indesign\\merged.pdf"));
      myDocument.close ();
      

       

      In the file I had it linked to a csv that pulled data but it seems the link has been broken (or out of date according to the error).

      Can anyone help me with what I am doing wrong or even provide a better method?

       

      I am running the script through PHP via SOAP in IIS running on Windows 2008 R2

      InDesign Server CC 2014

        • 1. Re: InDesign Server Automation
          Peter Spier Most Valuable Participant (Moderator)

          I've moved this to the Scripting forum. You're more likely to find folks with server scripting experience here.

          • 2. Re: InDesign Server Automation
            shadymilkman01 Level 1

            Thank you.

            • 3. Re: InDesign Server Automation
              TᴀW Adobe Community Professional & MVP

              This would be better asked in the scripting forum.

               

              But when you say "I'm looking into purchasing InDesign Server for the

              document automation features", if that is taken literally, it sounds

              like someone's about to make a very expensive mistake.

               

              Document automation features are fully accessible via scripting with a

              regular InDesign license costing a fraction of the Server option.

              • 4. Re: InDesign Server Automation
                shadymilkman01 Level 1

                Thank you for your "constructive" feedback. I don't think you fully understand what is trying to be accomplished. I need to run scripts and commands from a web server into InDesign, and if I'm not mistaken you need a server to do that.

                Do you have a suggestion on how to to run a data merge from PHP through a non server InDesign?

                • 5. Re: InDesign Server Automation
                  TᴀW Adobe Community Professional & MVP

                  I understand perfectly well. However, you wrote that you're getting ID

                  Sever for it's "document automation features". You did not write that

                  you're getting it because you need to run it on a web server. If

                  understood literally, that sounds like such an expensive mistake that I

                  thought I'd point it out, even at the risk of a snarky response.

                   

                  You are quite right that you need a server license if you need to run it

                  from a web server.

                   

                  As to the substance of the question: app.dataMergeOptions would normally

                  set the InDesign defaults for dataMergeOptions for new documents.

                   

                  If you want to change the options for an existing document, you would

                  normally change myDocument.dataMergeOptions.

                   

                  However, I don't do much data merging, either with a script or without,

                  so this is just a suggestion of something to double-check.

                  • 6. Re: InDesign Server Automation
                    shadymilkman01 Level 1

                    Thank you. I suppose I didn't explicitly state this, but I did state.

                    I am running the script through PHP via SOAP in IIS running on Windows 2008 R2

                    I am grateful for the reply and any assistance is appreciated.

                    I'm not sure how you'd go about setting the defaults in the server as there is no UI to do so, and I did notice the dataMergeOptions and assumed there would be an option for the data source or something along those lines there.

                    I just was unsure of what this option is and if there was a better method such as Variable Data Publishing (VDP) as listed in the FAQ and how to implement this.

                    I've been searching for some documentation or tutorials for a few days and haven't come up with much on the subject.

                    • 7. Re: InDesign Server Automation
                      TᴀW Adobe Community Professional & MVP

                      Again, setting app.dataMergeOptions will set InDesign's defaults for new

                      documents.

                       

                      Whereas, if myDoc is a reference to an open InDesign document,

                      myDoc.dataMergeOptions will change the options for that particular

                      document, regardless of InDesign's default options.

                       

                      There are many preferences in InDesign that work like this, i.e., that

                      can be set on the application level, meaning that new documents created

                      will inherit those prefs, versus being set on the document level,

                      meaning that they will be changed for that particular document only

                      (regardless of the app preferences) and will not be inherited by a new

                      document.

                       

                      Whether that's the solution to your particular problem in the original

                      question, I'm not sure, but it's worth a try.

                      • 8. Re: InDesign Server Automation
                        Loic.Aigon Adobe Community Professional

                        Hi,

                         

                        What you could try is to get back the path of your CSV file inside that document and at first check if the inner path is consistent with what you would expect.

                         

                        Secondly, you could restate the csv source file while opening the document with Document.dataMergeProperties.selectDataSource( your csv file full path )

                         

                        Finally, I see you are trying to use "createNewDocument = true; ". From what I observed, tweaking this property seems to have no effect (true/false=> no differencies).

                        So the basic with DataMerge is that calling "merge()" will lead to one to many temporary merged documents. Those I guesss you want to export.

                        At this stage you may either pick any created document to export them OR call the "Document.dataMergeProperties.exportFile()" method that will deal with both merging documents and doing the exports.

                         

                        Also, given that you are considering datamerge, I may also recommend dropping an eye on EasyCatalog. It's sure more expensive but also very powerful when it comes to populate data into InDesign automatically based on templates.

                         

                        Good luck and don't hesitate in testing any single object before to use it

                         

                        Loic

                        http://www.ozalto.com

                        • 9. Re: InDesign Server Automation
                          shadymilkman01 Level 1

                          Thank you for your post Loic.Aigon.

                           

                          After I stumbled upon this post javascript - InDesign Script: export to IDML - Stack Overflow I found the option dataMergeProperties.selectDataSource(csv file).

                          Here's my updated code, sorry for the missing formatting.

                           

                           

                          var myDocument = app.open(File("C:\\inetpub\\wwwroot\\indesign\\test.indd"));

                          var myDataSource = File("C:\\inetpub\\wwwroot\\indesign\\test.csv");

                           

                           

                          with (app.dataMergeOptions) {

                          linkImages = true; 

                          removeBlankLines = false;

                          createNewDocument = true;

                          documentSize = 100;

                          } // (end of dataMergeOptions)

                           

                           

                          myDocument.dataMergeProperties.selectDataSource(myDataSource);

                           

                           

                          myDocument.dataMergeProperties.mergeRecords();

                          app.activeDocument.exportFile(ExportFormat.PDF_TYPE, File ("/c/inetpub/wwwroot/indesign/merged2.pdf"));

                          //myDocument.save(new File("C:\\inetpub\\wwwroot\\indesign\\mergedOutput.idml"));

                          myDocument.close ();

                           

                           

                          if I run myDocument.exportFile(ExportFormat.PDF_TYPE, File ("/c/inetpub/wwwroot/indesign/merged2.pdf")); then it tries to merge but throws a warning [link manager Link out of date: file: and links the original csv file it was created with (not my referenced data source file).

                          I believe I should merge on the active document and not the original document.

                          But if I run app.activeDocument.exportFile(ExportFormat.PDF_TYPE, File ("/c/inetpub/wwwroot/indesign/merged2.pdf")); it throws a javascript error, app.activeDocument is undefined.

                          • 10. Re: InDesign Server Automation
                            shadymilkman01 Level 1

                            Wow I'm sorry I didn't read that thoroughly. I just tried with the Document.dataMergeProperties.exportFile() method and it worked out.

                            Thanks much!

                            • 11. Re: InDesign Server Automation
                              Laubender Adobe Community Professional & MVP

                              @shadymilkman – there is a preference on document level: DataMerge

                               

                              To work with it you first have to get it by its index in the document preferences.

                              DataMerge has no name property, but its constructor name is "DataMerge".

                               

                              See especially its methods:

                              selectDataSource()

                              updateDataSource()

                               

                              Here some info on that object (InDesign CS6):

                              Adobe InDesign CS6 (8.0) Object Model JS: DataMerge

                               

                              Uwe