Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
guys i have RDCL report i want to convert this report to Temp PDF, then print this temp PDF 5 times , i am using the below code, it is view the report as PDF but when i print
appear like bytes and not clear , any help please ?

What I have tried:

 ReportViewer1.ProcessingMode = ProcessingMode.Local;
            ReportViewer1.LocalReport.ReportPath = "Doctor_form.rdlc";
            this.ReportViewer1.LocalReport.SetParameters(parameters);
            ReportViewer1.LocalReport.Refresh();
            Warning[] warnings;
            string[] streamIds;
            string mimeType = string.Empty;
            string encoding = string.Empty;
            string extension = string.Empty;

            byte[] bytes = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
Response.Buffer = true;
            Response.Clear();
            Response.ContentType = mimeType;
            Response.BinaryWrite(bytes);
            Response.Flush();
Posted
Updated 27-Nov-18 5:08am

1 solution

It's coming up bytes in the browser because you're not telling the browser what type of content it's getting. You're setting the ContentType to an empty string instead of "application/pdf".
 
Share this answer
 
Comments
Richard Deeming 27-Nov-18 11:17am    
The Render[^] method should set that to the correct value.
loai_maane 27-Nov-18 11:27am    
thanks guys , but dear Dave as Richard told render will set the value . any options guys please ?
Dave Kreskowiak 27-Nov-18 11:39am    
Yeah, but the behavior you're describing suggests it's not being set.

Step through the code in the debugger and execute it line by line.
loai_maane 27-Nov-18 11:49am    
thanks Dave I will try , but how can I print the temp PDF and I want to print it 5 copies
Richard Deeming 27-Nov-18 14:24pm    
You can't. Neither the code running on the server, nor Javascript running on the client, can force the user to print a file, let alone control how many copies are printed.

Imagine what would happen if that were possible. Every prank or malicious site you visited would start printing out hundreds of copies of useless junk that you didn't want to print. Even printer manufacturer's sites would probably start printing out page after page of solid colour to drain your ink and force you to buy more.

All you can do is send the file to the user. They can then choose whether to save it for later; whether to print it out; and how many copies to print.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900