的ReportViewer呈现一个空的PDF(只是一白页) [英] ReportViewer rendering a empty PDF (Just one white page)

查看:175
本文介绍了的ReportViewer呈现一个空的PDF(只是一白页)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Asp.Net MVC 4项目,我使用的ReportViewer生成一些报告。

I have a Asp.Net MVC 4 project and I'm using ReportViewer to generate some reports.

由于存在具有的ReportViewer MVC中低或无的兼容性,使用Chrome和Firefox,我的做法是呈现一个PDF流中的ReportViewer和简单的返回这样的数据流:

Because there is low or none compatibility with ReportViewer in MVC, using Chrome and Firefox, my approach was render the ReportViewer in a PDF stream and simple returning the stream like this:

// using Microsoft.ReportViewer.WebForms.dll [10.0.0.0].

using (var viewer = new ReportViewer())
using (var bc = new MyBusinessClass())
{
    viewer.LocalReport.ReportEmbeddedResource = @"MyEmbeddedName";

    var dsobj = bc.GetData();

    var ds = new ReportDataSource("DsName", dsobj);
    var ps = new ReportParameterCollection();

    ps.Add(new ReportParameter("ParameterName", DateTime.Now));

    viewer.LocalReport.DataSources.Add(ds);
    viewer.LocalReport.SetParameters(ps);

    string deviceInfo = "some validated info";
    string mimeType, encoding, fileNameExtension;
    string[] streams;
    Warning[] warnings;

    var buffer = viewer.LocalReport.Render("PDF", deviceInfo,
        out mimeType, out encoding, out fileNameExtension,
        out streams, out warnings);

    return File(new MemoryStream(buffer), "application/pdf", "MyPdfName.pdf");
}

我有几个报道已经和所有的渲染罚款。但现在我创建一个新的使用同样的方法,但是当我打开一个PDF是空的,即它只有一个页面,没有任何在本页(空白)。

I have a few reports already and all render fine. But now I'm creating a new one using the same approach, but when I open the action the PDF is empty i.e. it is just one page and there is nothing in this page (is blank).

但是,如果这是不奇怪的是,现在我考同一所用IE(9)为浏览器和报表呈现很好,所以我决定尝试在Firefox和什么也没有了。

But if this isn't weird enough, now I test the same using IE(9) as browser, and the report rendered fine, so I decided to try in FireFox and get nothing too.

问题:

因此​​,这是我不明白,我渲染PDF返回所以之前为什么浏览器可以影响呢?

So this is what I don't understand, I'm rendering in PDF before returning so why the browser can influence this?

可能力的ReportViewer抛出异常,如果有什么差错? 因为现在,没有得到错误只是一个空白页面。

Is possible force ReportViewer to throw exceptions if anything goes wrong? 'Cause now, don't get errors just a empty page.

和最重要的,我怎么能解决这个问题(请在​​浏览器的工作)?

And most important, how can I fix this problem (make work in Chrome)?

推荐答案

这似乎是一个bug在最近的Chrome版本。据报道二零一五年十月一十四日,似乎固定在最近的版本。

This appears to be a bug in recent versions of Chrome. It was reported on October 14th, 2015 and appears to be fixed in recent builds.

对于我来说,更新至Chrome 46.0.2490.80解决了这个问题。

For me, updating to Chrome 46.0.2490.80 solved the issue.

来源: https://开头code。 google.com/p/chromium/issues/detail?id=543018

这篇关于的ReportViewer呈现一个空的PDF(只是一白页)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