【发布时间】:2018-07-05 22:27:04
【问题描述】:
我在 web.forms 站点中使用 vs2017、C#、asp.net 4.6.1 和 Rdlc 14.2
当我直接将其发送到 pdf 时,我有一个单页报告,在一页中
ReportViewer1.DataBind();
Microsoft.Reporting.WebForms.Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
string deviceInfo = "<DeviceInfo>" +
" <OutputFormat>PDF</OutputFormat>" +
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>11in</PageHeight>" +
" <MarginTop>0.5in</MarginTop>" +
" <MarginLeft>0.25in</MarginLeft>" +
" <MarginRight>0.25in</MarginRight>" +
" <MarginBottom>1in</MarginBottom>" +
"</DeviceInfo>";
byte[] writeBinaryBytes = new byte[0];
writeBinaryBytes = ReportViewer1.LocalReport.Render
("Pdf", deviceInfo, out mimeType, out encoding, out extension,
out streamids, out warnings);
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.AddHeader
("content-disposition", "attachment; filename=" + nombreReporte+".pdf");
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.BinaryWrite(writeBinaryBytes);
HttpContext.Current.Response.Flush();
当我在 ReportViewer 中查看时,它在一页中,但如果我将其导出为 pdf 或打印它,则在两页中……这是我打印前的代码
System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
pg.Margins.Top = 50; //hundredths of an inch 0.5" * 100
pg.Margins.Left = 25; //hundredths of an inch 0.25" * 100
pg.Margins.Right = 25; //hundredths of an inch 0.25" * 100
pg.Margins.Bottom = 100; //hundredths of an inch 1" * 100
System.Drawing.Printing.PaperSize size = new PaperSize
{
RawKind = (int)PaperKind.Letter
//hundredths of an inch
, Width = 850 //hundredths of an inch 8.5" * 100
, Height = 1100 //hundredths of an inch 11" * 100
};
pg.PaperSize = size;
pg.Landscape = false;
//pg.PaperSource.RawKind = (int)PaperKind.A5;
ReportViewer1.SetPageSettings(pg);
ReportViewer1.LocalReport.Refresh();
这是aspx页面中的ReportViewer控件:
<rsweb:ReportViewer ID="ReportViewer1" runat="server"
ShowToolBar="true"
ShowFindControls ="false"
ShowCredentialPrompts="true"
ShowDocumentMapButton="true"
EnableEventValidation="fase"
AsyncRendering = "false"
width="100%" />
有什么建议吗?
谢谢 鲁本克
【问题讨论】:
标签: webforms rdlc reportviewer