Beispiel #1
0
        public async Task <byte[]> DecisionCreatePDFAsync(int decisionId)
        {
            try
            {
                var decision = await _repoWrapper.Decesion.GetFirstAsync(x => x.ID == decisionId, include : dec =>
                                                                         dec.Include(d => d.DecesionTarget).Include(d => d.Organization));

                if (decision != null)
                {
                    var base64 = await _decisionBlobStorage.GetBlobBase64Async("dafaultPhotoForPdf.jpg");

                    IPdfSettings pdfSettings = new PdfSettings
                    {
                        Title     = $"Decision of {decision.Organization.OrganizationName}",
                        ImagePath = base64,
                    };
                    IPdfCreator creator = new PdfCreator(new DecisionDocument(decision, pdfSettings));
                    return(await Task.Run(() => creator.GetPDFBytes()));
                }
            }
            catch (Exception e)
            {
                _logger.LogError($"Exception: {e.Message}");
            }

            return(null);
        }
Beispiel #2
0
        public async Task <string> BlankCreatePDFAsync(string userId)
        {
            try
            {
                IPdfSettings pdfSettings = new PdfSettings
                {
                    Title     = "Бланк",
                    ImagePath = "Blank"
                };
                var blank = await GetBlankDataAsync(userId);

                IPdfCreator creator = new PdfCreator(new BlankDocument(blank, pdfSettings));
                var         base64  = await Task.Run(() => creator.GetPDFBytes());

                var azureBase64 = Convert.ToBase64String(base64);
                var result      = $"data:application/pdf;base64," + azureBase64;
                return(result);
            }
            catch (Exception e)
            {
                _logger.LogError($"Exception: {e.Message}");
            }

            return(null);
        }
Beispiel #3
0
        public async Task <byte[]> BlankCreatePDFAsync(string userId)
        {
            try
            {
                IPdfSettings pdfSettings = new PdfSettings
                {
                    Title     = "Бланк",
                    ImagePath = "wwwroot/images/pdf/Header-Eplast-Blank.png"
                };
                var         blank   = GetBlankData(userId);
                IPdfCreator creator = new PdfCreator(new BlankDocument(blank, pdfSettings));
                return(await Task.Run(() => creator.GetPDFBytes()));
            }
            catch (Exception e)
            {
                _logger.LogError($"Exception: {e.Message}");
            }

            return(null);
        }
Beispiel #4
0
        public async Task <byte[]> BlankCreatePDFAsync(string userId)
        {
            try
            {
                var blank = await GetBlankDataAsync(userId);

                IPdfSettings pdfSettings = new PdfSettings
                {
                    Title     = $"{blank.User.FirstName} {blank.User.LastName}",
                    ImagePath = "Blank"
                };
                IPdfCreator creator = new PdfCreator(new BlankDocument(blank, pdfSettings));
                return(await Task.Run(() => creator.GetPDFBytes()));
            }
            catch (Exception e)
            {
                _logger.LogError($"Exception: {e.Message}");
            }

            return(null);
        }