EDIT: Please ignore this I just answered my own question, I would just manually assign the path to a var in the DTL to be passed into the decode function

One more quick question, 
The aim was to create a non-specific utility function for use anywhere a PDF needs to be extracted, Instead of passing the field contents in as a string as then writing that to a stream object,  How would I programmatically get the path of the field in question as a string from within a DTL? 

E.g instead of getting the contents of the field at PIDgrpgrp(1).ORCgrp(1).OBXgrp(1).OBX:5(1).5,
I would want to get "PIDgrpgrp(1).ORCgrp(1).OBXgrp(1).OBX:5(1).5" as variable varFieldPath  to pass into the decode function via GetFieldStreamRaw() to give something like:

Set tSC=source.GetFieldStreamRaw(.varBase64,varFieldPath )

Thanks for your help, it's really appreciated :)

Thanks for your reply, I was able to amend my code to render the PDF correctly, so thank you for your help

Class ELHTPRODPKG.Functions.Utility.ExtractPDF Extends Ens.Rule.FunctionSet
{
      ClassMethod DecodeBase64HL7(base64String As %String, Path As %String, FileName As %String)        As %String
      {
             set base64 = ##class(%Stream.GlobalBinary).%New()
             set Oref = ##class(%FileBinaryStream).%New()
            
set Oref.Filename = Path_FileName_".pdf"

             Do base64.Write(base64String)
             Do base64.Rewind()
         
            
While 'base64.AtEnd 
             
{
                   set ln=base64.ReadLine()
                   set lnDecoded=$system.Encryption.Base64Decode(ln)
                   do Oref.Write(lnDecoded)
             }
            Do Oref.%Save()
            return Oref.Filename
     }
}