There was no change in driveshaft length (or transmission length) 1999 -2000.
Ford changed driveshaft style for the 2001 MY (I think only on Supercab trucks), but it wasn't a length change (they switched from a steel driveshaft to aluminum along with changing the t-case rear flange size). They also applied a TSB for the aluminum driveshaft on 1998 to 2000 models due to a slip-spline lubrication issue causing a "thump" when starting from a stop, so some '98-'00 might have the aluminum driveshaft, others will still be the steel shaft.
However there was a length change between 1997-1998 on Reg Cab trucks due to the cab being stretched 3" for '98.
So if your '04 is a Regular Cab, any rear driveshaft from '98-'11 Reg Cab should fit, but make sure it comes from a truck having the same bed length as yours (6' or 7').
Also be aware Ranger BW1354 t-cases have different front output yokes 1997-1998 (the earlier u-joint style being more desirable if you have any sort of locking hubs on the front axle). Whichever year t-case you have, you'll need a front driveshaft from the same side of that year split (I think you might also be able to swap the front output yoke, but I can't say for sure).
Just FYI, Dorman isn't to be trusted as a resource, they're probably one of the worst (I've gotten parts from them that don't fit about as often as ones that do). Instead I usually use the Rockauto website or car-part.com.