Thread View: adobe.scripting.indesign
1 messages
1 total messages
Started by Saranya_Harikrishnan
Wed, 25 Mar 2009 16:25
Scripting: Unable to create images in a new page added:
Author: Saranya_Harikrishnan
Date: Wed, 25 Mar 2009 16:25
Date: Wed, 25 Mar 2009 16:25
115 lines
4537 bytes
4537 bytes
Platform OS- Windows
Type of script - Javascript
Product- Adobe Indesign
version 5
Adobe CS3 Server Object model
Hi
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.
The xml structure is as follows
<gridpage>
<classification></classification>
<Styles>
<Colorways>
<Colorway>
<Image_1>
<Image_2>
<Colorway>
<Colorways>
<Styles>
</gridpage>
Each Styles con contain several Style.
Each colorways can contain several Colorway
Each colorway can contain one, or two or three images.
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.
Thank you in advance
The code that was written:
var basePath = "D:\\";
var xmlPath = basePath +"XML\\";
var reportsPath = basePath +"reports\\";
var templateName = basePath +"Templates\\template_new.indt";
var logFileName = basePath +"logs\\Script.log";
var xmlCleanup =true;
alert("Start of Execution");
try{
var myDocument = app.open (templateName, true);
var userName = "saranya";
var ReportName = "test_21";
}
catch(e){
logError(e);
throw(e);
}
var xmlFileName = "D:\\PIM\\XML\\test3_21.xml";
try{
var myRoot = myDocument.importXML(File(xmlFileName));
var myFirstPage = myDocument.pages.item(0);
var rootXMLElement = myDocument.xmlElements.item("gridpage");
var XMLinElement = rootXMLElement.xmlElements.item("XMLin");
XMLinElement.importXML(File(xmlFileName));
placeContent();
for(i=0;i<myDocument.links.length;i++){ myDocument.links.item(i).unlink(); }
myDocument.save(new File(reportsPath+String(userName)+"\\"+String(ReportName)+".indd"));
app.documents.item(0).exportFile(ExportFormat.pdfType, File(reportsPath+String(userName)+"\\"+String(ReportName)+".pdf"), app.pdfExportPresets.item("[Press Quality]"));
//Closing the document.
app.documents.item(0).close();
//app.quit();
}
catch(e){
logError(e);
throw(e);
}
alert("End of Execution");
function logError(text) {
var file = new File(logFileName);
file.encoding = "UTF8";
file.open("e", "TEXT", "????");
file.seek(0,2);
file.writeln(text);
file.close();
}
function writeXMLFile(file, xml) {
if (!(xml instanceof XML)) {
throw "Bad XML parameter";
}
file.encoding = "UTF8";
file.open("w", "TEXT", "????");
// unicode signature, this is UTF16 but will convert to UTF8 "EF BB BF"
file.write("\uFEFF");
file.lineFeed = "unix";
file.write(xml.toXMLString());
file.close();
};
function getNodeUsingXpath(oStartNode,xPath){
var aSplit = xPath.split ("/");
var oNode = oStartNode;
for(var i=0; i<aSplit.length; i++){ oNode = oNode.xmlElements.item(aSplit[i]); } return oNode; }
function createRectangles(currPage){
var tempPage = Object(Page);
tempPage = currPage;
var newRectangle = tempPage.rectangles.add()
return newRectangle;
}
function createContinousPage(currPage,currPageCount, lengthRec, widthRec){
var tempPage1 = myDocument.pages.item(currPageCount).duplicate(LocationOptions.AT_END,currPage);
var OldFrames = myDocument.pages.item(currPageCount+1).rectangles;
for (var j=0;j<OldFrames.length;j++)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads