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

11 posts, 1 answers
  1. Danilo
    Danilo avatar
    40 posts
    Member since:
    Sep 2012

    Posted 09 Mar Link to this post

    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

  2. Stef
    Admin
    Stef avatar
    3046 posts

    Posted 12 Mar Link to this post

    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
  3. DevCraft banner
  4. Danilo
    Danilo avatar
    40 posts
    Member since:
    Sep 2012

    Posted 14 Mar in reply to Stef Link to this post

    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

  5. Stef
    Admin
    Stef avatar
    3046 posts

    Posted 16 Mar Link to this post

    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
  6. Danilo
    Danilo avatar
    40 posts
    Member since:
    Sep 2012

    Posted 17 Mar in reply to Stef Link to this post

    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

  7. Answer
    Stef
    Admin
    Stef avatar
    3046 posts

    Posted 17 Mar Link to this post

    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
  8. Danilo
    Danilo avatar
    40 posts
    Member since:
    Sep 2012

    Posted 17 Mar in reply to Stef Link to this post

    Hello Stef

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

    Regards,
    Danilo

  9. Danilo
    Danilo avatar
    40 posts
    Member since:
    Sep 2012

    Posted 17 Mar Link to this post

    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

  10. Stef
    Admin
    Stef avatar
    3046 posts

    Posted 18 Mar Link to this post

    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
  11. Philipp
    Philipp avatar
    5 posts
    Member since:
    Feb 2016

    Posted 21 Jun Link to this post

    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

  12. Stef
    Admin
    Stef avatar
    3046 posts

    Posted 21 Jun Link to this post

    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
Back to Top
DevCraft banner