Import XML into an Indesign Template

Post Reply
KenCratty
Newbie
Posts: 9
Joined: Wed Feb 28, 2018 11:13 pm

Import XML into an Indesign Template

Post 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.
jan_suhr
Advanced member
Posts: 592
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Import XML into an Indesign Template

Post 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.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
KenCratty
Newbie
Posts: 9
Joined: Wed Feb 28, 2018 11:13 pm

Re: Import XML into an Indesign Template

Post by KenCratty »

That worked!

Thank you so much.
Post Reply