Page 1 of 1

Import XML into an Indesign Template

Posted: Tue Jul 07, 2020 11:09 pm
by KenCratty
We are attempting to take XML data and import into Indesign to create a job ticket.
I'm doing this with scripting in 2 steps.

//JS FILE for opening template

openTemplate() {

var curFile = File ( "/c/ProductionTickets/IndesignFiles/Production Ticket.indt" );

var curDoc = app.open( curFile );

}

openTemplate();

Then I'm running the command to import the XML file. The XML file is what is traveling in the flow.

//COMMAND JS FILE

main ()
function main () {

$doc.importXML( File($infile) );

}

This is creating an error and stopping the Indesign Configurator.

I'm new to scripting and would appreciate some help.

Re: Import XML into an Indesign Template

Posted: Wed Jul 08, 2020 7:11 am
by jan_suhr
I think it is better to do it the other way around. Let the InDesign file come to the InDesign configurator in the flow.

Then in InDesign you use this script.

Code: Select all

var Name_Of_File = $arg1;
$doc.importXML( File(Name_Of_File) );
Argument 1 in the properties is: /Path to the folder/XML_to_indesign/[Job.NameProper].xml

The XML file travels through the flow from the start, then Injects the template file (Name of that file could be in the XML) and the XML is sent to a folder on disk

You get the error because InDesign is expecting an InDesign file and it can't handle the incoming XML.

Re: Import XML into an Indesign Template

Posted: Wed Jul 08, 2020 1:47 pm
by KenCratty
That worked!

Thank you so much.