我正在用C#代码成功将SSRS报告呈现为PDF。但是,我需要PDF以横向格式显示,但我无法使其正常工作。
我尝试在DeviceInfo中相应地设置pagewidth和PageHeight,但这似乎没有什么不同。我也把pageSettings弄糟了。
Uri oUri = new Uri(GlobalClass.gReportServerURL);
//Run report
rpt.ServerReport.ReportPath = "/" + sReportName;
rpt.ServerReport.ReportServerUrl = oUri;
paramList.Add(new Microsoft.Reporting.WinForms.ReportParameter ("ClientID", sClientID));
rpt.ServerReport.SetParameters(paramList);
deviceInfo = $@"<DeviceInfo>
<OutputFormat>PDF</OutputFormat>
<PageWidth>11in</PageWidth>
<PageHeight>8.5in</PageHeight>
<MarginTop>.25in</MarginTop>
<MarginLeft>.25in</MarginLeft>
<MarginRight>.25in</MarginRight>
<MarginBottom>.25in</MarginBottom>
</DeviceInfo>";
ms = (MemoryStream)rpt.ServerReport.Render("PDF", deviceInfo, null, out mimeType, out fileNameExtension);
//Write it to disk
bytes = ms.ToArray();
fs = new System.IO.FileStream(sFile, System.IO.FileMode.Create);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
addPDFToList(sFile);
lstKillFiles.Add(sFile);
return sFile;
我希望PDF文件以横向放置,但不是。