private static void WriteInDocument(Document document, ReportResponseViewModel reportModel) { var sec = document.Sections.AddSection(); sec.AddParagraph("My test complain report."); sec.AddParagraph($"Complain Id: {reportModel.ComplainId}"); sec.AddParagraph($"User owner name: {reportModel.DealOwnerUsername}"); sec.AddParagraph($"User creditor name: {reportModel.DealCreditorUsername}"); sec.AddParagraph($"Date of creating: {reportModel.DateOfCreating.ToShortDateString()}"); sec.AddParagraph($"Complain: {reportModel.ComplainText}"); }
public async Task <IHttpActionResult> ComplainPdf(string complainId) { ReportResponseViewModel report = await _repo.GetReport(complainId); if (report == null) { return(BadRequest($"Complain {complainId} not found.")); } return(Ok(report)); }
public static string CreateHtml(ReportResponseViewModel report, string xsltTemplatePath) { string xmlPath = HostingEnvironment.MapPath($"\\App_Data\\temp-{report.ComplainId}.xml"); string htmlPath = HostingEnvironment.MapPath($"\\App_Data\\temp-{report.ComplainId}.html"); var formatter = new XmlSerializer(typeof(ReportResponseViewModel)); using (var fs = new FileStream(xmlPath, FileMode.Create)) { formatter.Serialize(fs, report); } var xmlDoc = new XPathDocument(xmlPath); var xslTransform = new XslCompiledTransform(); xslTransform.Load(xsltTemplatePath); xslTransform.Transform(xmlPath, htmlPath); return(File.ReadAllText(htmlPath)); }