I am new to mirth. I want to store the resultset of a select statement into a pdf file with some formatting and in the form of a table if possible. I have started by using a JavaScript reader to create an xml message to store the resultset as a single message using the following code
var dbConn = DatabaseConnectionFactory.createDatabaseConnection ('org.postgresql.Driver','url','username','passwor d');
var result = dbConn.executeCachedQuery("SELECT * FROM table;");
var list = new java.util.ArrayList();
var xmlMsg = '<?xml version="1.0" encoding="utf-8" standalone="no"?><result>'
while(result.next()) {
var code = result.getString(1);
var name = result.getString(2);
var age= result.getInt(3);
xmlMsg += '<row><code>'+code+'</code>';
xmlMsg += '<name>'+name+'</name>';
xmlMsg += '<age>'+age+'</age></row>';
}
xmlMsg += '</result>';
list.add(xmlMsg);
dbConn.close();
return list;
I know I may have to use a document writer for the pdf document. I have seen the transformer mapping the message to variables and using them to create a template for pdf in some examples but in those cases each value is mapped to a variable but here it is not possible as the number of rows changes, there can be about 100 rows etc. Hence, I don't know how to proceed from here. Can anyone recommend what should I do to convert the result set into a pdf file?
I am using Mirth Connect Administrator 2.2.2.6388
var dbConn = DatabaseConnectionFactory.createDatabaseConnection ('org.postgresql.Driver','url','username','passwor d');
var result = dbConn.executeCachedQuery("SELECT * FROM table;");
var list = new java.util.ArrayList();
var xmlMsg = '<?xml version="1.0" encoding="utf-8" standalone="no"?><result>'
while(result.next()) {
var code = result.getString(1);
var name = result.getString(2);
var age= result.getInt(3);
xmlMsg += '<row><code>'+code+'</code>';
xmlMsg += '<name>'+name+'</name>';
xmlMsg += '<age>'+age+'</age></row>';
}
xmlMsg += '</result>';
list.add(xmlMsg);
dbConn.close();
return list;
I know I may have to use a document writer for the pdf document. I have seen the transformer mapping the message to variables and using them to create a template for pdf in some examples but in those cases each value is mapped to a variable but here it is not possible as the number of rows changes, there can be about 100 rows etc. Hence, I don't know how to proceed from here. Can anyone recommend what should I do to convert the result set into a pdf file?
I am using Mirth Connect Administrator 2.2.2.6388
Resultset to pdf
0 commentaires:
Enregistrer un commentaire