Setting property printer.outputFileName to a nonempty string indicates that printing should be redirected to the specified file.
printer.outputFileName