Beispiel #1
0
        /// <summary>
        /// Export this course to the given path as pdf
        /// </summary>
        /// <param name="periods">An array of DateTime contains 3 items representing the start of the year,
        ///                     the start of the second period and the end of the half year.</param>
        /// <param name="storedPath">The path where the exported pdf should be stored.
        ///                     This path does NOT contain the name of this pdf file.
        ///                     The name will be like this format:
        ///                     CourseName-Teacher-Class.pdf</param>
        /// <param name="logoFilePath">A optional parameter represents where the logo is stored.
        ///                     If this is not given, then the logo will be replaced by the words "Sollstuden für Kurs"</param>
        /// <returns>A boolean value represents whether the export is successful or not.</returns>
        public bool ExportAsPDF(DateTime[] periods, string storedPath, string logoFilePath = "default")
        {
            string      title    = $"{this._courseName}-{this._teacher}-{this._className}";
            PdfDocument document = new PdfDocument();
            PdfPage     page     = document.AddPage();
            XGraphics   xGps     = XGraphics.FromPdfPage(page);

            #region Preset Format
            double ROWS = 30;
            //double SMALLWEEKDAYRECTWIDTH = Formats.getPixel(5);
            double SMALLDATERECTWIDTH = Formats.GetPixel(30);
            double SMALLNOTERECTWIDTH = Formats.GetPixel(55);
            double SMALLRECTHEIGHT    = Formats.GetPixel(7);
            double TOPHEIGHT          = Formats.GetPixel(40);
            double LEFTBLANK          = Formats.GetPixel(10);
            double CENTERBLANK        = Formats.GetPixel(20);
            //double RIGHTBLANK = Formats.getPixel(10);
            double OFFSET = Formats.GetPixel(1.5);
            //IN PIXEL
            XPoint[] smallRectStartCo = new XPoint[4] {
                new XPoint(), new XPoint(), new XPoint(), new XPoint()
            };

            #endregion

            #region Preset Text Format
            XFont          boldFont      = new XFont("Times New Roman", 10, XFontStyle.Bold);
            XFont          regularFont   = new XFont("Times New Roman", 10);
            XFont          titleFont     = new XFont("Times New Roman", 24, XFontStyle.Bold);
            XFont          subtitleFont  = new XFont("Times New Roman", 16, XFontStyle.Bold);
            XFont          smallNoteFont = new XFont("Times New Roman", 8);
            XTextFormatter xtf           = new XTextFormatter(xGps);
            XBrush[]       brushes       = new XBrush[2] {
                new XSolidBrush(XColor.FromArgb(230, 230, 230)), new XSolidBrush(XColor.FromArgb(210, 210, 210))
            };
            #endregion

            #region Responsive Design & Error check

            if (this._lines.Count > ROWS * 2)
            {
                ROWS           *= 1.3;
                SMALLRECTHEIGHT = Formats.GetPixel(6);
            }
            if (this._lines.Count > ROWS * 2)
            {
                ROWS           *= 1.3;
                SMALLRECTHEIGHT = Formats.GetPixel(4.5);
                OFFSET          = Formats.GetPixel(1);

                boldFont    = new XFont("Times New Roman", 8, XFontStyle.Bold);
                regularFont = new XFont("Times New Roman", 8);
            }
            //Round it to a whole number
            ROWS = Math.Round(ROWS);
            //If the data is too long or too short
            if (this._lines.Count > ROWS * 2)
            {
                throw new ArgumentException("the weeklyplan is too long: " + this._lines.Count + " : " + this._courseName + this._className + this._teacher);
            }
            else if (_lines.Count < 3)
            {
                throw new ArgumentException("the weeklyplan is too short: " + this._lines.Count + " course: " + this._courseName + this._className + this._teacher);
            }
            #endregion

            #region Points

            smallRectStartCo[0].X = LEFTBLANK;
            smallRectStartCo[0].Y = TOPHEIGHT;
            smallRectStartCo[1].X = LEFTBLANK + SMALLDATERECTWIDTH;
            smallRectStartCo[1].Y = TOPHEIGHT;
            smallRectStartCo[2].X = LEFTBLANK + SMALLDATERECTWIDTH + SMALLNOTERECTWIDTH + CENTERBLANK;
            smallRectStartCo[2].Y = TOPHEIGHT;
            smallRectStartCo[3].X = LEFTBLANK + CENTERBLANK + 2 * SMALLDATERECTWIDTH + SMALLNOTERECTWIDTH;
            smallRectStartCo[3].Y = TOPHEIGHT;

            #endregion

            #region HEAD
            //Set the Logo
            if (logoFilePath == "default")
            {
                XRect rectSubtitle = new XRect(0, 0, Formats.GetPixel(46), Formats.GetPixel(30));
                xGps.DrawString("Sollstuden für Kurs", subtitleFont, XBrushes.Gray, rectSubtitle, XStringFormats.TopLeft);
            }
            else
            {
                XImage lgIcon = XImage.FromFile(logoFilePath);
                if (lgIcon == null)
                {
                    throw new ArgumentNullException(nameof(logoFilePath), "the stream of this file path is null");
                }
                xGps.DrawImage(lgIcon, 0, 0, Formats.GetPixel(46), Formats.GetPixel(30));

                XRect rectSubtitle = new XRect(Formats.GetPixel(55), Formats.GetPixel(2), Formats.GetPixel(100), Formats.GetPixel(10));
                xGps.DrawString("Sollstuden für Kurs", subtitleFont, XBrushes.Gray, rectSubtitle, XStringFormats.TopLeft);
            }

            //Set the title
            XRect rectTitle = new XRect(Formats.GetPixel(55), Formats.GetPixel(10), Formats.GetPixel(100), Formats.GetPixel(20));
            xGps.DrawString(title, titleFont, XBrushes.Black, rectTitle, XStringFormats.TopLeft);

            //Set the current date and the half year
            DateTime dtNow    = DateTime.Now;
            XRect    rectDate = new XRect(Formats.GetPixel(180), Formats.GetPixel(2), Formats.GetPixel(28), Formats.GetPixel(5));
            xGps.DrawString($"Stand: {dtNow:dd-MM-yyyy}", regularFont, XBrushes.Gray, rectDate, XStringFormats.TopRight);

            XRect rectYear = new XRect(Formats.GetPixel(180), Formats.GetPixel(7), Formats.GetPixel(28), Formats.GetPixel(5));
            xGps.DrawString(DateTimeCalcUtils.GetHalfYear(this._lines[0].GetDate()), boldFont, XBrushes.Gray, rectYear, XStringFormats.TopRight);
            #endregion

            #region Main Body

            XRect rectCurrentLine;
            //The first column
            for (int i = 0; i < this._lines.Count && i < ROWS; i++)
            {
                //The color
                if (i % 2 != 0)
                {
                    xGps.DrawRectangle(brushes[0], new XRect(new XPoint(smallRectStartCo[0].X, smallRectStartCo[0].Y - OFFSET), new XPoint(smallRectStartCo[1].X + SMALLNOTERECTWIDTH, smallRectStartCo[1].Y + SMALLRECTHEIGHT - OFFSET)));
                }
                else
                {
                    xGps.DrawRectangle(brushes[1], new XRect(new XPoint(smallRectStartCo[0].X, smallRectStartCo[0].Y - OFFSET), new XPoint(smallRectStartCo[1].X + SMALLNOTERECTWIDTH, smallRectStartCo[1].Y + SMALLRECTHEIGHT - OFFSET)));
                }

                rectCurrentLine = new XRect(smallRectStartCo[0], new XPoint(LEFTBLANK + SMALLDATERECTWIDTH, smallRectStartCo[0].Y + SMALLRECTHEIGHT));
                xtf.DrawString(_lines[i].GetWeekdayS() + "  " + _lines[i].GetDateS(), boldFont, XBrushes.Black, rectCurrentLine, XStringFormats.TopLeft);
                rectCurrentLine = new XRect(smallRectStartCo[1], new XPoint(smallRectStartCo[1].X + SMALLNOTERECTWIDTH, smallRectStartCo[1].Y + SMALLRECTHEIGHT));
                xtf.DrawString(_lines[i].GetNotes(), regularFont, XBrushes.Black, rectCurrentLine, XStringFormats.TopLeft);

                smallRectStartCo[0].Y += SMALLRECTHEIGHT;
                smallRectStartCo[1].Y += SMALLRECTHEIGHT;
            }
            //The second column if exists
            if (this._lines.Count > ROWS)
            {
                for (int i = 0; i < _lines.Count - ROWS && i < ROWS; i++)
                {
                    //The color
                    if (i % 2 != 0)
                    {
                        xGps.DrawRectangle(brushes[0], new XRect(new XPoint(smallRectStartCo[2].X, smallRectStartCo[2].Y - OFFSET), new XPoint(smallRectStartCo[3].X + SMALLNOTERECTWIDTH, smallRectStartCo[3].Y + SMALLRECTHEIGHT - OFFSET)));
                    }
                    else
                    {
                        xGps.DrawRectangle(brushes[1], new XRect(new XPoint(smallRectStartCo[2].X, smallRectStartCo[2].Y - OFFSET), new XPoint(smallRectStartCo[3].X + SMALLNOTERECTWIDTH, smallRectStartCo[3].Y + SMALLRECTHEIGHT - OFFSET)));
                    }

                    rectCurrentLine = new XRect(smallRectStartCo[2], new XPoint(smallRectStartCo[3].X, smallRectStartCo[2].Y + SMALLRECTHEIGHT));
                    xtf.DrawString(_lines[i + (int)ROWS].GetWeekdayS() + "  " + _lines[i + (int)ROWS].GetDateS(), boldFont, XBrushes.Black, rectCurrentLine, XStringFormats.TopLeft);
                    rectCurrentLine = new XRect(smallRectStartCo[3], new XPoint(smallRectStartCo[3].X + SMALLNOTERECTWIDTH, smallRectStartCo[3].Y + SMALLRECTHEIGHT));
                    xtf.DrawString(_lines[i + (int)ROWS].GetNotes(), regularFont, XBrushes.Black, rectCurrentLine, XStringFormats.TopLeft);

                    smallRectStartCo[2].Y += SMALLRECTHEIGHT;
                    smallRectStartCo[3].Y += SMALLRECTHEIGHT;
                }
            }
            #endregion

            #region Bottom

            XRect        rect;
            const string INFO1 = "Alle Termine dieser Liste müssen in der Kursmappe eingetragen sein," +
                                 "auch die unterrichtsfreien Tage. Alle Termine(außer den Ferien)" +
                                 "müssen durch ihre Paraphe bestätigt werden. Tragen Sie bitte auch" +
                                 "die Fehlstundenzahl sowie die Soll - Ist - Stunden(Kursheft S.5) ein. ";
            const string INFO2 = "Hinweis: Schüler, die aus schulischen Gründen den Unterricht " +
                                 "versäumt haben(Klausur, schul.Veranstaltung usw.) müssen im " +
                                 "Kursheft aufgeführt werden. Diese Stunden dürfen auf dem " +
                                 "Zeugnis aber nicht als Fehlstunden vermerkt werden.";
            string OUTPUT = INFO1 + "\r\n\r\n" + INFO2;

            //If there is no lines at the second column, put the info direct at the second line.
            if (this._lines.Count - ROWS > 0)
            {
                rect = new XRect(smallRectStartCo[2].X, smallRectStartCo[2].Y + SMALLRECTHEIGHT, SMALLDATERECTWIDTH + SMALLNOTERECTWIDTH, Formats.A4.pixelHeight - (smallRectStartCo[2].Y + SMALLRECTHEIGHT));
                xtf.DrawString(OUTPUT, smallNoteFont, XBrushes.Black, rect, XStringFormats.TopLeft);
            }
            //Otherwise, add spaces
            else
            {
                rect = new XRect(smallRectStartCo[2].X, smallRectStartCo[2].Y, SMALLDATERECTWIDTH + SMALLNOTERECTWIDTH, Formats.A4.pixelHeight - (smallRectStartCo[2].Y + SMALLRECTHEIGHT));
                xtf.DrawString(OUTPUT, smallNoteFont, XBrushes.Black, rect, XStringFormats.TopLeft);
            }

            rect = new XRect(smallRectStartCo[0].X, smallRectStartCo[0].Y + Formats.GetPixel(1), SMALLNOTERECTWIDTH + SMALLDATERECTWIDTH, Formats.A4.pixelHeight - (smallRectStartCo[0].Y + SMALLRECTHEIGHT / 2));
            xGps.DrawString($"1. Kursabschnitt: {periods[0]:dd-MM-yyyy} - {periods[1].AddDays(-17):dd-MM-yyyy}", regularFont, XBrushes.Black, rect, XStringFormats.TopLeft);
            smallRectStartCo[0].Y += SMALLRECTHEIGHT / 2 + Formats.GetPixel(2);
            rect = new XRect(smallRectStartCo[0].X, smallRectStartCo[0].Y + Formats.GetPixel(1), SMALLNOTERECTWIDTH + SMALLDATERECTWIDTH, Formats.A4.pixelHeight - (smallRectStartCo[0].Y + SMALLRECTHEIGHT / 2));
            xGps.DrawString($"2. Kursabschnitt: {periods[1]:dd-MM-yyyy} - {periods[2]:dd-MM-yyyy}", regularFont, XBrushes.Black, rect, XStringFormats.TopLeft);
            #endregion

            #region Clean Up

            //Test illegal character to avoid the error when saving the document
            foreach (char c in title.ToCharArray())
            {
                //Test if there is illegal character in the title
                if (!((c >= 97 && c <= 123) || (c >= 48 && c <= 57) || (c >= 65 && c <= 90) ||
                      c == 45 || c == 46 || c == 64 || c == 95 || c == 32 || c == 'ä' || c == 'ö' || c == 'ü' ||
                      c == 'ß' || c == 'Ä' || c == 'Ö' || c == 'Ü'))
                {
                    //Replace it with .
                    title = title.Replace(c, '.');
                }
            }

            document.Save($"{storedPath}\\{title}.pdf");
            document.Close();
            document.Dispose();
            GC.Collect();

            Debug.WriteLine($"{storedPath}\\{title}.pdf ist exportiert.");
            #endregion
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Export this course to the given path as pdf
        /// </summary>
        /// <param name="periods">An array of DateTime contains 3 items representing the start of the year,
        ///                     the start of the second period and the end of the half year.</param>
        /// <param name="storedPath">The path where the exported pdf should be stored.
        ///                     This path does NOT contain the name of this pdf file.
        ///                     The name will be like this format:
        ///                     CourseName-Teacher-Class.pdf</param>
        /// <param name="logoFilePath">A optional parameter represents where the logo is stored.
        ///                     If this is not given, then the logo will be replaced by the words "Sollstuden für Kurs"</param>
        /// <returns>A boolean value represents whether the export is successful or not.</returns>
        public bool ExportAsPDF(DateTime[] periods, string storedPath)
        {
            DateTime     dtNow        = DateTime.Now;
            string       fileName     = $"{this._courseName}-{this._teacher}-{this._className}";
            string       title1       = $"Jahrgangstufe {this._className.Substring(0, 2)}.{DateTimeCalcUtils.GetHalfYearAsNumber(_lines[0].GetDate())}    {DateTimeCalcUtils.GetHalfYear(_lines[0].GetDate())}";
            string       title2       = $"Sollstunde für Kurs  {this._courseName}-{this._teacher}-{this._className}";
            const string columnTitle1 = "Tag";
            const string columnTitle2 = "Datum";
            const string columnTitle3 = "Besonderheit";

            PdfDocument document = new PdfDocument();
            PdfPage     page     = document.AddPage();
            XGraphics   xGps     = XGraphics.FromPdfPage(page);

            #region Preset Format
            const double ROWS = 70;
            //double SMALLWEEKDAYRECTWIDTH = Formats.getPixel(5);
            double SMALLDAYRECTWIDTH  = Formats.GetPixel(10);
            double SMALLDATERECTWIDTH = Formats.GetPixel(20);
            double SMALLNOTERECTWIDTH = Formats.GetPixel(55);
            double SMALLRECTHEIGHT    = Formats.GetPixel(3.6);
            double TOPHEIGHT          = Formats.GetPixel(21);
            double LEFTBLANK          = Formats.GetPixel(10);
            double CENTERBLANK        = Formats.GetPixel(20);
            //double RIGHTBLANK = Formats.getPixel(10);
            double OFFSET = Formats.GetPixel(0.6);
            //IN PIXEL
            XPoint[] smallRectStartCo = new XPoint[6] {
                new XPoint(), new XPoint(), new XPoint(), new XPoint(), new XPoint(), new XPoint()
            };

            #endregion

            #region Preset Text Format
            XFont          boldFont      = new XFont("Times New Roman", 7.5, XFontStyle.Bold);
            XFont          regularFont   = new XFont("Times New Roman", 7.5);
            XFont          titleFont     = new XFont("Times New Roman", 12, XFontStyle.Bold);
            XFont          subtitleFont  = new XFont("Times New Roman", 9, XFontStyle.Bold);
            XFont          smallNoteFont = new XFont("Times New Roman", 6.5);
            XTextFormatter xtf           = new XTextFormatter(xGps);
            XBrush[]       brushes       = new XBrush[2] {
                new XSolidBrush(XColor.FromArgb(230, 230, 230)), new XSolidBrush(XColor.FromArgb(210, 210, 210))
            };
            XPen pen     = new XPen(XColors.Gray, 0.5);
            XPen darkPen = new XPen(XColors.Black, 0.8);
            #endregion

            //If the data is too long or too short
            if (this._lines.Count > ROWS)
            {
                throw new ArgumentException($"The weeklyplan is too long: {_lines.Count}. \nAt: {_courseName}-{_className}-{_teacher}");
            }
            else if (_lines.Count < 3)
            {
                throw new ArgumentException($"The weeklyplan is too short: {_lines.Count}. \nAt: {_courseName}-{_className}-{_teacher}");
            }

            #region Points

            smallRectStartCo[0].X = LEFTBLANK;
            smallRectStartCo[0].Y = TOPHEIGHT;
            smallRectStartCo[1].X = LEFTBLANK + SMALLDAYRECTWIDTH;
            smallRectStartCo[1].Y = TOPHEIGHT;
            smallRectStartCo[2].X = LEFTBLANK + SMALLDAYRECTWIDTH + SMALLDATERECTWIDTH;
            smallRectStartCo[2].Y = TOPHEIGHT;
            smallRectStartCo[3].X = LEFTBLANK + SMALLDAYRECTWIDTH + SMALLDATERECTWIDTH + SMALLNOTERECTWIDTH + CENTERBLANK;
            smallRectStartCo[3].Y = TOPHEIGHT;
            smallRectStartCo[4].X = LEFTBLANK + 2 * SMALLDAYRECTWIDTH + SMALLDATERECTWIDTH + SMALLNOTERECTWIDTH + CENTERBLANK;
            smallRectStartCo[4].Y = TOPHEIGHT;
            smallRectStartCo[5].X = LEFTBLANK + CENTERBLANK + 2 * SMALLDAYRECTWIDTH + 2 * SMALLDATERECTWIDTH + SMALLNOTERECTWIDTH;
            smallRectStartCo[5].Y = TOPHEIGHT;

            #endregion

            #region HEAD

            //Set the titles
            XRect rectTitle = new XRect(Formats.GetPixel(10), Formats.GetPixel(3), Formats.GetPixel(85), Formats.GetPixel(5));
            xGps.DrawString(title1, titleFont, XBrushes.Black, rectTitle, XStringFormats.TopLeft);

            rectTitle = new XRect(Formats.GetPixel(10), Formats.GetPixel(8), Formats.GetPixel(85), Formats.GetPixel(5));
            xGps.DrawString(title2, titleFont, XBrushes.Black, rectTitle, XStringFormats.TopLeft);

            rectTitle = new XRect(smallRectStartCo[3].X, Formats.GetPixel(3), Formats.GetPixel(85), Formats.GetPixel(5));
            xGps.DrawString(title1, titleFont, XBrushes.Black, rectTitle, XStringFormats.TopLeft);

            rectTitle = new XRect(smallRectStartCo[3].X, Formats.GetPixel(8), Formats.GetPixel(85), Formats.GetPixel(5));
            xGps.DrawString(title2, titleFont, XBrushes.Black, rectTitle, XStringFormats.TopLeft);

            // column titles
            rectTitle = new XRect(new XPoint(smallRectStartCo[0].X, smallRectStartCo[0].Y - SMALLRECTHEIGHT - 5), new XPoint(LEFTBLANK + SMALLDATERECTWIDTH, smallRectStartCo[0].Y));
            xGps.DrawString(columnTitle1, boldFont, XBrushes.Black, rectTitle, XStringFormats.TopLeft);
            rectTitle = new XRect(new XPoint(smallRectStartCo[1].X, smallRectStartCo[0].Y - SMALLRECTHEIGHT - 5), new XPoint(LEFTBLANK + SMALLDATERECTWIDTH, smallRectStartCo[0].Y));
            xGps.DrawString(columnTitle2, boldFont, XBrushes.Black, rectTitle, XStringFormats.TopLeft);
            rectTitle = new XRect(new XPoint(smallRectStartCo[2].X, smallRectStartCo[0].Y - SMALLRECTHEIGHT - 5), new XPoint(smallRectStartCo[2].X + SMALLNOTERECTWIDTH, smallRectStartCo[2].Y));
            xGps.DrawString(columnTitle3, boldFont, XBrushes.Black, rectTitle, XStringFormats.TopLeft);

            rectTitle = new XRect(new XPoint(smallRectStartCo[3].X, smallRectStartCo[3].Y - SMALLRECTHEIGHT - 5), new XPoint(smallRectStartCo[3].X, smallRectStartCo[3].Y));
            xGps.DrawString(columnTitle1, boldFont, XBrushes.Black, rectTitle, XStringFormats.TopLeft);
            rectTitle = new XRect(new XPoint(smallRectStartCo[4].X, smallRectStartCo[3].Y - SMALLRECTHEIGHT - 5), new XPoint(smallRectStartCo[4].X, smallRectStartCo[3].Y));
            xGps.DrawString(columnTitle2, boldFont, XBrushes.Black, rectTitle, XStringFormats.TopLeft);
            rectTitle = new XRect(new XPoint(smallRectStartCo[5].X, smallRectStartCo[3].Y - SMALLRECTHEIGHT - 5), new XPoint(smallRectStartCo[5].X + SMALLNOTERECTWIDTH, smallRectStartCo[5].Y));
            xGps.DrawString(columnTitle3, boldFont, XBrushes.Black, rectTitle, XStringFormats.TopLeft);

            #endregion

            #region Main Body

            XRect rectCurrentLine;
            //The first column
            for (int i = 0; i < this._lines.Count && i < ROWS; i++)
            {
                //The color
                if (i % 2 != 0)
                {
                    xGps.DrawRectangle(brushes[0], new XRect(new XPoint(smallRectStartCo[0].X, smallRectStartCo[0].Y - OFFSET), new XPoint(smallRectStartCo[2].X + SMALLNOTERECTWIDTH, smallRectStartCo[2].Y + SMALLRECTHEIGHT - OFFSET)));
                }
                else
                {
                    xGps.DrawRectangle(brushes[1], new XRect(new XPoint(smallRectStartCo[0].X, smallRectStartCo[0].Y - OFFSET), new XPoint(smallRectStartCo[2].X + SMALLNOTERECTWIDTH, smallRectStartCo[2].Y + SMALLRECTHEIGHT - OFFSET)));
                }

                rectCurrentLine = new XRect(smallRectStartCo[0], new XPoint(LEFTBLANK + SMALLDAYRECTWIDTH, smallRectStartCo[0].Y + SMALLRECTHEIGHT));
                xtf.DrawString(_lines[i].GetWeekdayS(), boldFont, XBrushes.Black, rectCurrentLine, XStringFormats.TopLeft);
                rectCurrentLine = new XRect(smallRectStartCo[1], new XPoint(LEFTBLANK + SMALLDATERECTWIDTH, smallRectStartCo[1].Y + SMALLRECTHEIGHT));
                xtf.DrawString(_lines[i].GetDateS(), boldFont, XBrushes.Black, rectCurrentLine, XStringFormats.TopLeft);
                rectCurrentLine = new XRect(smallRectStartCo[2], new XPoint(smallRectStartCo[2].X + SMALLNOTERECTWIDTH, smallRectStartCo[2].Y + SMALLRECTHEIGHT));
                xtf.DrawString(_lines[i].GetNotes(), regularFont, XBrushes.Black, rectCurrentLine, XStringFormats.TopLeft);

                smallRectStartCo[0].Y += SMALLRECTHEIGHT;
                smallRectStartCo[1].Y += SMALLRECTHEIGHT;
                smallRectStartCo[2].Y += SMALLRECTHEIGHT;
            }
            //The second column
            for (int i = 0; i < _lines.Count && i < ROWS; i++)
            {
                //The color
                if (i % 2 != 0)
                {
                    xGps.DrawRectangle(brushes[0], new XRect(new XPoint(smallRectStartCo[3].X, smallRectStartCo[3].Y - OFFSET), new XPoint(smallRectStartCo[5].X + SMALLNOTERECTWIDTH, smallRectStartCo[5].Y + SMALLRECTHEIGHT - OFFSET)));
                }
                else
                {
                    xGps.DrawRectangle(brushes[1], new XRect(new XPoint(smallRectStartCo[3].X, smallRectStartCo[3].Y - OFFSET), new XPoint(smallRectStartCo[5].X + SMALLNOTERECTWIDTH, smallRectStartCo[5].Y + SMALLRECTHEIGHT - OFFSET)));
                }

                rectCurrentLine = new XRect(smallRectStartCo[3], new XPoint(smallRectStartCo[4].X, smallRectStartCo[3].Y + SMALLRECTHEIGHT));
                xtf.DrawString(_lines[i].GetWeekdayS(), boldFont, XBrushes.Black, rectCurrentLine, XStringFormats.TopLeft);
                rectCurrentLine = new XRect(smallRectStartCo[4], new XPoint(smallRectStartCo[5].X, smallRectStartCo[4].Y + SMALLRECTHEIGHT));
                xtf.DrawString(_lines[i].GetDateS(), boldFont, XBrushes.Black, rectCurrentLine, XStringFormats.TopLeft);
                rectCurrentLine = new XRect(smallRectStartCo[5], new XPoint(smallRectStartCo[5].X + SMALLNOTERECTWIDTH, smallRectStartCo[5].Y + SMALLRECTHEIGHT));
                xtf.DrawString(_lines[i].GetNotes(), regularFont, XBrushes.Black, rectCurrentLine, XStringFormats.TopLeft);

                smallRectStartCo[3].Y += SMALLRECTHEIGHT;
                smallRectStartCo[4].Y += SMALLRECTHEIGHT;
                smallRectStartCo[5].Y += SMALLRECTHEIGHT;
            }

            #endregion

            #region Bottom

            // Seperate lines
            xGps.DrawLine(darkPen, smallRectStartCo[0].X, TOPHEIGHT - 4, smallRectStartCo[2].X + SMALLNOTERECTWIDTH + 5, TOPHEIGHT - 4);
            xGps.DrawLine(pen, smallRectStartCo[1].X - 6, TOPHEIGHT - Formats.GetPixel(5.5), smallRectStartCo[1].X - 6, smallRectStartCo[0].Y);
            xGps.DrawLine(pen, smallRectStartCo[2].X - 15, TOPHEIGHT - Formats.GetPixel(5.5), smallRectStartCo[2].X - 15, smallRectStartCo[1].Y);

            xGps.DrawLine(darkPen, smallRectStartCo[3].X, TOPHEIGHT - 4, smallRectStartCo[5].X + SMALLNOTERECTWIDTH + 5, TOPHEIGHT - 4);
            xGps.DrawLine(pen, smallRectStartCo[4].X - 6, TOPHEIGHT - Formats.GetPixel(5), smallRectStartCo[4].X - 6, smallRectStartCo[0].Y);
            xGps.DrawLine(pen, smallRectStartCo[5].X - 15, TOPHEIGHT - Formats.GetPixel(5.5), smallRectStartCo[5].X - 15, smallRectStartCo[1].Y);



            XRect        rect;
            const string INFO1 = "Alle Termine dieser Liste müssen in der Kursmappe eingetragen sein, " +
                                 "auch die unterrichtsfreien Tage. Alle Termine(außer den Ferien) " +
                                 "müssen durch ihre Paraphe bestätigt werden. Tragen Sie bitte auch " +
                                 "die Fehlstundenzahl sowie die Soll - Ist - Stunden(Kursheft S.5) ein. ";
            const string INFO2 = "Hinweis: Schüler, die aus schulischen Gründen den Unterricht " +
                                 "versäumt haben(Klausur, schul.Veranstaltung usw.) müssen im " +
                                 "Kursheft aufgeführt werden. Diese Stunden dürfen auf dem " +
                                 "Zeugnis aber nicht als Fehlstunden vermerkt werden.";
            string OUTPUT = INFO1 + "\r\n" + INFO2;


            rect = new XRect(smallRectStartCo[0].X, smallRectStartCo[0].Y + Formats.GetPixel(1), SMALLNOTERECTWIDTH + SMALLDATERECTWIDTH, Formats.A4.pixelHeight - (smallRectStartCo[0].Y + SMALLRECTHEIGHT / 2));
            xGps.DrawString($"1. Kursabschnitt: {periods[0]:dd.MM.yyyy} - {periods[1]:dd.MM.yyyy}", smallNoteFont, XBrushes.Black, rect, XStringFormats.TopLeft);
            smallRectStartCo[0].Y += SMALLRECTHEIGHT / 2 + Formats.GetPixel(1);
            rect = new XRect(smallRectStartCo[0].X, smallRectStartCo[0].Y + Formats.GetPixel(1), SMALLNOTERECTWIDTH + SMALLDATERECTWIDTH, Formats.A4.pixelHeight - (smallRectStartCo[0].Y + SMALLRECTHEIGHT / 2));
            xGps.DrawString($"2. Kursabschnitt: {periods[2]:dd.MM.yyyy} - {periods[3]:dd.MM.yyyy}", smallNoteFont, XBrushes.Black, rect, XStringFormats.TopLeft);

            smallRectStartCo[0].Y += SMALLRECTHEIGHT / 2 + Formats.GetPixel(3);
            rect = new XRect(smallRectStartCo[0].X, smallRectStartCo[0].Y + Formats.GetPixel(1), SMALLNOTERECTWIDTH + SMALLDATERECTWIDTH, Formats.A4.pixelHeight - (smallRectStartCo[0].Y + SMALLRECTHEIGHT / 2));
            xtf.DrawString(OUTPUT, smallNoteFont, XBrushes.Black, rect, XStringFormats.TopLeft);


            //Set the current date and the half year
            XRect rectDate = new XRect(Formats.GetPixel(180), Formats.GetPixel(289), Formats.GetPixel(28), Formats.GetPixel(4));
            xGps.DrawString($"Stand: {dtNow:dd.MM.yyyy}", regularFont, XBrushes.Gray, rectDate, XStringFormats.TopRight);

            XRect rectYear = new XRect(Formats.GetPixel(180), Formats.GetPixel(293), Formats.GetPixel(28), Formats.GetPixel(4));
            xGps.DrawString(DateTimeCalcUtils.GetHalfYear(this._lines[0].GetDate()), boldFont, XBrushes.Gray, rectYear, XStringFormats.TopRight);
            #endregion

            #region Clean Up

            //Test illegal character to avoid the error when saving the document
            foreach (char c in fileName.ToCharArray())
            {
                //Test if there is illegal character in the title
                if (!((c >= 97 && c <= 123) || (c >= 48 && c <= 57) || (c >= 65 && c <= 90) ||
                      c == 45 || c == 46 || c == 64 || c == 95 || c == 32 || c == 'ä' || c == 'ö' || c == 'ü' ||
                      c == 'ß' || c == 'Ä' || c == 'Ö' || c == 'Ü'))
                {
                    //Replace it with .
                    fileName = fileName.Replace(c, '.');
                }
            }

            document.Save($"{storedPath}\\{fileName}.pdf");
            document.Close();
            document.Dispose();

            Debug.WriteLine($"{storedPath}\\{fileName}.pdf ist exportiert.");
            #endregion
            return(true);
        }