public async Task <ActionResult> ExportPDF(string startDate, string endDate) { using (var chanel = new ChanelFactory()) { string cusCode = User.Identity.Name; var cus = await GetByCusCode(cusCode.Trim()); ViewBag.TenDonVi = cus.Name; //GetListInv var listInvs = await chanel.GetFullListInvByCusCode(cusCode.Trim(), startDate, endDate); if (listInvs == null) { listInvs = new List <InvoiceCusSP>(); } Rotativa.PartialViewAsPdf vPdf = new Rotativa.PartialViewAsPdf("_ListPDF", listInvs) { PageOrientation = Rotativa.Options.Orientation.Portrait, IsJavaScriptDisabled = false, IsBackgroundDisabled = false, MinimumFontSize = 10, PageSize = Rotativa.Options.Size.Letter, PageMargins = new Rotativa.Options.Margins(15, 10, 15, 10) }; return(vPdf); } }
public async Task <ActionResult> GeneratePdf(Guid id) { var output = await _getDeclaracionUserCase.Execute(id); var modelView = Mapper.Map <DeclaracionModel>(output); var report = new Rotativa.PartialViewAsPdf("DetailsPdf", modelView); return(report); }
public string SaveOnPathe(string ReportName, DateTime FromDate, DateTime Todate) { TempData["FromDate"] = FromDate; TempData["ToDate"] = Todate; string pdfname = ""; try { CompanyID = Convert.ToInt32(Session["CompayID"]); long FromDa = Convert.ToDateTime(FromDate).Ticks; long TDate = Convert.ToDateTime(Todate).Ticks; HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("GetJournal/" + FromDa + "/" + TDate).Result; ViewBag.JournalList = response.Content.ReadAsAsync <List <TransactionModel> >().Result; CompanyId = Convert.ToInt32(Session["CompayID"]); HttpResponseMessage responseCompany = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + CompanyId.ToString()).Result; _company = responseCompany.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; TempData["Compantinfo"] = _company; TempData.Keep(); string companyName = ReportName + "-" + FromDate + "-" + Todate + ".pdf"; var root = Server.MapPath("/PDF/"); var path = Path.Combine(root, companyName); pdfname = path; string subPath = "/PDF"; bool exists = System.IO.Directory.Exists(Server.MapPath(subPath)); if (!exists) { System.IO.Directory.CreateDirectory(Server.MapPath(subPath)); } if (System.IO.File.Exists(path)) { try { if (System.IO.File.Exists(path)) { FileInfo info = new FileInfo(path); pdfname = path; if (!IsFileLocked(info)) { info.Delete(); } } } catch (System.IO.IOException) { } } var pdfResult = new Rotativa.PartialViewAsPdf("~/Views/Reports/JournalPartialView.cshtml") { PageSize = Rotativa.Options.Size.A4, MinimumFontSize = 16, PageMargins = new Rotativa.Options.Margins(10, 12, 20, 3), PageHeight = 40, SaveOnServerPath = path, }; pdfResult.BuildPdf(this.ControllerContext); } catch (Exception EX) { throw EX; } return(pdfname); }
public string PrintViewsdwede(int?Id) { string pdfname; try { ExpenseViewModel experviewModel = new ExpenseViewModel(); HttpResponseMessage Expense = GlobalVeriables.WebApiClient.GetAsync("GetExpenseById/" + Id).Result; experviewModel = Expense.Content.ReadAsAsync <ExpenseViewModel>().Result; HttpResponseMessage responseCompany = GlobalVeriables.WebApiClient.GetAsync("APIComapny/" + experviewModel.comapny_id.ToString()).Result; MVCCompanyInfoModel companyModel = responseCompany.Content.ReadAsAsync <MVCCompanyInfoModel>().Result; CommonModel commonModel = new CommonModel(); commonModel.Name = "Expense"; HttpResponseMessage expenseDetail = GlobalVeriables.WebApiClient.GetAsync("GetExpenseDetailById/" + Id).Result; List <ExpenseViewModel> ExpenseDetailList = expenseDetail.Content.ReadAsAsync <List <ExpenseViewModel> >().Result; ViewBag.CompanyName = companyModel.CompanyName; ViewBag.ExpenceModel = experviewModel; ViewBag.commonModel = commonModel; ViewBag.CompanyLogo = companyModel.CompanyLogo; ViewBag.ExpenseDetail = ExpenseDetailList; string companyName = Id + "-" + companyModel.CompanyName; var root = Server.MapPath("/PDF/"); pdfname = String.Format("{0}.pdf", companyName); var path = Path.Combine(root, pdfname); path = Path.GetFullPath(path); string subPath = "/PDF"; // your code goes here bool exists = System.IO.Directory.Exists(Server.MapPath(subPath)); if (!exists) { System.IO.Directory.CreateDirectory(Server.MapPath(subPath)); } if (System.IO.File.Exists(path)) { try { if (System.IO.File.Exists(path)) { FileInfo info = new FileInfo(path); if (!IsFileLocked(info)) { info.Delete(); } } } catch (System.IO.IOException) { } } var pdfResult = new Rotativa.PartialViewAsPdf("~/Views/Expence/ExpensePrint.cshtml") { PageSize = Rotativa.Options.Size.A4, MinimumFontSize = 16, PageMargins = new Rotativa.Options.Margins(10, 12, 20, 3), PageHeight = 40, SaveOnServerPath = path, // Save your place // CustomSwitches = "--footer-center \"" + "Wilt u zo vriendelijk zijn om het verschuldigde bedrag binnen " + diffDate + " dagen over te maken naar IBAN: " + companyModel.IBANNumber + " ten name van IT Molen o.v.v.bovenstaande factuurnummer. (Op al onze diensten en producten zijn onze algemene voorwaarden van toepassing.Deze kunt u downloaden van onze website.)" + " Printed date: " + // DateTime.Now.Date.ToString("MM/dd/yyyy") + " Page: [page]/[toPage]\"" + //" --footer-line --footer-font-size \"10\" --footer-spacing 6 --footer-font-name \"calibri light\"", }; pdfResult.BuildPdf(this.ControllerContext); } catch (Exception) { throw; } return(pdfname); }