有没有人找到一种方法以大于 96ppi 的分辨率呈现 Reporting Services 报告?

发布于 2024-09-16 00:34:34 字数 524 浏览 8 评论 0原文

我已尝试了所有我能想到的方法来更改需要渲染为 300ppi TIFF 的报告的渲染参数。

这是使用 URL 方法的几种尝试之一。当我们从 96ppi 变为 300ppi 时,8.5 x 11 图像的尺寸急剧增加,但分辨率仍保持在 96ppi。

//s0550284/ReportServer?/ERecordingReports/Report1&rs:Format=IMAGE&rc:DpiX=300&rc:DpiY=300&rc:PageHeight=11in&rc:PageWidth=8.5in&rs:Command=Render

我们尝试更改 SSRS 配置文件,将默认值从 96ppi 更改为 300ppi,但更改被忽略。

它开始看起来就像有人将 96ppi 硬编码到无法被覆盖的地方。

我们正在运行 SQL Server 2008 R2。

任何关于如何解决这个问题的想法将非常感激。

-汤姆

I've tried everything I can think of to change the rendering parameters for a report that I need to render as a 300ppi TIFF.

Here's one of several attempts using the URL approach. As we went from 96ppi to 300ppi the size of the 8.5 x 11 image increases dramatically, but the resolution remainded at 96ppi.

//s0550284/ReportServer?/ERecordingReports/Report1&rs:Format=IMAGE&rc:DpiX=300&rc:DpiY=300&rc:PageHeight=11in&rc:PageWidth=8.5in&rs:Command=Render

We've tried changing the SSRS configuration files to change the default from 96ppi to 300ppi, but the change is ignored.

It's starting to look like someone hardcoded 96ppi somewhere where it can't be overridden.

We're running SQL Server 2008 R2.

Any thoughts about how to get past this problem would be very much appreciated.

-Tom

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

尸血腥色 2024-09-23 00:34:35

在此处和其他论坛的受访者的帮助下,我发现了一个似乎可以解决我的问题的简单技巧。在我放弃与 SSRS 的斗争后,我想到了这一点。我确信对于 SSRS 处理不同分辨率参数的原因有很多完全有效的理由。坦白说,我不在乎。我只需要按照我指定的尺寸和分辨率生成文档。

这是相关的代码片段(为了简洁起见,删除了错误处理)。我通过 Web 服务接口调用 SSRS,生成报告,并将其呈现为 300 x 300 TIFF。结果暂时保存。它将生成为 96ppi TIFF 并按比例放大。然后我将其读入 BitMap,将分辨率更改为 300 x 300,然后再次写回。完毕。

string deviceInfo = "<DeviceInfo> <OutputFormat>TIFF</OutputFormat> <DpiX>300</DpiX> <DpiY>300</DpiY> <PrintDpiX>300</PrintDpiX> <PrintDpiY>300</PrintDpiY> </DeviceInfo>";
string format = "IMAGE";
Byte[] results;
string mimeType = "image/tiff";

// Generate the report as a TIF
ExecutionInfo ei = new ExecutionInfo();
ei = rsExec.LoadReport(_reportName, historyID);
results = rsExec.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);

string TempFileRSGeneratedTIFF = TempPath + "RSGeneratedTIFF.TIF";

// Save tiff file returned by RS
using (FileStream stream = File.OpenWrite(TempFileRSGeneratedTIFF))
{
    stream.Write(results, 0, results.Length);
}

// Read tif file into bitmap
Bitmap image = new Bitmap(TempFileRSGeneratedTIFF);

// Change the resolution to what it was supposed to be in the first place..
image.SetResolution(300, 300);

// Save the final version of the file
image.Save(DestFileName, System.Drawing.Imaging.ImageFormat.Tiff);

image.Dispose();

With the assistance of respondants here and in other forums, I found a simple hack that seems to solve my problem. It came to me after I gave up the fight with SSRS. I'm sure that there are lots of perfectly valid reasons as to why SSRS handles different resolution parameters as it does. Frankly, I don't give a hoot. I just need my document generated at the size and resolution I specified.

Here's the relevant pieces of code (error handling removed for the sake of brevity). I invoke SSRS via the web service interface, generate the report, and render it as 300 x 300 TIFF. The results are temporarily saved. It will have been generated as a 96ppi TIFF and scaled up. I then read it in into a BitMap, change the resolution to 300 x 300, and write it back out again. Done.

