Skip to main content
Participant
September 6, 2023
Question

DataMerge DataSource from String

  • September 6, 2023
  • 2 replies
  • 334 views

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

This topic has been closed for replies.

2 replies

Loic.Aigon
Legend
September 6, 2023

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

 

Inspiring
September 6, 2023

 

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