I want to display a print dialog (first setting some attributes like the printer name). When the user clicks OK, I want to pass the printer attributes specified in the dialog to PrintDocument objects later in the program. The code looks something like this:
PrintDialog pdlg = new PrintDialog();
pdlg.PrinterSettings.PrinterName = cbPrt.SelectedItem.ToString(); // Selected from list
static PageSettings PgSets = new PageSettings();
PgSets = pdlg.PrinterSettings.DefaultPageSettings;
In base class:
Dim WithEvents pDoc As New PrintDocument
... (many attributes set)
pDoc.DefaultPageSettings.PrinterSettings.PrintFileName = PgSets .PrinterSettings.PrintFileName
When the specified PrinterName is my HP printer, I don't have a problem. When the printer is an Adobe PDF writer, I get an exception when I try to do anything with the PrintFileName attribute:
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Illegal characters in path.
I basically want to display a print dialog and pass the parameters to PrintDocument objects. The print document objects are in a section of code that can't have any user intervention. Is the PageSettings object the right way to do this? Is there a better way to do this?
Also, I am moving each attribute from the PageSettings object to the PrintDocument individually (aaa.attr = bbb.attr). Is there a way to set them in a block?