1

I’m looking for a way to inject custom data inside IDML files via scripting, but I’m not sure that it’s possible.

The IDML specification states “IDML supports the inclusion of new scripting objects and properties added by InDesign plug-ins.”, but there is no mention about scripting.

I already tried adding a custom variable to the TextFrame object but with no luck (apparently the object structure is immutable).

Is there any way to do this without having to write a plugin?

It should be possible to add custom data to XMP (https://indisnip.wordpress.com/2010/09/07/storing-custom-data-into-indesign-file-xmp/) but that would require a lot more work because I would have to reference every object in some way and their custom values. Plus, I have to check XMP specs because I’m not sure if there are limitations in size for custom data (that could be a problem).

1

You can make use of scripting labels to save information in your idml file.

// create a new doc
var doc1 = app.documents.add();
// add a label
// everything can have a scripting label
// textFrames, ovals, pages, swatches ...
doc1.label = 'foo';
// save the file
doc1.save(new File('~/Desktop/doc1.indd'));
// export the idml file
doc1.exportFile(ExportFormat.INDESIGN_MARKUP, new File('~/Desktop/doc1.idml'), false);
// close the first document
doc1.close();
// open the idml file
var doc2 = app.open(File('~/Desktop/doc1.idml'));
// read the label
$.writeln(doc2.label); // returns 'foo'
  • I didn't know about the existence of the "label" property. Digging inside the JS APIs, I found out that the label property is available also for TextFrame elements and its value is indeed saved in the IDML file. Thanks! – paul.ago Mar 28 '17 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.