SSRS ReportViewer - 如何在导出为PDF时提高图像质量

时间:2014-11-25 22:41:38

标签: pdf reporting-services reportviewer

有一段时间我注意到每当我将报告从ReportViewer控件(Webforms版本)导出为PDF格式时,任何包含的图像都会失去质量并且会略微出现像素化。

然而,它们在ReportViewer中看起来很不错。

根据我的阅读,PDF渲染器将以96 dpi的大小调整任何包含的图像,无论图像最初是什么dpi。

我做了一些挖掘并发现了这篇文章here

我已经在我自己的代码中尝试了这种方法,通过连接一个像这样的按钮

protected void btnExport_Click(object sender, EventArgs e)
    {
        string mimeType, encoding, fileNameExtension;
        Warning[] warnings;
        string[] streams;

        var sb = new StringBuilder(1024);
        var xr = XmlWriter.Create(sb);
        xr.WriteStartElement("DeviceInfo");
        xr.WriteElementString("DpiX", "300");
        xr.WriteElementString("DpiY", "300");
        xr.Close();

        byte[] bytes = ReportViewer1.ServerReport.Render("PDF", sb.ToString(), out mimeType, out encoding,
                                            out fileNameExtension, out streams, out warnings);

        Response.ContentType = "application/pdf";
        Response.AppendHeader("Content-Disposition", "attachment; filename=Test.pdf");
        Response.BinaryWrite(bytes);
    }

与Report Viewer控件中显示的内容相比,这实际上使我的图像在导出的PDF中显得更小。

我的原始图像在300dpi时为600x600,我已尝试按原样使用这些图像,并且在报告中的图像属性上,RDL设计人员将尺寸属性设置为“适合”'并将图像大小调整为0.25英寸x 0.25英寸。同样,在Report Viewer控件中预览模式下看起来都很棒,但导出到PDF时质量会丢失。

我尝试在我的图像编辑器(paint.net)中将图像大小调整为0.25in x 0.25in,并保持300 dpi,但结果仍然没有差异。

我现在只是围成一圈,毫无疑问我错过了一些东西。我希望有一种方法可以为我提供一些帮助吗?

谢谢!

0 个答案:

没有答案
相关问题