string deviceInfo = "<DeviceInfo> <OutputFormat>TIFF</OutputFormat> <DpiX>300</DpiX> <DpiY>300</DpiY> <PrintDpiX>300</PrintDpiX> <PrintDpiY>300</PrintDpiY> </DeviceInfo>";
string format = "IMAGE";
Byte[] results;
string mimeType = "image/tiff";

// Generate the report as a TIF
ExecutionInfo ei = new ExecutionInfo();
ei = rsExec.LoadReport(_reportName, historyID);
results = rsExec.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);

string TempFileRSGeneratedTIFF = TempPath + "RSGeneratedTIFF.TIF";

// Save tiff file returned by RS
using (FileStream stream = File.OpenWrite(TempFileRSGeneratedTIFF))
{
    stream.Write(results, 0, results.Length);
}

// Read tif file into bitmap
Bitmap image = new Bitmap(TempFileRSGeneratedTIFF);

// Change the resolution to what it was supposed to be in the first place..
image.SetResolution(300, 300);

// Save the final version of the file
image.Save(DestFileName, System.Drawing.Imaging.ImageFormat.Tiff);

image.Dispose();
栩栩如生 2024-09-23 00:34:35

我可以通过编辑 rsreportserver.config 文件在 SSRS 2008 R2 中轻松完成此操作:

      <Extension Name="IMAGE" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering" />
  <Extension Name="TIFF 200 DPI" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering">
    <OverrideNames>
      <Name Language="en-US">TIFF 200 DPI</Name>
    </OverrideNames>
    <Configuration>
      <DeviceInfo>
        <ColorDepth>32</ColorDepth>
        <DpiX>200</DpiX>
        <DpiY>200</DpiY>
        <OutputFormat>TIFF</OutputFormat>
      </DeviceInfo>
    </Configuration>
  </Extension>
  <Extension Name="TIFF 300 DPI" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering">
    <OverrideNames>
      <Name Language="en-US">TIFF 300 DPI</Name>
    </OverrideNames>
    <Configuration>
      <DeviceInfo>
        <ColorDepth>32</ColorDepth>
        <DpiX>300</DpiX>
        <DpiY>300</DpiY>
        <OutputFormat>TIFF</OutputFormat>
      </DeviceInfo>
    </Configuration>
  </Extension>

请注意,我完整保留了原始 IMAGE 扩展名(尽管我没有必要),并添加了对该扩展名的另外两个引用 - 一个在 200 DPI 下和一个 300 DPI 的。所有这三个现在都显示在报表管理器的导出下拉列表中并且可以正常工作。请注意(按照 Microsoft 的示例)我包含了 ColorDepth 属性,尽管 SSRS 会忽略它。另请注意,我在“名称”属性中使用了“语言”参数。我正在看的文章说,如果不包含 Language 参数(未测试),覆盖配置将被忽略。

I was able to do this easily in SSRS 2008 R2 by editing the rsreportserver.config file:

      <Extension Name="IMAGE" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering" />
  <Extension Name="TIFF 200 DPI" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering">
    <OverrideNames>
      <Name Language="en-US">TIFF 200 DPI</Name>
    </OverrideNames>
    <Configuration>
      <DeviceInfo>
        <ColorDepth>32</ColorDepth>
        <DpiX>200</DpiX>
        <DpiY>200</DpiY>
        <OutputFormat>TIFF</OutputFormat>
      </DeviceInfo>
    </Configuration>
  </Extension>
  <Extension Name="TIFF 300 DPI" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering">
    <OverrideNames>
      <Name Language="en-US">TIFF 300 DPI</Name>
    </OverrideNames>
    <Configuration>
      <DeviceInfo>
        <ColorDepth>32</ColorDepth>
        <DpiX>300</DpiX>
        <DpiY>300</DpiY>
        <OutputFormat>TIFF</OutputFormat>
      </DeviceInfo>
    </Configuration>
  </Extension>

Note that I left the original IMAGE extension intact (although I didn't have to) and added two more references to that extension - one at 200 DPI and one at 300 DPI. All three now show up in the export drop down list in Report Manager and work correctly. Note that (by following Micorsoft's example) I included the ColorDepth attribute although SSRS ignores it. Also note that I used the Language parameter in the Name attribute. The article I was looking at says that the override configuration will be ignored if it doesn't include the Language parameter (didn't test it).

心病无药医 2024-09-23 00:34:35

我尝试了 @Chuck Brevitt 的方法,但 Web API 的 Reporting Services 似乎不支持 PDF 设置的 DPI 设置。
通过实验和 Microsoft 注释中的一些提示,我发现这有效:

