I am trying to search and replace some of the text (eg \'Smith, John\') in this pdf form file (header.fdf, I presumed this is treated as binary file):
\'%FDF-1.2
f=open("header.fdf","rb") s=str(f.read()) f.close() s=s.replace(b'PatientName',name)
or
f=open("header.fdf","rb") s=f.read() f.close() s=s.replace(b'PatientName',bytes(name))
probably the latter, as I don't think you are going to be able to use unicode names with this type of substitution anyway