I have a Windows Forms application that has a textbox
, a button
, and 3 ReportViewer
. The 3 ReportViewer
boxes are hidden. When you enter a ShopOrder
into the textbox and click on the button, it will automatically pass the Shop order value as a parameter to all 3 reports, render the report, and once the rendering is complete, render the report as EMF file, print the report.
I have a few variances in my application because I am using ServerReports
in my ReportViewer
and not LocalReport
. But after all these changes, my application prints them all out with no problems.
But the only issue I have is, I am not able to set my page orientation to Landscape
, even though the orientation on my report is Landscape.
So I thought maybe I need to set the deviceInfo
variable's PageWidth
and PageHeight
variables accordingly, so this is what the deviceInfo
variable has:
string deviceInfo =
@"<DeviceInfo>
<OutputFormat>EMF</OutputFormat>
<PageWidth>11in</PageWidth>
<PageHeight>8.5in</PageHeight>
<MarginTop>0.25in</MarginTop>
<MarginLeft>0.25in</MarginLeft>
<MarginRight>0.25in</MarginRight>
<MarginBottom>0.25in</MarginBottom>
</DeviceInfo>";
I have two Export
functions: Export
and ExportLandscape
. The code snippet above is a part of ExportLandscape
. When I call ExportLandscape
, my report still prints in Portrait.
I tried just completely removing the Page setup options from my DeviceInfo
variable and made it just say the OutputFormat
. That didn't do it either.
Is there anything else I need to change for my report to print in Landscape? What am I missing?
It is also worth noting that, out of my 3 reports, 2 of them print in Landscape and 1 prints in Portrait. So I would really like for my application to just print it in whatever page settings the report is in. I just tried getting the report's page size and report's margins and setting those to my DeviceInfo
variable as suggested here. STILL NO LUCK!!
I just tried adding a breakpoint at the Export(ReportViewer report)
function and stepped through. When I get the report.ServerReport.GetDefaultPageSettings().PaperSize
in the immediate window, I see this:
{[PaperSize Letter Kind=Letter Height=1100 Width=850]}
Height: 1100
Kind: Letter
PaperName: "Letter"
RawKind: 1
Width: 850
This makes me feel like even though my report is set to landscape (height = 8.5in and Width = 11in), my application does not seem to recognize it.
Important Update:
The printer I am printing to has 2 paper trays. When I print a portrait report, it takes it from the default tray with the default paper size (tray 2). But when my application sends the landscape report to print, the printer tries to get a paper out of tray 1. When I load tray 1 with the same paper that is in tray 2, it asks me to enter a width and height of the paper. The printer does not seem to understand when I tell it to print it in landscape. Or rather, the printer thinks this is some new setting that it does not know about. When I enter 11 for width and 8.5 for height, it prints landscape data on a portrait paper.
To make myself clearer, the data is getting printed with a width of 11 and height of 8.5. AKA, only 75% of the data gets printed. The rest gets pushed out of the page because the page is still being oriented in portrait.