The below example code was provided by Richard at Qvera. I edited it to make it a bit more simple. You must install the itext jar files in Qvera for this to work. Name it like any other file using {s:OBR-3}.pdf or whatever you want to name it in the destination node.
// This mapping uses the itextpdf-5.3.4.jar library found at
// http://itextpdf.com
// copy the jar into the QIE\lib\ folder
// and then configure QIE to include the jar using the
// 'Manage External Libraries' button under 'System Configuration'
importPackage(java.io);
// wrap all lines in OBX-5 to 77 characters or less
// wrapOBX5(77);
// get text out of all OBX-5 (uncommet this and comment out the above line for multiple OBX-5)
var obx5 = 'A NICE HEADER~~';
var instances = message.getAllNodes('OBX-5');
for (var inst = 0 ; inst < instances.length ; inst++) {
obx5 += instances[inst] + "~";
}
// parse into string array
var lines = obx5.split('~');
// convert text to PDF
var byteArrayOutputStream = new java.io.ByteArrayOutputStream();
var document = new com.itextpdf.text.Document();
document.setPageSize(com.itextpdf.text.PageSize.LETTER);
document.setMargins(72, 72, 36, 54);
var font = new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.COURIER, 10);
com.itextpdf.text.pdf.PdfWriter.getInstance(document, byteArrayOutputStream).setInitialLeading(10);
document.open();
//document.add(com.itextpdf.text.pdf.codec.BmpImage.getImage("c:\\sample.bmp"));
var pngmap = new com.itextpdf.text.pdf.codec.PngImage.getImage("C:\\hl7\\in\\cgi-example.png");
pngmap.scaleAbsolute(150, 75);
pngmap.setAbsolutePosition(400, 680);
document.add(new com.itextpdf.text.Chunk("Line One Text\nLine Two Text\nLine Three Text", font));
document.add(pngmap);
document.add(new com.itextpdf.text.Chunk("\n\n\n\n\n______________________________________________________________________________\n\n", font));
for (var i = 0; i < lines.length; i++) {
document.add(new com.itextpdf.text.Chunk(lines[i], font));
document.add(com.itextpdf.text.Chunk.NEWLINE);
}
document.close();
//Get observation date for folder structure
var obsdate = source.getNode('OBR-7');
var year = obsdate.substring(0, 4);
var month = obsdate.substring(4, 6);
var day = obsdate.substring(6, 8);
// create new message with PDF as the content
message = qie.createTextMessage();
message.setNode('/', byteArrayOutputStream.toString('ISO-8859-1'));