I have done this a few times. I learned the process back in the 90s from watching a show on the old TLC channel back when it was about learning rather than all the jew garbage of today. The show was kind of faggy but it was informative. I think it was called "Furniture on the Mend" and two faggy guys showed basic furniture repair and improvement. I'm sure you can find the show online. It was also named "Furniture on the Go" at a different time.
One great tip from them was to start stapling from the middle working out on both sides when reattaching the fabric and cambric material so you can keep it properly stretched and even. This also helps manage the foam better. Another tip was to make your replacement foam slightly larger than the one you are replacing since the old foam has changed shape from years of being compressed. Doing this will prevent saggy gaps from forming when the new foam shrinks down.
Unrelated to your task but still a neat thing was their use of old shellac records to make shellac coatings for wood. They would break up an old 78 record and add ethanol to it and turn the record into a thick shellac that they would finish wood with. Pretty cool but it's probably cheaper to buy prepared shellac since most people don't have any old 78 shellac records to use. It was a neat idea though.
Good tips thanks!