Esempio n. 1
0
        public IHttpActionResult Post([FromBody] string html)
        {
            if (string.IsNullOrWhiteSpace(html))
            {
                ModelState.AddModelError("html", "Cannot generate pdf from nothing");
                return(BadRequest(ModelState));
            }
            var pdfData = _service.CreatePdfFromHtml(html);

            if (pdfData.LongLength <= 0)
            {
                ModelState.AddModelError("pdf", "Could not generate a pdf correctly");
                return(BadRequest(ModelState));
            }
            return(Ok(pdfData));
        }