what is to do to set landscape for a pdf export ?
using of System.Drawing.Printing.PageSettings before a refresh doesn't work.
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);
}
}
In Design View of your report (rdlc
) select report and in the properties pane set the following items in page size
width :11in
height :8.5in
Best way is to pass DeviceInformation during the render of the export.
Check out http://msdn.microsoft.com/en-us/library/ms154682.aspx
You can pass the PageHeight and PageWidth as DeviceInformation, so you can specify 8.5x11 for your landscape format.
Code example below:
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With