public dynamic ImprimirRotina([FromBody] ImprimirRotinaCommands command) { var rotina = _rotinaRepositorio.Imprimir(command.RotinaId); var obj = TemplateGenerator.ImprimirRotina(rotina); var pdf = RetornoPdf.Retorno(obj, "assets", "styles.css", Orientation.Landscape); //file = _converter.Convert(pdf); //var pdf = new HtmlToPdfDocument() //{ // GlobalSettings = ConfiguracaoPdf._GlobalSettings(Orientation.Landscape), // Objects = { ConfiguracaoPdf._ObjectSettings(obj, "assets", "style.css") } //}; //_converter.Convert(pdf); IF WE USE Out PROPERTY IN THE GlobalSettings CLASS, THIS IS ENOUGH FOR CONVERSION var file = _converter.Convert(pdf); //return Ok("Successfully created PDF document."); //return File(file, "application/pdf", "EmployeeReport.pdf"); USE THIS RETURN STATEMENT TO DOWNLOAD GENERATED PDF DOCUMENT return(File(file, "application/pdf")); }
public dynamic RetornoTotalOcorrencia([FromBody] FiltroOcorrenciaCommands command) { try { if (!command.IsValid()) { return(new ComandResult(false, "Por favor corrija os campos abaixo", command.Notifications)); } byte[] file; var retorno = _ocorrenciaRepositorio.RetornoTotalOcorrencia(command); var obj = TemplateGenerator.TotalOcorrencias(retorno); var pdf = RetornoPdf.Retorno(obj, "assets", "styles.css", Orientation.Landscape); file = _converter.Convert(pdf); return(File(file, "application/pdf")); } catch (NullReferenceException ex) { return(ex.Message); } }