I am writing an application that creates checks on 8.5 x 7" tractor feed paper. I am developing the app on vs2012 and it is an mvc 4 app with users printing checks on their client side printers. I am rendering the report output to PDF.
The problem that I am having is that when I render the checks, they print in landscape because width > height. So after reading many posts, I have tried the work around which is to create a square report page of 8.5 x 8.5" and not use the bottom 1.5". When I render this, it prints in portrait mode, but instead of getting the required 8.5 x 7 layout, I am getting a 8.5 x 8.5.
To be more specific about my report layout - here are more details:
Report page size = 8.5 x 8.5
Interactive page size = 8.5 x 8.5
Page margins: .25 top, bottom, right, left
Body size: 8 x 6.5
All report items fit within the body.
Can someone please tell me how to do this?
Thanks
Here is my controller code:
[HttpGet]
public ActionResult TestReport()
{
Ui_ProcessRoyaltyChecks ui = new Ui_ProcessRoyaltyChecks();
return View(ui);
}
[HttpPost]
public ActionResult TestReport(Ui_ProcessRoyaltyChecks ui)
{
string id = ui.SelectedReportFormat;
var unprintedOwnerChecks = (from upc in context.OilGasCheckRegistries
join or in context.GasRoyalties on upc.PaymentId equals or.PaymentId
join p in context.Payees on upc.OwnerNum equals p.VendorNum
orderby upc.CheckNum ascending
select new
{
upc.PaymentId,
upc.PaidDate,
or.Yyyy,
or.Mm,
upc.AmtPaid,
upc.OwnerName,
upc.OwnerNum,
upc.CheckNum,
upc.CheckWords,
or.IncomeTax,
or.AmountOwed,
p.Address,
p.AddressContd,
p.City,
p.State,
p.Zip
}).AsEnumerable();
LocalReport lr = new LocalReport();
string path = Path.Combine(Server.MapPath("~/Reports"), "TestReport.rdlc");
if (System.IO.File.Exists(path))
{
lr.ReportPath = path;
}
else
{
return View(ui);
}
if (unprintedOwnerChecks == null)
{
return View(ui);
}
ReportDataSource datasource = new ReportDataSource("DataSet_GasRoyaltyChecks", unprintedOwnerChecks);
lr.DataSources.Clear();
lr.DataSources.Add(datasource);
string reportType = id;
string mimeType;
string encoding;
string fileNameExtension;
string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>" + id + "</OutputFormat>" +
" <Orientation>Portrait</Orientation>" +
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>8.5in</PageHeight>" +
" <MarginTop>0.25in</MarginTop>" +
" <MarginLeft>0.25in</MarginLeft>" +
" <MarginRight>0.25in</MarginRight>" +
" <MarginBottom>0.25in</MarginBottom>" +
"</DeviceInfo>";
Warning[] warnings;
string[] streams;
byte[] renderedBytes;
renderedBytes = lr.Render(
reportType,
deviceInfo,
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings);
return File(renderedBytes, mimeType);
}