예제 #1
0
        public ResponseModel GeneratePdfTemplate(TemplateModel objTemplate, string path)
        {
            var objRes = new ResponseModel();

            try
            {
                var objPdfTemplate = PdfFactory.GetTemplate(objTemplate.Type);

                var respTemplate = objPdfTemplate.ProcessTemplate(objTemplate);

                if (respTemplate.Status)
                {
                    //template file
                    _file.WriteFile(path, respTemplate.PdfTemplateFileName, respTemplate.PdfTemplateFileContent);

                    //Models file if existis
                    if (!string.IsNullOrEmpty(respTemplate.PdfModelsFileName))
                    {
                        _file.WriteFile(path, respTemplate.PdfModelsFileName, respTemplate.PdfModelsFileContent);
                    }
                }
                else
                {
                    return new ResponseModel {
                               Status = false, Message = respTemplate.Message
                    }
                };
            }
            catch (Exception ex)
            {
                objRes.Status  = false;
                objRes.Message = "Exp:" + ex.Message;
            }
            return(objRes);
        }
예제 #2
0
 public InvoicesController(IMapper mapper, IInvoiceService invoiceService, IFileService fileService, IUserService userService, IConverter converter)
 {
     _mapper         = mapper;
     _invoiceService = invoiceService;
     _fileService    = fileService;
     _userService    = userService;
     _converter      = converter;
     _pdfFactory     = new PdfFactory(_converter);
 }
