In this paper, an advanced preoperative planning framework for spinal fusion is presented. The framework is based on spinal pedicle data obtained from computed tomography (CT) images, and provides optimal insertion trajectories and pedicle screw sizes. The proposed approach begins with a safety margin estimation for each potential insertion trajectory that passes through the pedicle volume, followed by procedures to collect a set of insertion trajectories that satisfy operation safety objectives. Among the trajectory candidates, the insertion trajectory, which maximizes the insertable depth of a pedicle screw into the vertebral body, is then chosen as optimal, because the insertable depth enhances the strength of the transpedicular screw-vertebra interface after spinal fusion surgery. The radius of a pedicle screw was chosen as 70% of the pedicle radius. This framework has been tested on 68 spinal pedicles of 8 patients requiring spinal fusion. It was successfully applied, resulting in an average success rate of 100% and a final safety margin of 2.11±0.17mm.