Exemple #1
0
    {//оценка : ID предмет оценка статус номер сессии idстудента
        public static void GiveStudents()
        {
            Student.Add(new student(1, "Студентов", "Студент", "Студентович", 161));
            MArks.Add(new marks(1, "ООП", 5, "Сдано", 1, 1));
            MArks.Add(new marks(2, "Матан", 5, "Сдано", 1, 1));
            MArks.Add(new marks(3, "Алгебра", 4, "Не сдано", 1, 1));
            MArks.Add(new marks(4, "Матан", 4, "Сдано", 2, 1));
            MArks.Add(new marks(5, "ООП", 4, "Сдано", 2, 1));

            Student.Add(new student(2, "Фиитова", "Фиита", "Фиитовна", 161));
            MArks.Add(new marks(6, "ООП", 5, "Сдано", 1, 2));
            MArks.Add(new marks(7, "Алгебра", 4, "Сдано", 1, 2));
            MArks.Add(new marks(8, "Матан", 5, "Сдано", 1, 2));
            MArks.Add(new marks(9, "ООП", 5, "Сдано", 2, 2));

            Student.Add(new student(3, "Рандомов", "Рандом", "Рандомович", 233));
            MArks.Add(new marks(10, "ООП", 5, "Сдано", 3, 3));
            MArks.Add(new marks(11, "Алгебра", 4, "Сдано", 3, 3));
            MArks.Add(new marks(12, "Матан", 5, "Сдано", 3, 3));
            MArks.Add(new marks(13, "ООП", 5, "Сдано", 4, 3));

            Student.Add(new student(4, "Программистов", "Программист", "Программистович", 233));
            MArks.Add(new marks(14, "ООП", 5, "Сдано", 3, 4));
            MArks.Add(new marks(15, "Алгебра", 4, "Сдано", 3, 4));
            MArks.Add(new marks(16, "Матан", 5, "Сдано", 3, 4));
            MArks.Add(new marks(17, "ООП", 5, "Сдано", 4, 4));

            DateTime d = new DateTime(2014, 11, 06);

            Redact.Add(new redact(1, 1, 3, d));
        }
        private static string GeneratePDF(UserDataJsonModel model, bool applyRedaction)
        {
            Library.Initialize(serialNo, key);

            try
            {
                // Create a new PDF with a blank page.
                using PDFDoc doc   = new PDFDoc();
                using Form form    = new Form(doc);
                using PDFPage page = doc.InsertPage(0, PDFPage.Size.e_SizeLetter);

                // Create a text field for each property of the user data json model.
                int iteration = 0;
                foreach (var prop in model.GetType().GetProperties())
                {
                    int offset = iteration * 60;
                    using Control control = form.AddControl(page, prop.Name, Field.Type.e_TypeTextField,
                                                            new RectF(50f, 600f - offset, 400f, 640f - offset));
                    using Field field = control.GetField();
                    var propValue = prop.GetValue(model);
                    field.SetValue($"{prop.Name}: {propValue}");
                    iteration++;
                }

                // Convert fillable form fields into readonly text labels.
                page.Flatten(true, (int)PDFPage.FlattenOptions.e_FlattenAll);

                if (applyRedaction)
                {
                    // Configure our text search to look at the first (and only) page in our PDF.
                    using var redaction = new Redaction(doc);
                    page.StartParse((int)foxit.pdf.PDFPage.ParseFlags.e_ParsePageNormal, null, false);
                    using TextPage textPage = new TextPage(page,
                                                           (int)foxit.pdf.TextPage.TextParseFlags.e_ParseTextUseStreamOrder);
                    using TextSearch search = new TextSearch(textPage);
                    RectFArray rectArray = new RectFArray();

                    // Mark text starting with the pattern "SIN:" to be redacted.
                    search.SetPattern("SIN:");
                    while (search.FindNext())
                    {
                        using var searchSentence = new TextSearch(textPage);
                        var sentence = search.GetMatchSentence();
                        searchSentence.SetPattern(sentence.Substring(sentence.IndexOf("SIN:")));

                        while (searchSentence.FindNext())
                        {
                            RectFArray itemArray = searchSentence.GetMatchRects();
                            rectArray.InsertAt(rectArray.GetSize(), itemArray);
                        }
                    }

                    // If we had matches to redact, then apply the redaction.
                    if (rectArray.GetSize() > 0)
                    {
                        using Redact redact = redaction.MarkRedactAnnot(page, rectArray);
                        redact.SetFillColor(0xFF0000);
                        redact.ResetAppearanceStream();
                        redaction.Apply();
                    }
                }

                // Save the file locally and return the file's location to the caller.
                string fileOutput = "./Output.pdf";
                doc.SaveAs(fileOutput, (int)PDFDoc.SaveFlags.e_SaveFlagNoOriginal);
                return(fileOutput);
            }
            finally
            {
                Library.Release();
            }
        }