コード例 #1
0
        public IActionResult CreateDocumentFile(int id)
        {
            var exam = _examManager.GetExamWithSectionAndQuestions(id);

            var pdfBuilder = new PdfBuilder(exam);

            var stream = pdfBuilder.WordDocument();

            MemoryStream memoryStream = new MemoryStream();

            stream.CopyTo(memoryStream);

            var byteArray = memoryStream.ToArray();

            var docResponse = new DocumentResponse
            {
                Base64            = Convert.ToBase64String(byteArray),
                FileName          = $"{exam.Subject}_{exam.Teacher}_{DateTime.Now.ToShortTimeString()}.docx",
                ApplicationFormat = "application/ms-word"
            };

            return(Ok(docResponse));
        }