Exemple #1
0
        public override void SaveAs(string fileName)
        {
            PdfWriter writer = null;
            var       doc    = new Document();

            try
            {
                writer = PdfWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create));

                doc.Open();

                var baseFont   = BaseFont.CreateFont("C:\\Windows\\Fonts\\arial.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                var font       = new Font(baseFont, 12, Font.NORMAL);
                var fontBold   = new Font(baseFont, 12, Font.BOLD);
                var fontHeader = new Font(baseFont, 14, Font.BOLD);
                var fontTitle  = new Font(baseFont, 18, Font.NORMAL);

                doc.Add(new Paragraph(Title, fontTitle));

                var table = new PdfPTable(2)
                {
                    SpacingBefore = 50
                };

                foreach (var model in Models)
                {
                    table.AddTitleTable($"{model.Id} / {model.Gender?.Name} / {model.Weight}", fontHeader, 2);

                    table.AddCell("Идентификатор", font);
                    table.AddCell(model.Id.ToString(), font);

                    table.AddCell("Пол", font);
                    table.AddCell(model.Gender?.Name, font);

                    table.AddCell("Вес", font);
                    table.AddCell(model.Weight.ToString(), font);

                    table.AddHeaderColumn("Мать", fontBold, 2);

                    table.AddCell("Идентификатор", font, 0, 15);
                    table.AddCell(model.Mother?.Id.ToString(), font, 0, 15);

                    table.AddCell("Имя", font, 0, 15);
                    table.AddCell(model.Mother?.Name, font, 0, 15);
                }

                doc.Add(table);
            }
            finally
            {
                writer?.Flush();
                doc.Close();

                writer = null;
                doc    = null;
            }
        }
Exemple #2
0
        public override void SaveAs(string fileName)
        {
            PdfWriter writer = null;
            var       doc    = new Document();

            try
            {
                writer = PdfWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create));

                doc.Open();

                var baseFont   = BaseFont.CreateFont("C:\\Windows\\Fonts\\arial.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                var font       = new Font(baseFont, 12, Font.NORMAL);
                var fontBold   = new Font(baseFont, 12, Font.BOLD);
                var fontHeader = new Font(baseFont, 14, Font.BOLD);
                var fontTitle  = new Font(baseFont, 18, Font.NORMAL);

                doc.Add(new Paragraph(Title, fontTitle));

                var table = new PdfPTable(2)
                {
                    SpacingBefore = 50
                };

                foreach (var model in Models)
                {
                    table.AddTitleTable($"{model.Id} / {model.Name}", fontHeader, 2);

                    table.AddCell("Идентификатор", font);
                    table.AddCell(model.Id.ToString(), font);

                    table.AddCell("Имя", font);
                    table.AddCell(model.Name, font);

                    table.AddCell("Породность", font);
                    table.AddCell(model.Porodnost.ToString(), font);

                    table.AddCell("Дата рождения", font);
                    table.AddCell(model.BDay.ToString(), font);

                    table.AddCell("Место рождения", font);
                    table.AddCell(model.BPlace, font);

                    table.AddCell("Вес", font);
                    table.AddCell(model.Weight.ToString(), font);

                    table.AddCell("Возраст", font);
                    table.AddCell(model.Age.ToString(), font);

                    table.AddCell("В стаде", font);
                    table.AddCell((model.IsInHerd == true ? "Да" : "Нет"), font);

                    table.AddCell("Порода", font);
                    table.AddCell(model.Breed?.Name, font);

                    table.AddCell("Линия", font);
                    table.AddCell(model.Line?.Name, font);

                    table.AddCell("Семейство", font);
                    table.AddCell(model.Family?.Name, font);

                    table.AddCell("Категория", font);
                    table.AddCell(model.Category?.Name, font);

                    table.AddCell("Группа крови", font);
                    table.AddCell(model.BloodType?.Name, font);

                    table.AddHeaderColumn("Мать", fontBold, 2);

                    table.AddCell("Идентификатор", font, 0, 15);
                    table.AddCell(model.Mother?.Id.ToString(), font, 0, 15);

                    table.AddCell("Имя", font, 0, 15);
                    table.AddCell(model.Mother?.Name, font, 0, 15);

                    table.AddHeaderColumn("Отец", fontBold, 2);

                    table.AddCell("Идентификатор", font, 0, 15);
                    table.AddCell(model.Father?.Id.ToString(), font, 0, 15);

                    table.AddCell("Месторасположение", font, 0, 15);
                    table.AddCell(model.Father?.Location.ToString(), font, 0, 15);

                    table.AddCell("Сторонний идентификатор", font, 0, 15);
                    table.AddCell(model.Father?.OtherId.ToString(), font, 0, 15);
                }

                doc.Add(table);
            }
            finally
            {
                writer?.Flush();
                doc.Close();

                writer = null;
                doc    = null;
            }
        }
