Most Windows printer drivers have a 'print to file' check box in the 'print' dialogue. If this is selected, it causes the printer driver to write all the data and control sequences to a selected file (you will be prompted to provide a full path name) instead of sending the data and control sequences to the target device.
If you are not using Windows, then I assume that other operating systems will provide similar facilities.