This is a migrated thread and some comments may be shown as answers.

print report in c# winforms not working anymore since the latest telerik update

10 Answers 916 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Danilo
Top achievements
Rank 1
Danilo asked on 09 Mar 2016, 10:26 AM

Hello everyone

I'm using Telerik ReportViewer for about one or two years now without any problems. But since the last update, I'm not able to print a report using the printer name property. I'm using the following code to print a report:

IReportDocument repDocList = new Fertigungsliste("85856917", "1");
 
// set printer settings
PrinterSettings printSet = new PrinterSettings();
printSet.Copies = 1;
printSet.PrinterName = @"\\bbfs\ADM51";
 
// create print controller
PrintController printCtrl = new StandardPrintController();
 
// create report processor
ReportProcessor repProc = new ReportProcessor();
repProc.PrintController = printCtrl;
 
InstanceReportSource repSrc = new InstanceReportSource();
repSrc.ReportDocument = repDocList;
 
repProc.PrintReport(repSrc, printSet);

Unfortunately this code doesn't print the report anymore. If I delete

printSet.PrinterName = @"\\bbfs\ADM51";

it works. Then it uses the default windows printer. But this does not help me. I need to set the printer name like in the example above.

Is there a bug in the latest version of reporting?

Suggestions appreciated

Regards,
Danilo

10 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 12 Mar 2016, 01:35 PM
Hello Danilo,

The following code snippet works as expected on my machine which is connected to the network printer specified by name:
IReportDocument repDocList = new Report1();
 
 // set printer settings
 PrinterSettings printSet = new PrinterSettings();
 printSet.Copies = 2;
 printSet.PrinterName = @"\\the name of our network printer";
 
 // create print controller
 PrintController printCtrl = new StandardPrintController();
 
 // create report processor
 ReportProcessor repProc = new ReportProcessor();
 repProc.PrintController = printCtrl;
 
 InstanceReportSource repSrc = new InstanceReportSource();
 repSrc.ReportDocument = repDocList;
 
 repProc.PrintReport(repSrc, printSet);
If the printer is not reachable or valid, there must appear a PrintDialog requesting you to select a valid printer. Thus check if the print operation is failing due to the machine. Please double-check the name of the printer and if the machine is connected to that printer.

The machine's Event Viewer may contain more details about the error on print. Please post the error message in order to provide you more accurate suggestions.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Danilo
Top achievements
Rank 1
answered on 14 Mar 2016, 09:03 AM

Hi Stef

Thank you for your answer.

As I said, before the last Telerik update it worked for me as well. There is no PrintDialog popping up so the printername is correct I guess. The print job does not appear in the printer queue. We haven't done any changes to our printers or to the network, I checked this with our system administator.

There is also no error/warning/information about this in the event viewer. My computer is connected to the network and also to the printer. When I paste "\\bbfs\ADM51" in the addressbar of the explorer, it opens the printer queue of this printer. I'm also able to print documents from e.g. MS Word/Excel etc. using exactly this printer name.

Do you have any further suggestions?

Regards,
Danilo

0
Stef
Telerik team
answered on 16 Mar 2016, 05:27 PM
Hi Danilo,

I can suggest you the following tests:
  1. Test displaying the report to verify the report can be previewed without errors. For the purpose add a WinForms ReportViewer - How to: Add report viewer to a Windows Forms' Form;
  2. Test printing other content with the same PrinterSettings which will let you know if the issue is related to the printer machine and how it is specified. For example use the following code snippet:
    public Form1()
          {
              InitializeComponent();
          }
     
          private void button1_Click(object sender, EventArgs e)
          {
              PrintDocument pd = new PrintDocument();
              pd.PrintPage += new PrintPageEventHandler(PrintPage);
              PrintDialog pdi = new PrintDialog();
              pdi.Document = pd;
     
              // create print controller
              PrintController printCtrl = new StandardPrintController();
              // set printer settings
              PrinterSettings printSet = new PrinterSettings();
              printSet.Copies = 2;
              printSet.PrinterName = @"\\safeqorssof01\Telerik Default Printer";
     
             
     
              pd.PrinterSettings = printSet;
              pd.PrintController = printCtrl;
              pd.Print();
          }
          void PrintPage(object o, PrintPageEventArgs e)
          {
              int x = SystemInformation.WorkingArea.X;
              int y = SystemInformation.WorkingArea.Y;
              int width = this.Width;
              int height = this.Height;
     
              Rectangle bounds = new Rectangle(x, y, width, height);
     
              Bitmap img = new Bitmap(@"C:\Pictures\ab85_r2d2_usb_hub.jpg");
     
              this.DrawToBitmap(img, bounds);
              Point p = new Point(100, 100);
              e.Graphics.DrawImage(img, p);
          }
Let us know the result of both tests.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Danilo
Top achievements
Rank 1
answered on 17 Mar 2016, 08:18 AM

Hi Stef

The report can be display in a ReportViewer without any problems.
I also tried the code you provided to print another document. This does not print anything as well. The printer name is correct.

Do you need some more information or do you have any other suggestions?

Regards,
Danilo

0
Accepted
Stef
Telerik team
answered on 17 Mar 2016, 08:39 AM
Hello Danilo,

If the first suggested test is successful - the report is displayed, this excludes the report as source of the problem.
If the second test fails - printing a PrintDocument, this implies there is an issue with the given PrinterSettings, which is out of the scope of the reporting engine. 

 My suggestions is to test connecting other printer to the machine and test printing with it. You will have to check with your system administrator if there are any connectivity issues, the name of the printer machine, the printer machine's drivers and other settings that may prevent the silent printing of documents.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Danilo
Top achievements
Rank 1
answered on 17 Mar 2016, 09:53 AM

Hello Stef

Okay, I'll test it with our system administrator in the afternoon. I'll give you a feedback.

Regards,
Danilo

0
Danilo
Top achievements
Rank 1
answered on 17 Mar 2016, 12:49 PM

I guess I found the problem. I'm using Windows 10. I tried the same code I posted with a Windows 7 computer. It works on Win7. Is this a Telerik related problem or am I unable to print documents using C# and Win10?

Regards,
Danilo

0
Stef
Telerik team
answered on 18 Mar 2016, 06:02 PM
Hi Danilo,

The second suggested test can give you information if the issue is related to reports or the printer machine. If any document cannot be printed from the Windows10 machine, you will have to check how the printer machine is connected and if its drivers require update.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Philipp
Top achievements
Rank 1
answered on 21 Jun 2016, 11:50 AM

Hi,

did you find a solution to this problem? I have the same problem when using the Telerik PdfViewer to print to a network printer. Strangely enough, printing rtf, docx, etc. using the radrichtextbox works.

Best regards,

Philipp

0
Stef
Telerik team
answered on 21 Jun 2016, 03:54 PM
Hi Philipp,

Please test to print a random PDF file by using the printer machine that refuses to print PDF files sent by the Viewer. You can test with a PDF reader or code.
Check the machine's event viewer for any errors logs and if other machines connected to the same printer machine can print PDF files.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Danilo
Top achievements
Rank 1
Answers by
Stef
Telerik team
Danilo
Top achievements
Rank 1
Philipp
Top achievements
Rank 1
Share this question
or