Exemple #3
0
        public override void SaveAs(string fileName)
        {
            PdfWriter writer = null;
            var       doc    = new Document();

            try
            {
                writer = PdfWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create));

                doc.Open();

                var baseFont   = BaseFont.CreateFont("C:\\Windows\\Fonts\\arial.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                var font       = new Font(baseFont, 12, Font.NORMAL);
                var fontBold   = new Font(baseFont, 12, Font.BOLD);
                var fontHeader = new Font(baseFont, 14, Font.BOLD);
                var fontTitle  = new Font(baseFont, 18, Font.NORMAL);

                doc.Add(new Paragraph(Title, fontTitle));

                var table = new PdfPTable(2)
                {
                    SpacingBefore = 50
                };

                foreach (var model in Models)
                {
                    table.AddTitleTable($"{model.Id} / {model.Cow?.Name} / {model.Date}", fontHeader, 2);

                    table.AddCell("Идентификатор", font);
                    table.AddCell(model.Id.ToString(), font);

                    table.AddCell("Учтено лактаций", font);
                    table.AddCell(model.UchtenoLaktacij.ToString(), font);

                    table.AddCell("Удой(кг.)", font);
                    table.AddCell(model.UdojKg.ToString(), font);

                    table.AddCell("Жир(%)", font);
                    table.AddCell(model.ZhirProz.ToString(), font);

                    table.AddCell("Белок(%)", font);
                    table.AddCell(model.BelokProz.ToString(), font);

                    table.AddCell("Дата", font);
                    table.AddCell(model.Date.ToString(), font);

                    table.AddHeaderColumn("Соответствующая корова", fontBold, 2);

                    table.AddCell("Идентификатор", font, 0, 15);
                    table.AddCell(model.Cow?.Id.ToString(), font, 0, 15);

                    table.AddCell("Имя", font, 0, 15);
                    table.AddCell(model.Cow?.Name, font, 0, 15);
                }

                doc.Add(table);
            }
            finally
            {
                writer?.Flush();
                doc.Close();

                writer = null;
                doc    = null;
            }
        }
        public override void SaveAs(string fileName)
        {
            PdfWriter writer = null;
            var       doc    = new Document();

            try
            {
                writer = PdfWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create));

                doc.Open();

                var baseFont   = BaseFont.CreateFont("C:\\Windows\\Fonts\\arial.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                var font       = new Font(baseFont, 12, Font.NORMAL);
                var fontBold   = new Font(baseFont, 12, Font.BOLD);
                var fontHeader = new Font(baseFont, 14, Font.BOLD);
                var fontTitle  = new Font(baseFont, 18, Font.NORMAL);

                doc.Add(new Paragraph(Title, fontTitle));

                var table = new PdfPTable(2)
                {
                    SpacingBefore = 50
                };

                foreach (var model in Models)
                {
                    table.AddTitleTable($"{model.Id} / {model.DateOsemeneniya} - {(model.DateOtela == null ? "?" : model.DateOtela.ToString())}", fontHeader, 2);

                    table.AddCell("Идентификатор", font);
                    table.AddCell(model.Id.ToString(), font);

                    table.AddCell("Метод случки", font);
                    table.AddCell(model.MethodSluchki?.Name, font);

                    table.AddCell("Число сухих дней", font);
                    table.AddCell(model.ChisloSuhihDney.ToString(), font);

                    table.AddCell("Сер. период", font);
                    table.AddCell(model.SerPeriod.ToString(), font);

                    table.AddCell("Дата осеменения", font);
                    table.AddCell(model.DateOsemeneniya.ToString(), font);

                    table.AddCell("Дата отела", font);
                    table.AddCell((model.DateOtela == null ? "?" : model.DateOtela.ToString()), font);

                    table.AddHeaderColumn("Соответствующий бык", fontBold, 2);

                    table.AddCell("Идентификатор", font, 0, 15);
                    table.AddCell(model.Bull?.Id.ToString(), font, 0, 15);

                    table.AddCell("Месторасположение", font, 0, 15);
                    table.AddCell(model.Bull?.Location.ToString(), font, 0, 15);

                    table.AddCell("Сторонний идентификатор", font, 0, 15);
                    table.AddCell(model.Bull?.OtherId.ToString(), font, 0, 15);

                    table.AddHeaderColumn("Соответствующая корова", fontBold, 2);

                    table.AddCell("Идентификатор", font, 0, 15);
                    table.AddCell(model.Cow?.Id.ToString(), font, 0, 15);

                    table.AddCell("Имя", font, 0, 15);
                    table.AddCell(model.Cow?.Name, font, 0, 15);
                }

                doc.Add(table);
            }
            finally
            {
                writer?.Flush();
                doc.Close();

                writer = null;
                doc    = null;
            }
        }