Page 1 of 1

PDF export-script to include metadata

Posted: Fri Oct 23, 2015 1:07 pm
by Terkelsen
I could need a little help on this one :-)

I have created a flow, to receive xml-files via a SubmitPoint in Switch. Metadata is attached to the files in the SubmitPoint. The xml-file is then passed on and initiates the injection of a template to InDesign, that creates a PDF using the data from the xml. That works fine, and if I let the InDesign-configurator create the PDF, the metadata from the SubmitPoint is still present in the resulting PDF.

However, for different reasons I need to create the PDF using a script run via the InDesign Configurator. This is partly because I need both the PDF and the InDesign-dokument filled out with the data from the xml, and because I need to name the files depending on information in the xml. The script exports both a PDF and the InDesign document, so this works fine as well. The only problem is, that the PDF and the InDesign-document created by the script no longer contains the metadata from the SubmitPoint.

Can anybody help me with a script that will include the metadata from the SubmitPoint into the resulting PDF and InDesign documents created by my script?

Re: PDF export-script to include metadata

Posted: Fri Oct 23, 2015 3:10 pm
by gabrielp
So it sounds like your script is creating a new file/job and sending it out, along with the original switch job which is the InDesign file.

If the job you're running through the script has the dataset you need, you can certainly set that dataset on new jobs you create within the script. It might be as easy as doing a var myDataset = originalJob.getDataset('myTag'); and newJob.setDataset('newTag', myDataset);. A simpler but less elegant solution would be to do an export metadata before your script, and then do an XML pickup after the script (with the new PDF).

Re: PDF export-script to include metadata

Posted: Sun Oct 25, 2015 9:30 am
by Terkelsen
I'm a novice on JavaScript so it's kind of trial and error :-/

originalJob is undefined so I tried activeJob and myDoc with the same result. Application.activeJob returns an "Script returned error: /tmp/SWITCH_applescript__1fe81aef:236:248: execution error: Adobe InDesign CC 2015 got an error: Object does not support the property or method 'activeDocument' (55).

Any other ideas of how to refer to the actual open document in InDesign?

Re: PDF export-script to include metadata

Posted: Mon Oct 26, 2015 6:25 pm
by gabrielp
I haven't done any InDesign scripting and I'm unsure of what you can get (Switch-related) within InDesign, but I doubt it's much.

An easy solution to this would be to export the metadata before you send it into this InDesign script, then do an XML pickup afterward. If you're creating several files, you can do an Inject with the original metadata file acting as a repository. You still have the problem of matching the PDF to the XML file to pickup, but if your InDesign script kept the PDF file names consist ant, you could rename your metadata files to pickup to match them.

I wish I could give you a better answer but that's about all I can contribute without seeing the flow.

Re: PDF export-script to include metadata

Posted: Thu Dec 03, 2015 2:21 pm
by jugganaut
There are a bunch of standard variables that you can use in an InDesign script that will reference Switch variables - take a look at the switch manual for those. Active document is referenced by using $doc

The way to export whatever you want is to use a separate script for just the export functionality. And to push your metadata through, you might have to add it into private data for that particular job.

I had some of the same difficulty and there's a thread (that you may have already found ) that I was a part of that describes more of this in depth - just search my username...