I need to find a way to gain access to the name of the printer port when
trying to print.

What I am trying to do is make sure that the user does not print to an
electronic format. For example PDF, Microsoft Office Image Writer,
PaperPort, etc. I only want the user to be able to print directly to a
physical printer.

It is possible for the user to change the name of the printer. For example
the default name for the Adobe PDF printer is "Adobe PDF" but this name can
be changed by the user to something like "Adobe P.D.F." This would prevent
me from being able to halt printing based on the printer name.

BUT!! The PrinterSettings.OutputPort (Which is not public) can not be
changed as easily. I would like to be able to get that value so I can check
that to make sure that the user is not printing to PDF, etc.

Does anyone have any clues??

Thanks,
Mike

Here is a small code snipet:
        PrintDocument pd = new PrintDocument();

        while( true )
        {
                PrintDialog dlg = new PrintDialog();
                dlg.PrinterSettings = pd.PrinterSettings;
                dlg.AllowCurrentPage = false;
                dlg.AllowSelection = false;
                dlg.AllowSomePages = false;
                dlg.AllowPrintToFile = false;
                dlg.PrinterSettings.Copies = 1;
                dlg.PrinterSettings.DefaultPageSettings.Landscape = true;
                dlg.UseEXDialog = false;

                if( dlg.ShowDialog() == DialogResult.OK )
                {
                        // Here we check to see if the user is attempting to
print
                        // to a printer that we won't accept. (PDF, etc.)
                        string temp =
pd.PrinterSettings.PrinterName.ToLower();
                        if( temp.IndexOf( "pdf" ) > -1 ||
                            temp.IndexOf( "image writer" ) > -1 ||
                            temp.IndexOf( "paperport" ) > -1 )
                        {
                                MessageBox.Show( "Invalid printer type.
Please select a different printer." );
                        }

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to