The easiest way to do this would be to use the QIE functions.
// The qie.readFile() can accept a path to the file, so just passing a string is the easiest way to read a file
var bytes = qie.readFile('c:\\hl7\\Sample Report.pdf');
// qie.base64EncodeBytes() will encode the bytes that were returned from the qie.readFile()
var base64 = qie.base64EncodeBytes(bytes);
// validate the output with a debug statement
qie.debug(base64);
This will read the file and base64 encode the contents.
Once you have the contents you can store them in a parameterMap or messageCache. Then your template can reference the messageCache or parameterMap.
// MessageCache Example
// the node tag for this will be '{mc:encodedFile}'
messageCache.setValue('encodedFile', base64);
// ParameterMap Example
var parameterMap = qie.newParameterMap();
// the node tag for this will be '{p:encodedFile}'
parameterMap.put('encodedFile', base64);
// NOTE: make sure to pass the parameter map into your evaluate template call
var output = qie.evaluateTemplate('template', parametersMap, 'HL7', false, '');