Exemple #1
0
        /// <summary>
        /// Finshed render html track by add element id = my_reporting_finished
        /// </summary>
        /// <param name="html"></param>
        /// <returns></returns>
        public byte[] ExportFromHtml(string html)
        {
            var sectionFileId = Guid.NewGuid();
            var htmlPath      = $"{_reportContext.GetSessionPath()}\\{sectionFileId}.html";

            File.WriteAllText(htmlPath, html);
            var pdfFilePath = $"{_reportContext.GetSessionPath()}\\{sectionFileId}.pdf";

            string log = RunProgress(htmlPath, pdfFilePath);

            if (File.Exists(pdfFilePath))
            {
                _logger.LogInformation(log);
                _reportContext.AddTempFiles("ChromiumRepositoty", new List <string> {
                    htmlPath, pdfFilePath
                });
                return(File.ReadAllBytes(pdfFilePath));
            }
            _logger.LogError(log);
            _reportContext.AddTempFiles("ChromiumRepositoty", new List <string> {
                htmlPath
            });
            throw new Exception("Cant translate html to pdf !");
        }