SSRS报告流式传输为图像和打印不符合PDF导出

时间:2017-08-29 18:15:52

标签: c# .net reporting-services webforms console-application

我们有一个客户端将SSRS报告流式传输到两个应用程序中,一个是控制台,第二个是WinForms应用程序。控制台应用程序自动为用户生成最新报告,并可选择将同一报告自动打印到默认选定的打印机。将报表导出为PDF时,报表看起来很完美,但在自动打印报表时,文本大小调整似乎会略微缩小,文本间距会减小,并且某些放置与自动生成的PDF相比会有所不同。

当自动打印报告时,我们将报告流式化为图像,然后创建自定义PrintPage方法以创建矩形,然后将图像设置在矩形内,然后将图像发送到打印(请参阅下面的代码)。 / p>

private void PrintPage(object sender, PrintPageEventArgs ev)
    {

        var pageImage = new Metafile(_mStreams[_currentPageIndex]);

        // Adjust rectangular area with printer margins.
        var adjustedRect = new Rectangle(
            ev.PageBounds.Left - (int)ev.PageSettings.HardMarginX,
            ev.PageBounds.Top - (int)ev.PageSettings.HardMarginY,
            ev.PageBounds.Width,
            ev.PageBounds.Height);

        // Draw a white background for the report
        ev.Graphics.FillRectangle(Brushes.White, adjustedRect);

        // Draw the report content
        ev.Graphics.DrawImage(pageImage, adjustedRect);

        // Prepare for the next page. Make sure we haven't hit the end.
        _currentPageIndex++;
        ev.HasMorePages = (_currentPageIndex < _mStreams.Count);

    }

当完成该过程时,页面的边距和大小匹配,但显然文本在自动打印副本上的显示方式有所不同。下面是两个报告的屏幕截图,您可以看到一些文本的间距和位置与自动生成的PDF报告略有不同。当这个较大的50页以上的文档中,自动生成的PDF包含比图像导出更多的页面时,此问题会对报告产生更多影响。

自动生成屏幕截图

Auto Generated Screen Shot

自动打印屏幕截图

Auto Printed Screen Shot

非常感谢您对此的任何帮助。谢谢。

1 个答案:

答案 0 :(得分:0)

所以我通过抓取旧的打印功能来支持使用Adobe自动打印最近生成的报告。我的问题的关键在于将报告重新导出为SSRS中的图像。这导致调整所有格式和样式以匹配该格式。