0 Replies Latest reply on Mar 25, 2009 8:25 AM by (Saranya_Harikrishnan)

    Scripting: Unable to create images in a new page added:

      Platform OS- Windows<br />Type of script - Javascript<br />Product- Adobe Indesign<br />version 5<br />Adobe CS3 Server Object model<br /><br />Hi<br /><br />I am trying to run a script for placing Images dynamically, the Information of the images being taken from an xml, and then generate the pdf. I have a blank template created, which I open in the script to perform the functions. Kindly have a look at the xml structure that i have added along to understand the problem. <br /><br />The xml structure is as follows<br /><gridpage><br /><classification></classification><br /><Styles><br /> <Style><br />  <Colorways><br />   <Colorway><br />    <Image_1><br />    <Image_2><br />   <Colorway><br />  <Colorways><br /><Style><br /><Styles><br /></gridpage><br />Each Styles con contain several Style.<br />Each colorways can contain several Colorway<br />Each colorway can contain one, or two or three images.<br /><br />The contraints that I have are. Every new style will have to start on a new row, and the images taken from the colorway are added one after the other. If the row of a page exceed the page margins, the next image has to be added on to a new Page. The problem that I face is that, when I try to continue the images of a style to a new page, the first image that has to be added on to the new page, is created in the new page, but the remaining images are placed in the previous page. Kindly excuse me, if you find the formatting of this post a little difficult to read. A little urgent on this issue, any help will be apprecatiated.<br /><br />Thank you in advance<br /><br />The code that was written:<br /><br />var basePath = "D:\\";<br />var xmlPath = basePath +"XML\\";<br />var reportsPath = basePath +"reports\\";<br />var templateName = basePath +"Templates\\template_new.indt";<br />var logFileName = basePath +"logs\\Script.log";<br />var xmlCleanup =true;<br /><br />alert("Start of Execution");<br /><br />try{<br />    var myDocument = app.open (templateName, true);<br />    var userName = "saranya";<br />    var ReportName = "test_21";<br />}<br />catch(e){<br />    logError(e);<br />    throw(e);<br />}<br />var xmlFileName = "D:\\PIM\\XML\\test3_21.xml";<br /><br />try{<br />     var myRoot = myDocument.importXML(File(xmlFileName));<br />     var myFirstPage = myDocument.pages.item(0);<br />     var rootXMLElement = myDocument.xmlElements.item("gridpage");<br />     var XMLinElement = rootXMLElement.xmlElements.item("XMLin");<br />     XMLinElement.importXML(File(xmlFileName));<br />     <br />     placeContent();<br />     for(i=0;i<myDocument.links.length;i++){<br />          myDocument.links.item(i).unlink();<br />     }<br /><br />     myDocument.save(new File(reportsPath+String(userName)+"\\"+String(ReportName)+".indd"));<br />     app.documents.item(0).exportFile(ExportFormat.pdfType, File(reportsPath+String(userName)+"\\"+String(ReportName)+".pdf"), app.pdfExportPresets.item("[Press Quality]"));<br />     //Closing the document.<br />     app.documents.item(0).close();<br />     //app.quit();<br />}<br />catch(e){<br />     logError(e);<br />     throw(e);<br />}<br /><br />alert("End of Execution");<br /><br />function logError(text) {<br />     var file = new File(logFileName);<br />     file.encoding = "UTF8";<br />     file.open("e", "TEXT", "????");<br />     file.seek(0,2);     <br />     file.writeln(text);<br />     file.close();<br />}<br /><br />function writeXMLFile(file, xml) {<br />     if (!(xml instanceof XML)) {<br />          throw "Bad XML parameter";<br />     }<br />     file.encoding = "UTF8";<br />     file.open("w", "TEXT", "????");<br />     // unicode signature, this is UTF16 but will convert to UTF8 "EF BB BF"<br />     file.write("\uFEFF");<br />     file.lineFeed = "unix";<br />     file.write(xml.toXMLString());<br />     file.close();<br />};<br /><br />function getNodeUsingXpath(oStartNode,xPath){<br />     var aSplit = xPath.split ("/");<br />     var oNode = oStartNode;     <br />     for(var i=0; i<aSplit.length; i++){          <br />               oNode = oNode.xmlElements.item(aSplit[i]);     <br />     }          <br />     return oNode;     <br />}<br /><br />function createRectangles(currPage){<br />     var tempPage = Object(Page);<br />     tempPage = currPage;<br />     var newRectangle = tempPage.rectangles.add()<br />     return newRectangle;<br />     }<br /><br />function createContinousPage(currPage,currPageCount, lengthRec, widthRec){<br />     var tempPage1 = myDocument.pages.item(currPageCount).duplicate(LocationOptions.AT_END,currPage);<br />     var OldFrames = myDocument.pages.item(currPageCount+1).rectangles;<br />     for (var j=0;j<OldFrames.length;j++)