web stats
Mirth Community - View Single Post - Hl7 message "PDF file Size" contains more than one block fails create pdf
View Single Post
  #1  
Old 06-10-2019, 07:50 AM
midavies midavies is offline
Mirth Newb
 
Join Date: Dec 2017
Posts: 8
midavies is on a distinguished road
Default Hl7 message "PDF file Size" contains more than one block fails create pdf

I'm Newbie, no error generated - something not quite right with global variable - any ideas will be much appreciated

function to re-create pdf file from message received: when hl7 message contains one block file is created ok, but not when multiple block

var pdfBytes = [];

function DecodeBase64_3(base64pdf, filename, total, index) {

//var pdfBytes = org.apache.commons.codec.binary.Base64.decodeBase6 4(msg['OBX']['OBX.5']['OBX.5.1'].toString());
var pdfBytes0 = org.apache.commons.codec.binary.Base64.decodeBase6 4(base64pdf);
if(index == 1)
{
pdfBytes.length = 0;
pdfBytes = pdfBytes0.slice(0);
}
else
{
pdfBytes.concat(pdfBytes0);

}
//org.apache.commons.io.FileUtils.writeByteArrayToFi le(new java.io.File('C:/HL7/PDFBOX/'+UUIDGenerator.getUUID()+'.pdf'),pdfBytes,true);
if (total == index)
{
org.apache.commons.io.FileUtils.writeByteArrayToFi le(new java.io.File('C:/HL7/PDFBOX/' + total + index +filename),pdfBytes,false);
}
}
Reply With Quote