i trying xml import automatically startup script when document loaded. successful in getting of content populate, images being ignored. works, including images, when manual 'import xml' through ui, or through manual script.
below manual script:
var mydocument = app.activedocument; var xmlfile = file('/c/full/path/to/data.xml'); mydocument.importxml(xmlfile);
but goal on startup. below startup script:
#targetengine "session" app.addeventlistener('afteropen', function(myevent) { if (myevent.target.constructor.name !== 'document') { return; } var mydocument = myevent.target; var xmlfile = file('/c/full/path/to/data.xml'); mydocument.importxml(xmlfile); });
below xml tag image:
<image href="file:///c:/full/path/to/image/02.png" />
i'm wondering if there issue 'afteropen'
event callback, , that's reason why works manually using same method, not in startup script.
i able around issue avoiding event listener altogether.
main(); function main () { // create path file object var curfile = file('/c/path/to/file.indd'); var xmlfile = file('/c/path/to/data.xml'); // close app if files don't exist if (!curfile.exists || !xmlfile.exists) { app.quit(saveoptions.no); } // open file var curdoc = app.open(curfile); // import xml curdoc.importxml(xmlfile); // create new file object var pdffile = new file(curfile.parent + '/' + curfile.name + '.pdf'); // export pdf curdoc.exportfile(exportformat.pdf_type, pdffile); // close app app.quit(saveoptions.no); }
Comments
Post a Comment