Copy link to clipboard
Copied
Hello,
is it some how possible to use data merge in a script without needing to select an external csv file as the data source?
I would like to extract the fields from a JSON payload and do the data merge within InDesign.
Or is there a way to "skip the selectDataSource-part" and replace the placeholders manually via script?
I hope that I have been able to express myself clearly.
Thanks in advance.
Regards
Lars
Copy link to clipboard
Copied
I suggest:
- convert the file from json format to xml format.
- place xml tags in your indesign document
- keep the xml file name unchanged and update the link in indesign
Copy link to clipboard
Copied
Almost everything is feasible. But I don't think you can create Datamerge Placeholders without loading a CSV file first. Besides the DataMergeFields collection doesn't expose an "add" method, which second that point.
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#DataMergeFields.html
That said, whatever, you will use Datamerge or XML import in a scripted way, it will probably start by manually tagging elements in the layout. Unless you have some deep logic to turn untagged contents to tagged contents.
Loic