Hello Bob and welcome to the forum.
I have no idea what a W2 looks like so my comments may be way off here.
The typical solution to a problem where a field can 'float' up and down in a logical record area is to attempt to find a way to use a preceding string to identify the vertical position of the field, usually establish a known starting point line for othe first line of a record.
I suspect you can't identify a suitable preceding string and have therefore to rely upon the row number but I don't think that will reliably give you what you want in this context. (As you seem to have discovered already ...!)
If you have already looked at the preceding string option and found it wanting I'm not sure what else to suggest but if you can share your test pdf file I would be happy to take a look to see if anything looks like it might provide a way forward for modeling the PDF conversion.