global class MyActionable_LeadSourceColumnRepeater implements cadmus_core.AbstractBeforeWithDataSourcesActionable {

    global void execute(cadmus_core__Actionable__c actionable, Id docConfig, Id objectId, Map<String, Object> inputMap, Map<String, Object> dsMap, cadmus_core.ConvertController.ConvertDataModel cdm) {
    
        //get the DataSource from PDF Butler
        Object leadSourcesObj =  dsMap.get('00D2p000000QL9s_a022p00000YNpp5');
        System.debug('leadSourcesObj: ' + leadSourcesObj);
        //get the data from the DataSource
        List<Map<String,Object>> leadSources = ((cadmus_core.ListWrapper)(leadSourcesObj)).data;
        System.debug('leadSources: ' + leadSources);
        
        //prepare the suffix for the columns in the rows
        Map<String,String> suffix = new Map<String,String>();
        Integer counter = 0;
        for(Map<String,Object> leadSource : leadSources) {
            if(counter != 0) {
                suffix.put((String)leadSource.get('LeadSource'), '_' + counter);
            } else {
                suffix.put((String)leadSource.get('LeadSource'), '');
            }
            
            counter++;
        }
        
        //Get Leads
        List<Map<String, String>> leadList = new List<Map<String, String>>();
        //We use a SOQL in the class as an example that the data can come from a PDF Butler DataSource or can be retrieved in the Class
        //	This also means that the data can come from a callout, a JSON file or ...
        List<Lead> leads = [SELECT Id, Name, LeadSource From Lead];
        for(Lead ld : leads) {
            Map<String, String> leadItem = new Map<String, String>();
            //Create the columns empty, we will overwrite the column in a few lines from now
            for(String val : suffix.values()) {
        		leadItem.put('Item' + val, '');
            }
            
            //Put the real data
        	leadItem.put('Name', ld.Name);
        	leadItem.put('Item' + suffix.get(ld.LeadSource), 'Yes');
            //If you have more fields to handle, add them here
            
            leadList.add(leadItem);
        }
        
        cadmus_core.ListWrapper dsLeads = new cadmus_core.ListWrapper();
        dsLeads.data = leadList;
        
        //put back the data into the list of data to sent to PDF Butler
        dsMap.put('00D2p000000QL9s_a022p00000YNppA',dsLeads);
    }

}