public IHttpActionResult VisualizeByFormat([FromUri] Guid document_id)
        {
            if (IsTokenValid() && authenticationService.IsAllowedToVisualizeDocument(GetTokenUserEmail(), document_id))
            {
                try
                {
                    string   formatName = Request.Headers.GetValues("Format-Name").FirstOrDefault();
                    Document document   = documentManagementService.GetById(document_id);
                    Format   format     = formatManagementService.GetByName(formatName);

                    return(Ok(codeGenerator.GenerateHTML(document, format)));
                }
                catch (MissingDocumentException e)
                {
                    return(BadRequest(e.Message));
                }
                catch (MissingFormatException e)
                {
                    return(BadRequest(e.Message));
                }
                catch (Exceptions e)
                {
                    return(BadRequest(e.Message));
                }
            }

            return(Unauthorized());
        }