You can do basically what you want using scripts extension which hooks your code for postprocessing
https://jsreport.net/learn/scripts