[c#]Choose the printer by code RRS feed

  • Question

  • Hi all Smile

    I've this problem:

    Using CutePdfWriter, i was able to save some reports as pdf file.

    For the reason that the cutepdfwriter is not the default printer, i would like to know how can i manage this situation by code.

    For example, in the printerButton_Click event, go directly to the non default printer.

    Is it possible?

    Many thx in advance Smile

    Tuesday, May 22, 2007 2:20 PM

All replies

  • I've found this simple way:

    PrintDialog pdiag = new PrintDialog();
    pdiag.PrinterSettings.PrinterName = "myPrinterName";

    And this works..

    Now, I need to print to file.

    Is there a way to have a default path where saving file?

    I mean when user press the ok button on printdialog, how can i set an initial directory like an openfiledialog?


    Thursday, May 24, 2007 1:24 PM
  • Use PrinterSettings.PrintFileName.  You don't need the dialog, just use PrintDocument.PrinterSettings.  PrintDialog is still a good idea as an option, just in case the printer name changes some day in the future.
    Thursday, May 24, 2007 6:53 PM
  • Hi and thank you for reply.

    I've already done that but without result.

    This is because im using CutePdf Writer to export my report as a pdf.

    If i use PrintFileName, i was unable to obtain a valid pdf file.
    Friday, May 25, 2007 10:18 AM
  • CutePDF does its own prompting for a filename.  Sloppy.  You'll have to find something else, there's lots of them.
    Friday, May 25, 2007 10:38 AM
  • And may you suggest something else?

    For the reason that im developing a non professional application, im not considering to buy professional software (i mean the most of pdf export or manipulation software).

    Many thx Smile

    Friday, May 25, 2007 10:53 AM