Skip to Content
avatar image
Former Member

.NET CrystalReportViewer preset programmatically number of copies on the print dialog

I'm using CrystalDecisions.Windows.Forms.CrystalReportViewer control to preview reports to the end users of my application developed using Microsoft .NET Windows Forms framework 4.0.

I found that setting the property PrinterName on the ReportDocument object change the selected printer on the PrintDialog displayed when user click on the print toolbar item of the Crystal Report Viewer.

There is a way to do the same with the number of copies?

By default number of copies is 1.

I want change the default to 3 for some reports, so the user can confirm or change that on the PrintDialog before print.

There is a way to do this programmatically?

Another related question: when user click on the print button there is some event that notify me? Something like DocumentPrinted event or overriding some methods using a custom inherited CrystalReportViewer control?

I have to do some work only if the user print the document but I cannot find any way to be notified.

Thanks

printerdialog.png (25.3 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    May 03, 2017 at 08:27 PM

    As I said, CR does not save the number of pages in the RPT file so you need to use Windows API's to change them.

    Create your own print button and then you can set those values any way you want using Windows API's.

    Search for KBA 1765153

    It's an example of how to add your own button.

    You can also set them for your printer and then use CopyTo() to copy those settings into the app using your own print button.

    Don

    Add comment
    10|10000 characters needed characters exceeded

  • May 03, 2017 at 01:33 PM

    Hello,

    CR doesn't have an option to save the number of copies in a report. You can get to that property using the Windows API's:

    System.Drawing.Printing.PageSettings page = new System.Drawing.Printing.PageSettings();
    page.PrinterSettings.Copies = 3;

    Then use SetPrinter options in CR using PrintOutputController.

    Search for KBA 2163438, it has a printer test app that has all of this in it.

    And to save them either save the Report name in a database field or you could use a field in the SummaryInfo in the report.

    Parameter test app has a drop down box to get that info as well.

    On the download page Related content area has all of the links:

    https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

    Don

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 03, 2017 at 03:49 PM

    Thanks,

    I have downloaded the sample but all code that change the NumberOfCopies is commented and used on methods that print directly to the printer without preview.

    I don't want to save the number of copies on the report, I want to set them programmatically and not print directly the report but use the CrystalReportViewer to preview it, changing the default value of number of copies on the viewer default PrintDialog.

    What do you mean by "Then use SetPrinter options in CR using PrintOutputController." ?

    I see that I can obtain the PrintOutputController using the readonly property ReportDocument.ReportClientDocument.PrintOutputController

    PrintOutputController inherits from ISCRPrintOutputController and has some methods but none of them seems to give the ability of set the number of copies loading from an object of type System.Drawing.Printing.PageSettings

    Could you help me? What methods of PrintOutputController should I use exactly and How?

    Thanks

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 04, 2017 at 07:23 AM

    Thank you Don,

    I will try to hide default print button and add a custom one combining informations from KBA 1765153 and KBA 2163438

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 16, 2017 at 09:50 AM

    I have hidden the default print button and I have customized printing but I cannot find a way to implement a progress print status dialog like the one of the viewer.

    How can I receive notification of print progress (printing page N of M) and provide to user the capability to cancel printing?

    I want to implement a print progress dialog like the default of the viewer. Can you help me?

    Add comment
    10|10000 characters needed characters exceeded