Error: access to path is denied while exporting rdlc into pdf

Last Reply on Aug 23, 2016 08:53 AM By dharmendr

Posted on Aug 23, 2016 02:49 AM

Hello

I used this code export rdlc with out reportviwer but what i want is to view that rdlc in pdf in a div 

so I can Used this 

<div runat="server" id="PDFDiv">
<object data="abc1.pdf" type="application/pdf" width="400" height="300"> alt : <a href="payslip (5).pdf">test.pdf</a></object>
</div>

 

but that issue is that when i try to make it dynamics so it gives an error of access denied because we can access to client directory..

so I want it save it in server directory without save question pompt and when we click on button pdf will display in side div.

The path will be from server directory to fetch pdf... 

 

Posted on Aug 23, 2016 02:49 AM
Hi @Mujahid,
Please try the following

[Solved] Export ASP.Net Page to PDF and save the PDF on server folder (disk) using C# and VB.Net

It might help you.

Cheers Andrea.

Posted on Aug 23, 2016 02:51 AM

 

ReportDataSource rds = new ReportDataSource("dsSlip", DAL.DAL.GetData("SELECT * FROM PAYSLIP"));


// Variables
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;


// Setup the report viewer object and get the array of bytes
ReportViewer viewer = new ReportViewer();
viewer.ProcessingMode = ProcessingMode.Local;
viewer.LocalReport.ReportPath = Server.MapPath("~/Reports/PaySlip.rdlc");
viewer.LocalReport.DataSources.Add(rds); // Add datasource here


byte[] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);


// Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=" + fileName + "." + extension);
Response.BinaryWrite(bytes); // create the file

Response.Flush(); // send it to the client to download






Thats the code i am using not it is working but exporting to client


Posted on Aug 23, 2016 02:52 AM

Hello Andrea

I have been to there it is exporting from Gridview to PDF  I want from RDLC