To print to file, you need to use the fd field in printer parameter of the print callback, usually fd can be use to store the file pointer, so you can use it to write to file.
Remember to open file prerior to call the print_object method, and close file after this method.