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
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);
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

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
I can suggest you the following tests:
- 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;
- 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);
}
Regards,
Stef
Telerik

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
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

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

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
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

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
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