Custom Page Size not working when pdf is saved to App_Data
jldelacruz opened this issue · comments
Custom page size on preview is working 612f x 396f but the saved file to App_Data is whole Letter size.
public ActionResult SaveToAppData()
{
var model = new recordListModel();
model.records = db.Records.Select(x => new recordModel
{
Id = x.Id,
Date = x.Date,
PaidTo = x.PaidTo,
CheckNo = x.CheckNo,
Payor = x.Payor
}).ToList();
byte[] pdfOutput = ControllerContext.GeneratePdf(model, "Print");
string fullPath = Server.MapPath("~/App_Data/FreshlyMade.pdf");
if (System.IO.File.Exists(fullPath))
{
System.IO.File.Delete(fullPath);
}
System.IO.File.WriteAllBytes(fullPath, pdfOutput);
return View("SaveToAppData");
}
public ActionResult Print()
{
var model = new recordListModel();
model.records = db.Records.Select(x => new recordModel
{
Id = x.Id,
Date = x.Date,
PaidTo = x.PaidTo,
CheckNo = x.CheckNo,
Payor = x.Payor
}).ToList();
return new PdfActionResult(model, (writer, document) =>
{
document.SetPageSize(new Rectangle(612f, 396f, 90));
document.NewPage();
});
}