我想在rdlc报告中将数据作为图像类型(pdf)

时间:2015-09-30 06:24:03

标签: asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 c#-4.0 model-view-controller

我想将数据设为图像而不是文本,以便用户无法在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);
    }

1 个答案:

答案 0 :(得分:0)

尝试将报告类型和扩展名更改为TIFF。 SQL Server Reporting Services supports reports using the TIFF format

public FileResult DownloadArticle(int id)
{
    ...
    string reportType = "tiff";
    ...
    string fileNameExtension = "tiff";
    ...
}