Ejemplo n.º 1
0
        public async Task <IActionResult> FileToPdf(string id)
        {
            try
            {
                var fileMemoryStream = new MemoryStream();
                var file             = await _fileLogic.GetFileById(Guid.Parse(id));

                if (file == null)
                {
                    return(NotFound());
                }

                var buffer = await _fileLogic.ReadAsync(file.Path);

                if (buffer == null)
                {
                    return(NotFound());
                }

                var pdf = await _fileLogic.ConvertPdf2Pdf(fileMemoryStream, file.Path);

                if (!pdf)
                {
                    return(NotFound());
                }

                fileMemoryStream.Position = 0;
                return(new FileStreamResult(fileMemoryStream, "application/pdf"));
            }
            catch (Exception e)
            {
                return(ExceptionResult(e));
            }
        }