Import XML into Indesign to convert to PDF

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

Import XML into Indesign to convert to PDF

Post by KenCratty »

I'm trying to use a flow that will take the XML and create a document in Indesign. I have my XML file and the Indesign template. It looks like I need a script to open the Indesign file template and import the Indesign file. Can someone help me with this? I don't know scripting.
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Import XML into Indesign to convert to PDF

Post by jan_suhr »

You need the following JavaScript in the InDesign configurator property Command
Then as Argument 1 you specify the name of the XML file.

The incoming jobb to InDesign is the InDesign template file and the XML is easiest picked up from a folder where Switch stored it.

Code: Select all

var NameOfFile = $arg1;
$doc.importXML( File(NameOfFile) );
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 Indesign to convert to PDF

Post by KenCratty »

Thank you. I saw in another post you demo a simple business card flow using your csvXML tool. Can you share that flow?
KenCratty
Newbie
Posts: 9
Joined: Wed Feb 28, 2018 11:13 pm

Re: Import XML into Indesign to convert to PDF

Post by KenCratty »

Here is the document of the flow I built. I'm getting an error 'null is not an object'. Please let me know what I'm doing wrong.
The attachment flow25Doc.zip is no longer available
flow25Doc.zip
(20.81 KiB) Downloaded 548 times
User avatar
Liv
Member
Posts: 31
Joined: Tue May 12, 2020 10:54 pm
Location: Milwaukee, WI USA

Re: Import XML into Indesign to convert to PDF

Post by Liv »

Silly question... how do you get the xml info into the InDesign file? How do you create the fields?
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Import XML into Indesign to convert to PDF

Post by jan_suhr »

Google XML import to InDesign.

You have to set up the template document with text fields that is tagged to receive the 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 Indesign to convert to PDF

Post by KenCratty »

I have been using this script to import xml into Indesign:

Code: Select all

var NameOfFile = $arg1;
$doc.importXML( File(NameOfFile) );
It was working fine until someone updated to Indesign 2020. Now I get this error:
"Cannot handle the request because of a modal dialog or alert is active". Can you help me make the adjustment?
laurentd
Member
Posts: 137
Joined: Wed Mar 13, 2019 2:06 pm

Re: Import XML into Indesign to convert to PDF

Post by laurentd »

It looks like there is a warning dialog open in InDesign (missing links, fonts, etc).
Open your document manually on the Switch server, you should get the same error, then fix it.
For automation, the InDesign document should open without any error or warning.
Laurent De Wilde, Solution Architect @ Enfocus
KenCratty
Newbie
Posts: 9
Joined: Wed Feb 28, 2018 11:13 pm

Re: Import XML into Indesign to convert to PDF

Post by KenCratty »

I opened it and there are no missing fonts or graphics.

When we first built the flow, the version of Indesign did not have an additional menu after you select the XML import. The option were check boxes at the bottom of the election window. Now there is a popup menu for the selections. That is the window we need to resolve in the script.
laurentd
Member
Posts: 137
Joined: Wed Mar 13, 2019 2:06 pm

Re: Import XML into Indesign to convert to PDF

Post by laurentd »

When you manually import an xml in InDesign, you can disable "Show XML Import Options"
You can disable this option then save the InDesign template again.
On my side it works whether this options was checked or not, but who knows.
The first time I ran my flow (on Mac) I also got a dialog telling "osascript wants access to control Adobe InDesign 2020", just had to allow this.
Laurent De Wilde, Solution Architect @ Enfocus
Post Reply