Implement a customBeforePrint function