Beispiel #1
0
        private void AddFarmCell(AcPdfPTable table, FarmModel farm)
        {
            var cell = DefaultCell(table.ColorDark);

            cell.AddElement(new Phrase(farm.Ktidb, Fonts.Helvetica12BlackBold));
            cell.AddElement(new Phrase(farm.CompleteName, Fonts.Helvetica12BlackBold));
            cell.AddElement(new Phrase(farm.Address, Fonts.Helvetica10Black));
            cell.AddElement(new Phrase("Email: " + farm.Email, Fonts.Helvetica10Black));
            table.AddCell(cell);
        }
Beispiel #2
0
        private void AddImageCellFromBase64(AcPdfPTable table,
                                            string base64,
                                            int scalePercent        = 100,
                                            int rowspan             = 1,
                                            float borderWidth       = 0.5f,
                                            int horizontalAlignment = Element.ALIGN_LEFT)
        {
            byte[] bytes = Convert.FromBase64String(base64);
            var    image = Image.GetInstance(bytes);

            image.ScalePercent(scalePercent);
            AddImageCell(table, image, rowspan, borderWidth, horizontalAlignment);
        }
Beispiel #3
0
        private void AddImageCell(AcPdfPTable table,
                                  Image image,
                                  int rowspan             = 1,
                                  float borderWidth       = 0.5f,
                                  int horizontalAlignment = Element.ALIGN_LEFT)
        {
            var cell = new PdfPCell(image, false)
            {
                BorderWidth         = borderWidth,
                BorderColor         = table.ColorDark,
                Rowspan             = rowspan,
                HorizontalAlignment = horizontalAlignment
            };

            table.AddCell(cell);
        }
Beispiel #4
0
        private void AddImageCellFromFile(AcPdfPTable table,
                                          string imagePath,
                                          int scalePercent        = 100,
                                          int rowspan             = 1,
                                          float borderWidth       = 0.5f,
                                          int horizontalAlignment = Element.ALIGN_LEFT)
        {
            if (string.IsNullOrEmpty(imagePath))
            {
                return;
            }

            var image = Image.GetInstance(imagePath); // PlatformNotSupportedException while calling Image.GetInstance(url) which calls System.Net.WebRequest.Create.

            // Must directly pass byte array of logo image instead.

            image.ScalePercent(scalePercent);
            AddImageCell(table, image, rowspan, borderWidth, horizontalAlignment);
        }
Beispiel #5
0
        private void AddOrganizationCell(AcPdfPTable table)
        {
            var cell = DefaultCell(table.ColorDark, 0);

            Phrase OrganizationPhrase(Organization organization)
            {
                bool check = organization.IsCantonalOrgForCanton(model_.CantonCode);

                return(new Phrase
                {
                    new Chunk(check ? "[x] " : "[  ] ", Fonts.Helvetica10BlackBold),
                    new Chunk(organization.Name + ": ", Fonts.Helvetica10BlackBold),
                    new Chunk(organization.Address, Fonts.Helvetica10Black)
                });
            }

            cell.AddElement(OrganizationPhrase(Organization.Agripige));
            cell.AddElement(OrganizationPhrase(Organization.Ajapi));
            cell.AddElement(OrganizationPhrase(Organization.Anapi));
            cell.AddElement(OrganizationPhrase(Organization.Cobra));

            table.AddCell(cell);
        }
Beispiel #6
0
        private void AddResultCell(AcPdfPTable table, ResultModel resultModel, float borderWidth,
                                   BaseColor backgroundColor = null)
        {
            backgroundColor ??= Colors.White;
            var cell = DefaultCell(table.ColorDark, borderWidth, backgroundColor);

            if (!string.IsNullOrWhiteSpace(resultModel.ResultInspectorComment))
            {
                cell.AddElement(new Phrase
                {
                    new Chunk("Remarque contrôleur: ", Fonts.Helvetica8Black),
                    new Chunk(resultModel.ResultInspectorComment, Fonts.Helvetica8BlackBoldItalic),
                });
            }

            if (!string.IsNullOrWhiteSpace(resultModel.ResultFarmerComment))
            {
                cell.AddElement(new Phrase
                {
                    new Chunk("Remarque exploitant: ", Fonts.Helvetica8Black),
                    new Chunk(resultModel.ResultFarmerComment, Fonts.Helvetica8BlackBoldItalic),
                });
            }

            if (resultModel.HasDefect)
            {
                cell.AddElement(new Phrase
                {
                    new Chunk("Manquement dans la liste: ", Fonts.Helvetica8Black),
                    new Chunk(resultModel.DefectName, Fonts.Helvetica8BlackBoldItalic),
                });
            }

            if (!string.IsNullOrWhiteSpace(resultModel.ResultDefectDescription))
            {
                cell.AddElement(new Phrase
                {
                    new Chunk("Manquement constaté: ", Fonts.Helvetica8Black),
                    new Chunk(resultModel.ResultDefectDescription, Fonts.Helvetica8BlackBoldItalic),
                });
            }

            if (resultModel.ResultSize.HasValue)
            {
                cell.AddElement(new Phrase
                {
                    new Chunk("Ampleur du manquement: ", Fonts.Helvetica8Black),
                    new Chunk(resultModel.ResultSize.ToString() + " " + resultModel.ResultUnit, Fonts.Helvetica8BlackBoldItalic),
                });
            }

            if (resultModel.Seriousness != DefectSeriousness.Empty) //TODO a verifier
            {
                cell.AddElement(new Phrase
                {
                    new Chunk("Gravité: ", Fonts.Helvetica8Black),
                    new Chunk(resultModel.Seriousness?.Name, Fonts.Helvetica8BlackBoldItalic),
                });
            }

            //if (resultModel.Repetition != DefectRepetitions.NoDefect)
            //    cell.AddElement(new Phrase($"Récidive: {resultModel.Repetition.ToDisplayName()}", Fonts.Helvetica8Black));

            table.AddCell(cell);
        }