1 Reply Latest reply on May 4, 2015 8:01 AM by Jump_Over

    How do I insert my csv file column value into a text frame placeholder with javascript?

    12345657uhgfdgdsf

      Hi guys i'm a beginner when it comes to scripting in general and I got an assignment .

      I'm working on a web api which needs to produce an empty indd Document and fill it with content with the help of a csv file(datamerge) and convert it to a pdf afterwards. Im currently using the InDesign server and a soap client to insert my task with scripts in it to accomplish this. In the script below I am trying put the header column into a placeholder text frame in InDesign. the problem is that when i run this I get the error  " Missing placeholders". so the script can't put the csv content in a placeholder. I am stuck at this error, please help me if you can.


      code below:


      var source = File("/c/xampp/htdocs/project/data/indd/hello1.indd");// indesign source
      var destination = File("");
      var sourceData = File("/c/xampp/htdocs/project/data/csv/data1.csv"); csv file

        //Create a new document.
        var myDocument = app.documents.add();
        //Get a reference to the first page.

        var myPage = myDocument.pages.item(0);
        //Create a text frame.
        var myTextFrame = myPage.textFrames.add();
        var myTextFrame = myPage.textFrames.add({geometricBounds:[60,30,35,85]});
        var myTextFrame1 = myPage.textFrames.add();
        var myTextFrame1 = myPage.textFrames.add({geometricBounds:[110,30,310,170]});

        myDocument.dataMergeProperties.selectDataSource(sourceData);


      myTextFrame.contents = TextFrameContents.placeholderText;
      myTextFrame1.contents = TextFrameContents.placeholderText;

       

      var myDataMergeProperties= myDocument.dataMergeProperties;

      myDocument.dataMergeProperties.mergeRecords();

      //Save the document.
      myDocument.save(new File("/c/xampp/htdocs/project/data/indd/hello2.indd"));
      //Close the document.
      app.documents.item(0).close();


      app.activeDocument.save(File("/c/xampp/htdocs/project/data/indd/he.indd"));
      app.documents.item(0).exportFile(ExportFormat.pdfType, destination);
      doc.close();




      the csv file looks like this when opened in notepad :


      Klant,Content

       

      Johan,LAKDASDMASDASDJASDASDAD

       

      Susan,waLALALALLALALLALALALALALANANANnana

       

      Jack,eensLALALALLALALLALALALALALANANANnana

       

      Daniel,eenLALALALLALALLALALALALALANANANnana

       

      any help would be appreciated!