"PrintDocument Class" does not implement the PrintToFile feature (820644)
The information in this article applies to:
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual C# 2005, Express Edition
- Microsoft Visual C# .NET (2003)
- Microsoft Visual C# .NET (2002)
- Microsoft .NET Framework 2.0
- Microsoft .NET Framework 1.1
- Microsoft .NET Framework 1.0
SUMMARYIn the Microsoft .NET Framework Class Library documentation,
the help topic for PrinterSettings.PrintToFile Property, under the Remarks section, states the following: Note This property is only used by the PrintDialog class and cannot be set programmatically. However,
when you try to set the PrintToFile property programmatically, you do not receive any error.
Additionally, when you set the PrintToFile property to True, the PrintDocument class sends the output to a printer and not to a
file. MORE INFORMATIONThe .NET Framework Class Library includes the PrinterSettings class. You can specify how a document is printed with the PrinterSettings class. You can access PrinterSettings through the PrintDocument.PrinterSettings property. When you set the PrintToFile property of the PrinterSettings class to True, it indicates that the data is printed to a file.
However, when you set the PrintToFile property to True by creating an instance of the PrintDocument class, the data is not printed to a file. This behavior occurs
because the path of the destination file cannot be set by using the PrintDocument class.
Therefore, use the PrintDialog class. PrintDialog provides the required implementation to print the data to a file.
When you create an instance of the PrintDialog class and then set the PrintDialog.AllowPrintToFile to True, the Print to file option is enabled on the Print dialog box when
it appears. When you select the Print to file option, you are
prompted for a file name. The data is then printed to the destination file that
you specify as the output file name.
For more information, visit the PrintDialog Class Web site that is mentioned in the "References" section of this
article.REFERENCESFor more information, visit the following Microsoft
Developer Network (MSDN) Web sites:
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbvs2005swept kbvs2005applies kbProperties kbdocerr kbWindowsForms kbprint KB820644 kbAudDeveloper |
---|
|