【问题标题】:Report Viewer Landscape pdf export报表查看器横向 pdf 导出
【发布时间】:2009-07-04 05:01:01
【问题描述】:

如何设置 pdf 导出的横向?

在刷新之前使用 System.Drawing.Printing.PageSettings 不起作用。

        Type tip = reportViewer1.GetType();
        FieldInfo[] pr = tip.GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
        System.Drawing.Printing.PageSettings ps = new System.Drawing.Printing.PageSettings();
        ps.Landscape = true;

       // ps.PaperSource=
        foreach (FieldInfo item in pr)
        {
            if (item.Name == "m_pageSettings")
            {
                item.SetValue(reportViewer1, ps);

            }
        }

【问题讨论】:

标签: pdf reportviewer


【解决方案1】:

最好的方法是在导出的渲染过程中传递 DeviceInformation。

查看http://msdn.microsoft.com/en-us/library/ms154682.aspx

您可以将 PageHeight 和 PageWidth 作为 DeviceInformation 传递,因此您可以为横向格式指定 8.5x11。

下面的代码示例:

Dim warnings As Warning() = Nothing
Dim streamids As String() = Nothing
Dim mimeType As String = Nothing
Dim encoding As String = Nothing
Dim extension As String = Nothing
Dim bytes As Byte()
Dim deviceInf as String

deviceInf = "<DeviceInfo><PageHeight>8.5in</PageHeight><PageWidth>11in</PageWidth></DeviceInfo>"

bytes = ReportViewer1.LocalReport.Render("PDF", deviceInf, mimeType, encoding, extension, streamids, warnings)
Dim fs As New FileStream(FILENAME, FileMode.Create)
fs.Write(bytes, 0, bytes.Length)
fs.Close()

【讨论】:

  • 更改 &lt;PageHeight&gt;&lt;PageWidth&gt; 对我来说非常有效。 1 行修复!
【解决方案2】:

您需要在报表定义中设置报表大小。这是一个有同样问题的人:

http://forums.asp.net/t/1138481.aspx

【讨论】:

    【解决方案3】:

    在报表的设计视图 (rdlc) 中选择报表并在属性窗格中将以下项目设置为 page size

    width :11in
    height :8.5in
    

    【讨论】:

    • 或者,对于欧洲所有使用 A4 的人,宽度:29.7 厘米,高度:21 厘米。
    猜你喜欢
    • 1970-01-01
    • 2011-01-12
    • 1970-01-01
    • 1970-01-01
    • 2014-05-22
    • 1970-01-01
    • 2015-04-12
    • 1970-01-01
    • 2014-10-12
    相关资源
    最近更新 更多