예제 #3
0
        private void btnGeneratePdf_Click(object sender, EventArgs e)
        {
            string fileName = txtFilename.Text;

            if (string.IsNullOrEmpty(fileName))
            {
                MessageBox.Show(this, "Filename cant be empty", "error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                PdfContent pdfContent = new PdfContent
                {
                    Text1   = txtText1.Text,
                    Text2   = txtText2.Text,
                    Text3   = txtText3.Text,
                    PdfFont = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, txtFont.Font.Size)
                };
                //var fontFactory = new FontFactoryImp();
                //fontFactory.RegisterFamily(txtFont.Font.FontFamily.Name, txtFont.Font.Name,);

                //pdfContent.PdfFont = new iTextSharp.text.Font(BaseFont.CreateFont(txtFont.Font.FontFamily.Name, iTextSharp.text.FontFactory.DefaultEncoding, true));
                //pdfContent.PdfFont.Size = txtFont.Font.Size;
                //pdfContent.PdfFont.SetStyle(txtFont.Font.Style.ToString());
                System.Drawing.Image img = pictureBoxBackground.Image;

                MemoryStream ms = new MemoryStream();
                img.Save(ms, ImageFormat.Jpeg);
                pdfContent.BackgroundImage = new Jpeg(ms.ToArray(), img.Width, img.Height);

                PdfFactory.CreatePdf(txtFilename.Text, pdfContent);
                MessageBox.Show(this, "Pdf Generated successfully", "Pdf created", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception exception)
            {
                MessageBox.Show(this, exception.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #4
0
        public static void Main(string[] args)
        {
            // Mock
            VacantCandidateReportComparative data;

            data = new VacantCandidateReportComparative
            {
                vacant = new VacantLight
                {
                    Name = "Programador Web"
                },
                vacantCompetences = new VacantCompetence[]
                {
                    new VacantCompetence
                    {
                        Name         = "Guapo",
                        IsRequired   = false,
                        MinScore     = 3.30M,
                        MaxScore     = 4.50M,
                        CompetenceId = 5
                    },
                    new VacantCompetence
                    {
                        Name         = "Creatividad e Innovación",
                        IsRequired   = true,
                        MinScore     = 3.30M,
                        MaxScore     = 4.50M,
                        CompetenceId = 3
                    }
                },
                candidate = new CandidateReportComparative[]
                {
                    new CandidateReportComparative
                    {
                        candidate = new CandidateLight
                        {
                            Name       = "Anakin Skywalker",
                            Address    = "Tepito, Mexico City, CDMX, Mexico",
                            AvatarUri  = "https://s3-us-west-2.amazonaws.com/brive-yooin-users/files/8391",
                            Experience = "0 años 10 meses"
                        },
                        CandidateSalary = new CandidateSalary {
                            Minimum = 23000,
                            Maximum = 25000
                        },
                        AffinityPercentage   = (decimal?)100.14,
                        candidateCompetences = new Brive.YooinEnterprise.DTO.Models.CandidateCompetence[]
                        {
                            new Brive.YooinEnterprise.DTO.Models.CandidateCompetence
                            {
                                Competence = new Competence
                                {
                                    Id = 1
                                },
                                Score = 2.25M
                            },
                            new Brive.YooinEnterprise.DTO.Models.CandidateCompetence
                            {
                                Competence = new Competence
                                {
                                    Id = 3
                                },
                                Score = 2.25M
                            },
                            new Brive.YooinEnterprise.DTO.Models.CandidateCompetence
                            {
                                Competence = new Competence
                                {
                                    Id = 5
                                },
                                Score = 2.95M
                            }
                        }
                    },
                    new CandidateReportComparative
                    {
                        candidate = new CandidateLight
                        {
                            Name       = "Obi-Wan Kenobi",
                            Address    = "Tepito, Mexico City, CDMX, Mexico",
                            AvatarUri  = "https://s3-us-west-2.amazonaws.com/brive-yooin-users/files/8408",
                            Experience = "0 años 10 meses"
                        },
                        CandidateSalary = new CandidateSalary {
                            Minimum = 23000,
                            Maximum = 25000
                        },
                        AffinityPercentage   = (decimal?)96.58,
                        candidateCompetences = new Brive.YooinEnterprise.DTO.Models.CandidateCompetence[]
                        {
                            new Brive.YooinEnterprise.DTO.Models.CandidateCompetence
                            {
                                Competence = new Competence
                                {
                                    Id = 1
                                },
                                Score = 2.75M
                            },
                            new Brive.YooinEnterprise.DTO.Models.CandidateCompetence
                            {
                                Competence = new Competence
                                {
                                    Id = 3
                                },
                                Score = 2.75M
                            },
                            new Brive.YooinEnterprise.DTO.Models.CandidateCompetence
                            {
                                Competence = new Competence
                                {
                                    Id = 5
                                },
                                Score = 3.75M
                            }
                        }
                    },
                    new CandidateReportComparative
                    {
                        candidate = new CandidateLight
                        {
                            Name       = "Obi-Wan Kenobi",
                            Address    = "Tepito, Mexico City, CDMX, Mexico",
                            AvatarUri  = "",
                            Experience = "0 años 10 meses"
                        },
                        CandidateSalary = new CandidateSalary {
                            Minimum = 23000,
                            Maximum = 25000
                        },
                        AffinityPercentage   = (decimal?)80.36,
                        candidateCompetences = new Brive.YooinEnterprise.DTO.Models.CandidateCompetence[]
                        {
                            new Brive.YooinEnterprise.DTO.Models.CandidateCompetence
                            {
                                Competence = new Competence
                                {
                                    Id = 1
                                },
                                Score = 2.3M
                            },
                            new Brive.YooinEnterprise.DTO.Models.CandidateCompetence
                            {
                                Competence = new Competence
                                {
                                    Id = 3
                                },
                                Score = 2.3M
                            },
                            new Brive.YooinEnterprise.DTO.Models.CandidateCompetence
                            {
                                Competence = new Competence
                                {
                                    Id = 5
                                },
                                Score = 2.8M
                            }
                        }
                    },
                    new CandidateReportComparative
                    {
                        candidate = new CandidateLight
                        {
                            Name       = "Palpatine",
                            Address    = "Chalco, Mexico City, CDMX, Mexico",
                            Experience = "5 años 1 mes"
                        },
                        CandidateSalary = new CandidateSalary {
                            Minimum = 22000,
                            Maximum = 20000
                        },
                        AffinityPercentage   = (decimal?)78.54,
                        candidateCompetences = new Brive.YooinEnterprise.DTO.Models.CandidateCompetence[]
                        {
                            new Brive.YooinEnterprise.DTO.Models.CandidateCompetence
                            {
                                Competence = new Competence
                                {
                                    Id = 1
                                },
                                Score = 3.3M
                            },
                            new Brive.YooinEnterprise.DTO.Models.CandidateCompetence
                            {
                                Competence = new Competence
                                {
                                    Id = 3
                                },
                                Score = 3.3M
                            },
                            new Brive.YooinEnterprise.DTO.Models.CandidateCompetence
                            {
                                Competence = new Competence
                                {
                                    Id = 5
                                },
                                Score = 4
                            }
                        }
                    },
                    new CandidateReportComparative
                    {
                        candidate = new CandidateLight
                        {
                            Name       = "Darth Maul",
                            Address    = "Tepito, Mexico City, CDMX, Mexico",
                            AvatarUri  = "",
                            Experience = "0 años 10 meses"
                        },
                        CandidateSalary = new CandidateSalary {
                            Minimum = 23000,
                            Maximum = 25000
                        },
                        AffinityPercentage   = (decimal?)60.36,
                        candidateCompetences = new Brive.YooinEnterprise.DTO.Models.CandidateCompetence[]
                        {
                            new Brive.YooinEnterprise.DTO.Models.CandidateCompetence
                            {
                                Competence = new Competence
                                {
                                    Id = 1
                                },
                                Score = 3.40M
                            },
                            new Brive.YooinEnterprise.DTO.Models.CandidateCompetence
                            {
                                Competence = new Competence
                                {
                                    Id = 3
                                },
                                Score = 3.40M
                            },
                            new Brive.YooinEnterprise.DTO.Models.CandidateCompetence
                            {
                                Competence = new Competence
                                {
                                    Id = 5
                                },
                                Score = 3.4M
                            }
                        }
                    }
                }
            };


            PdfFactory pdf;

            pdf = new PdfFactory(@"/Users/joel/prueba.pdf", data);
            pdf.GenerateReport(1);
        }