Mark the pre-hung door for the opening adding an inch or two for carpet to run underneath the door. Put painter’s tape along the length of their mark (Image 1) and on the plate of the saw (Image 2). Then cut the door along the mark (Image 3). Applying painter’s tape over the mark keeps the door from being marred by the saw and to keep the door from splitting while cutting.
Finally, apply low expansion foam to the spaces between the door and the wall, filling the spaces around the nails first. The foam expands, hardens and keeps the door in place and can be used instead of shims. Cut any excess foam flush to the wall after the foam dries with a straight edge.
Cover the gaps with trim.