Seems there is FormatUtil.GetVariableFields Method that could be used to obtain field number/name pairs from format.
You need to read your ZPL file to string variable and then send this string value as a parameter to mentioned method.
Hope it helps.
Software Engineer, Kutir Mobility
Posted on behalf of Zebra Technologies