我想将数据设为图像而不是文本,以便用户无法在rdlc报告中复制pdf中的文本。
public FileResult DownloadArticle(int id)
{
SignalRDataContext srcontext = new SignalRDataContext();
LocalReport localReport = new LocalReport();
localReport.ReportPath = Server.MapPath("~/Report/Report1.rdlc");
ReportDataSource reportDataSource = new ReportDataSource();
localReport.EnableExternalImages = true;
reportDataSource.Name = "DataSet1";
reportDataSource.Value = srcontext.Articles.Where(x => x.ArticleID == id).Select(x => new { x.code, x.Article_Name }).ToList();
localReport.DataSources.Add(reportDataSource);
string reportType = "pdf";
string mimeType;
string encoding;
string fileNameExtension = "pdf";
Warning[] warnings;
string[] streams;
byte[] renderedBytes;
renderedBytes = localReport.Render(reportType, "", out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
Response.AddHeader("content-disposition", "attachment;filename=Membership." + fileNameExtension);
return File(renderedBytes, fileNameExtension);
}
答案 0 :(得分:0)
尝试将报告类型和扩展名更改为TIFF。 SQL Server Reporting Services supports reports using the TIFF format
public FileResult DownloadArticle(int id)
{
...
string reportType = "tiff";
...
string fileNameExtension = "tiff";
...
}