Skip to main content

Documentation

Version: 4.0

Redirecting to File

The PrintToFileName property allows a print job to be redirected to a file rather than printing directly to a physical printer. Usually a .prn file extension is used, as this is the conventional extension for captured print spool data.

The generated file contains the device-specific print stream produced by the printer driver, such as PCL or PostScript instructions. Because the output is printer-driver dependent, the resulting file is intended for later printing using the same printer or a compatible printer. It is not designed for direct viewing or editing.

The following example demonstrates how to redirect a PDF document to a file instead of sending it directly to a printer.

PrintJob printJob = new PrintJob(Printer.Default, pdfFilePath);
printJob.PrintToFileName = prnFilePath;
printJob.Print();
Dim printJob As New PrintJob(Printer.Default, pdfFilePath)
printJob.PrintToFileName = prnFilePath
printJob.Print()
Documentation version