为了获得更好的图像 PDF 渲染,请像这样传递设备信息:

http://serverName/ReportServer?/pathtoReport/ReportName&InvoiceIdOrOtherParameter=24013&rs:Command=Render&rs:Format=PDF&rs:DeviceInfo=<DpiX>300<%2FDpiX><DpiY>300<%2FDpiY>

I tried @Chuck Brevitt's method, but Reporting Services from the Web API didn't seem to be honouring the DPI settings for PDF settings.
I found by experimentation and some hints in Microsoft notes that this worked:

In order to get better PDF rendering of Images, pass the Device Info like this:

http://serverName/ReportServer?/pathtoReport/ReportName&InvoiceIdOrOtherParameter=24013&rs:Command=Render&rs:Format=PDF&rs:DeviceInfo=<DpiX>300<%2FDpiX><DpiY>300<%2FDpiY>
﹉夏雨初晴づ 2024-09-23 00:34:35

在配置文件中进行更改后尝试重新启动 ReportServer。请点击以下链接。

http://social.msdn.microsoft.com/Forums/sqlserver/en-US/2b1379e1-cbc5-4764-8f39-f043b334244d/rendering-a-report-in-tiff-at -300ppi?forum=sqlreportingservices

我不太确定在导出图像后是否尝试更改分辨率。

Try restarting your ReportServer after making the changes in the configuration file. Follow the below link.

http://social.msdn.microsoft.com/Forums/sqlserver/en-US/2b1379e1-cbc5-4764-8f39-f043b334244d/rendering-a-report-in-tiff-at-300ppi?forum=sqlreportingservices

I am not quite sure about trying to change the resolution once you have the image exported.

自控 2024-09-23 00:34:35

将图像对象设置为外部(报表服务器上的链接)或数据库中,而不是嵌入报表中。

Setup the image object to be external (link on report server) or in the database, versus embedded within the report.

黄昏下泛黄的笔记 2024-09-23 00:34:35

为了 SSRS 2012,我尝试了一切,我的意思是一切。但最终我也放弃了。沿着汤姆的同样路线和大量谷歌搜索,我发现 http: //csharphelper.com/blog/2017/09/change-image-resolution-c/

这是工作模型:

public static string BumpUpResolution(string filename, float dpiX, float dpiY, string processID)
    {
        int oldWidth = 0, oldHeight = 0;

        Bitmap image = new Bitmap(filename);
        oldWidth = image.Width;
        oldHeight = image.Height;

        using (Bitmap bm = new Bitmap(oldWidth, oldHeight))
        {
            Point[] points = {
                             new Point(0,0),
                             new Point(oldWidth, 0),
                             new Point(0, oldHeight),
                         };

            using (Graphics gr = Graphics.FromImage(bm))
            {
                gr.DrawImage(image, points);
            }

            bm.SetResolution(dpiX, dpiY);

            bm.Save(Path.Combine(Path.GetDirectoryName(filename), string.Format("{0}{1}", processID, Path.GetExtension(filename))), System.Drawing.Imaging.ImageFormat.Tiff);
        }

        image.Dispose();
        return Path.Combine(Path.GetDirectoryName(filename), string.Format("{0}{1}", processID, Path.GetExtension(filename)));
    }

I tried everything under the sun for SSRS 2012, and I mean everything. But eventually I gave up on it as well. Along the same lines of Tom and a ton of googling I found http://csharphelper.com/blog/2017/09/change-image-resolution-c/

This is the working model:

public static string BumpUpResolution(string filename, float dpiX, float dpiY, string processID)
    {
        int oldWidth = 0, oldHeight = 0;

        Bitmap image = new Bitmap(filename);
        oldWidth = image.Width;
        oldHeight = image.Height;

        using (Bitmap bm = new Bitmap(oldWidth, oldHeight))
        {
            Point[] points = {
                             new Point(0,0),
                             new Point(oldWidth, 0),
                             new Point(0, oldHeight),
                         };

            using (Graphics gr = Graphics.FromImage(bm))
            {
                gr.DrawImage(image, points);
            }

            bm.SetResolution(dpiX, dpiY);

            bm.Save(Path.Combine(Path.GetDirectoryName(filename), string.Format("{0}{1}", processID, Path.GetExtension(filename))), System.Drawing.Imaging.ImageFormat.Tiff);
        }

        image.Dispose();
        return Path.Combine(Path.GetDirectoryName(filename), string.Format("{0}{1}", processID, Path.GetExtension(filename)));
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文