Measure the inside dimension of the door opening first and let us know.
Does a modern door frame with DIN dimensions fit in there at all?
How big is the casing, that is the lateral overlap?
The old door frame was plastered in. Looks like it’s from the GDR to me. Western doors don’t fit into GDR door openings. They were smaller, so you have to enlarge the door size. It may be that you have to plaster a bit on the side first so that the new frame fits and is flush with the wall. I wouldn’t do it just with expanding foam.
But send the measurements first.