Exemplo n.º 1
0
        private void DrawStrightLine(PdfPageBase page)
        {
            PointF[] points = new PointF[4];
            //clear the watermark
            int downRate = 1;
            int leftRate = 2;

            points[0] = new PointF(-1 - leftRate, -1 + downRate);
            points[1] = new PointF(-1 - leftRate, 1 + downRate);
            points[2] = new PointF(1 - leftRate, 1 + downRate);
            points[3] = new PointF(1 - leftRate, -1 + downRate);

            PdfPath path = new PdfPath();

            path.AddLine(points[0], points[1]);
            path.AddLine(points[1], points[2]);
            path.AddLine(points[2], points[3]);
            path.AddLine(points[3], points[0]);

            //save graphics state
            //PdfGraphicsState state = page.Canvas.Save();
            PdfPen pen = new PdfPen(Color.DeepSkyBlue, 0.02f);

            page.Canvas.ScaleTransform(105f, 105f);
            page.Canvas.TranslateTransform(5f, 1.2f);
            page.Canvas.DrawPath(pen, path);

            //drawing a stright line
            PdfPath path2 = new PdfPath();

            path2.AddLine(new PointF(-4.5f, 0), new PointF(-3f, 3.53f));
            PdfPen pen2 = new PdfPen(Color.Red, 0.046f);

            page.Canvas.DrawPath(pen2, path2);
        }
Exemplo n.º 2
0
        private void DrawLineFunc(PdfPageBase page)
        {
            state = page.Canvas.Save();

            //Draw Rectagle
            PdfPen   pen    = PdfPens.DeepSkyBlue;
            PdfBrush brush  = new PdfSolidBrush(Color.Red);//画刷,颜色为red
            PdfPath  path   = new PdfPath();
            float    offset = 50;

            PointF[] points = new PointF[] { new PointF(0, 0), new PointF(0, 80), new PointF(80, 80), new PointF(80, 0) };
            for (int i = 0; i < points.Length; i++)
            {
                points[i].X += offset;
                points[i].Y += offset;
            }
            path.AddLine(points[0], points[1]);
            path.AddLine(points[1], points[2]);
            path.AddLine(points[2], points[3]);
            path.AddLine(points[3], points[0]);

            page.Canvas.DrawPath(pen, path);

            page.Canvas.TranslateTransform(280, 0);
            path.FillMode = PdfFillMode.Winding;
            page.Canvas.DrawPath(pen, brush, path);
            //drawing line
            PdfPath Linepath = new PdfPath();

            Linepath.AddLine(new PointF(70, 270), new PointF(96, 192));
            page.Canvas.DrawPath(pen, Linepath);

            //restor graphics
            page.Canvas.Restore(state);
        }
Exemplo n.º 3
0
        private void DrawStrightLine(PdfPageBase page)
        {
            PointF[] points = new PointF[4];

            points[0] = new PointF(-1, -1);
            points[1] = new PointF(-1, 1);
            points[2] = new PointF(1, 1);
            points[3] = new PointF(1, -1);

            PdfPath path = new PdfPath();

            path.AddLine(points[0], points[1]);
            path.AddLine(points[1], points[2]);
            path.AddLine(points[2], points[3]);
            path.AddLine(points[3], points[0]);


            //save graphics state
            PdfGraphicsState state = page.Canvas.Save();
            PdfPen           pen   = new PdfPen(Color.DeepSkyBlue, 0.02f);

            // PdfBrush brush1 = new PdfSolidBrush(Color.CadetBlue);

            page.Canvas.ScaleTransform(80f, 80f);
            page.Canvas.TranslateTransform(5f, 1.2f);
            page.Canvas.DrawPath(pen, path);

            PdfPath path2 = new PdfPath();

            path2.AddLine(new PointF(-3, 0), new PointF(-3, 3));
            page.Canvas.DrawPath(pen, path2);
        }
Exemplo n.º 4
0
        private void DrawPath(PdfPageBase page)
        {
            PointF[] points = new PointF[5];
            for (int i = 0; i < points.Length; i++)
            {
                float x = (float)Math.Cos(i * 2 * Math.PI / 5);
                float y = (float)Math.Sin(i * 2 * Math.PI / 5);
                points[i] = new PointF(x, y);
            }
            PdfPath path = new PdfPath();

            path.AddLine(points[2], points[0]);
            path.AddLine(points[0], points[3]);
            path.AddLine(points[3], points[1]);
            path.AddLine(points[1], points[4]);
            path.AddLine(points[4], points[2]);

            //save graphics state
            PdfGraphicsState state  = page.Canvas.Save();
            PdfPen           pen    = new PdfPen(Color.DeepSkyBlue, 0.02f);
            PdfBrush         brush1 = new PdfSolidBrush(Color.CadetBlue);

            page.Canvas.ScaleTransform(50f, 50f);
            page.Canvas.TranslateTransform(5f, 1.2f);
            page.Canvas.DrawPath(pen, path);

            page.Canvas.TranslateTransform(2f, 0f);
            path.FillMode = PdfFillMode.Alternate;
            page.Canvas.DrawPath(pen, brush1, path);

            page.Canvas.TranslateTransform(2f, 0f);
            path.FillMode = PdfFillMode.Winding;
            page.Canvas.DrawPath(pen, brush1, path);

            PdfLinearGradientBrush brush2 = new PdfLinearGradientBrush(new PointF(-2, 0), new PointF(2, 0), Color.Red, Color.Blue);

            page.Canvas.TranslateTransform(-4f, 2f);
            path.FillMode = PdfFillMode.Alternate;
            page.Canvas.DrawPath(pen, brush2, path);

            PdfRadialGradientBrush brush3 = new PdfRadialGradientBrush(new PointF(0f, 0f), 0f, new PointF(0f, 0f), 1f, Color.Red, Color.Blue);

            page.Canvas.TranslateTransform(2f, 0f);
            path.FillMode = PdfFillMode.Winding;
            page.Canvas.DrawPath(pen, brush3, path);

            PdfTilingBrush brush4 = new PdfTilingBrush(new RectangleF(0, 0, 4f, 4f));

            brush4.Graphics.DrawRectangle(brush2, 0, 0, 4f, 4f);

            page.Canvas.TranslateTransform(2f, 0f);
            path.FillMode = PdfFillMode.Winding;
            page.Canvas.DrawPath(pen, brush4, path);

            //restor graphics
            page.Canvas.Restore(state);
        }
Exemplo n.º 5
0
        private void DrawStrightLine(PdfPageBase page)
        {
            PointF[] points = new PointF[4];



            int downRate = 350;
            int leftRate = 150;
            int baseRate = 94;

            points[0] = new PointF(-baseRate + leftRate, -baseRate + downRate);
            points[1] = new PointF(-baseRate + leftRate, baseRate + downRate);
            points[2] = new PointF(baseRate + leftRate, baseRate + downRate);
            points[3] = new PointF(baseRate + leftRate, -baseRate + downRate);



            PdfPath path = new PdfPath();

            path.AddLine(points[0], points[1]);
            path.AddLine(points[1], points[2]);
            path.AddLine(points[2], points[3]);
            path.AddLine(points[3], points[0]);



            //save graphics state
            //PdfGraphicsState state = page.Canvas.Save();
            PdfPen pen = new PdfPen(Color.DeepSkyBlue, 2f);



            // page.Canvas.ScaleTransform(95f, 95f);
            //skewTransform б±ä»»

            page.Canvas.SkewTransform(10, 10);

            //page.Canvas.RotateTransform(-15.5f);
            //translation operator
            page.Canvas.TranslateTransform(0, -90);//shift shapes
            // page.Canvas.TranslateTransform(5f, 1.2f);

            page.Canvas.DrawPath(pen, path);



            //drawing a stright line
            PdfPath path2 = new PdfPath();

            path2.AddLine(new PointF(0, 450f), new PointF(258f, 450f));
            PdfPen pen2 = new PdfPen(Color.Blue, 3f);

            page.Canvas.DrawPath(pen2, path2);
        }
        private void DrawPath(PdfPageBase page)
        {
            PointF[] points = new PointF[5];
            for (int i = 0; i < points.Length; i++)
            {
                float x = (float)Math.Cos(i * 2 * Math.PI / 5);
                float y = (float)Math.Sin(i * 2 * Math.PI / 5);
                points[i] = new PointF(x, y);
            }
            PdfPath path = new PdfPath();
            path.AddLine(points[2], points[0]);
            path.AddLine(points[0], points[3]);
            path.AddLine(points[3], points[1]);
            path.AddLine(points[1], points[4]);
            path.AddLine(points[4], points[2]);

            //save graphics state
            PdfGraphicsState state = page.Canvas.Save();
            PdfPen pen = new PdfPen(Color.DeepSkyBlue, 0.02f);
            PdfBrush brush1 = new PdfSolidBrush(Color.CadetBlue);

            page.Canvas.ScaleTransform(50f, 50f);
            page.Canvas.TranslateTransform(5f, 1.2f);
            page.Canvas.DrawPath(pen, path);

            page.Canvas.TranslateTransform(2f, 0f);
            path.FillMode = PdfFillMode.Alternate;
            page.Canvas.DrawPath(pen, brush1, path);

            page.Canvas.TranslateTransform(2f, 0f);
            path.FillMode = PdfFillMode.Winding;
            page.Canvas.DrawPath(pen, brush1, path);

            PdfLinearGradientBrush brush2 = new PdfLinearGradientBrush(new PointF(-2, 0), new PointF(2, 0), Color.Red, Color.Blue);
            page.Canvas.TranslateTransform(-4f, 2f);
            path.FillMode = PdfFillMode.Alternate;
            page.Canvas.DrawPath(pen, brush2, path);

            PdfRadialGradientBrush brush3 = new PdfRadialGradientBrush(new PointF(0f, 0f), 0f, new PointF(0f, 0f), 1f, Color.Red, Color.Blue);
            page.Canvas.TranslateTransform(2f, 0f);
            path.FillMode = PdfFillMode.Winding;
            page.Canvas.DrawPath(pen, brush3, path);

            PdfTilingBrush brush4 = new PdfTilingBrush(new RectangleF(0, 0, 4f, 4f));
            brush4.Graphics.DrawRectangle(brush2, 0, 0, 4f, 4f);

            page.Canvas.TranslateTransform(2f, 0f);
            path.FillMode = PdfFillMode.Winding;
            page.Canvas.DrawPath(pen, brush4, path);

            //restor graphics
            page.Canvas.Restore(state);
        }
Exemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Load a pdf document
            string input = "..\\..\\..\\..\\..\\..\\Data\\AddTextStamp.pdf";

            //Open a pdf document
            PdfDocument document = new PdfDocument();

            document.LoadFromFile(input);
            //Get the first page
            PdfPageBase page = document.Pages[0];

            //Create a pdf template
            PdfTemplate     template     = new PdfTemplate(125, 55);
            PdfTrueTypeFont font1        = new PdfTrueTypeFont(new Font("Elephant", 10f, FontStyle.Italic), true);
            PdfSolidBrush   brush        = new PdfSolidBrush(Color.DarkRed);
            PdfPen          pen          = new PdfPen(brush);
            RectangleF      rectangle    = new RectangleF(new PointF(5, 5), template.Size);
            int             CornerRadius = 20;
            PdfPath         path         = new PdfPath();

            path.AddArc(template.GetBounds().X, template.GetBounds().Y, CornerRadius, CornerRadius, 180, 90);
            path.AddArc(template.GetBounds().X + template.Width - CornerRadius, template.GetBounds().Y, CornerRadius, CornerRadius, 270, 90);
            path.AddArc(template.GetBounds().X + template.Width - CornerRadius, template.GetBounds().Y + template.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
            path.AddArc(template.GetBounds().X, template.GetBounds().Y + template.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
            path.AddLine(template.GetBounds().X, template.GetBounds().Y + template.Height - CornerRadius, template.GetBounds().X, template.GetBounds().Y + CornerRadius / 2);
            template.Graphics.DrawPath(pen, path);

            //Draw stamp text
            String s1 = "REVISED\n";
            String s2 = "by E-iceblue at " + DateTime.Now.ToString("MM dd, yyyy");

            template.Graphics.DrawString(s1, font1, brush, new PointF(5, 10));
            PdfTrueTypeFont font2 = new PdfTrueTypeFont(new Font("Lucida Sans Unicode", 9f, FontStyle.Bold), true);

            template.Graphics.DrawString(s2, font2, brush, new PointF(2, 30));

            //Create a rubber stamp
            PdfRubberStampAnnotation stamp       = new PdfRubberStampAnnotation(rectangle);
            PdfAppearance            apprearance = new PdfAppearance(stamp);

            apprearance.Normal = template;
            stamp.Appearance   = apprearance;

            //Draw stamp into page
            page.AnnotationsWidget.Add(stamp);

            string output = "AddTextStamp.pdf";

            //Save pdf document
            document.SaveToFile(output);

            //Launch the file
            PDFDocumentViewer(output);
        }
Exemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            //pdf file
            string input = "..\\..\\..\\..\\..\\..\\..\\Data\\Sample5.pdf";

            //open a pdf document
            PdfDocument document = new PdfDocument(input);

            //get the first page
            PdfPageBase page = document.Pages[0];

            //create a pdf template
            PdfTemplate     template     = new PdfTemplate(200, 50);
            PdfTrueTypeFont font1        = new PdfTrueTypeFont(new Font("Elephant", 16f, FontStyle.Italic), true);
            PdfSolidBrush   brush        = new PdfSolidBrush(Color.DarkRed);
            PdfPen          pen          = new PdfPen(brush);
            RectangleF      rectangle    = new RectangleF(new PointF(0, 0), template.Size);
            int             CornerRadius = 20;
            PdfPath         path         = new PdfPath();

            path.AddArc(template.GetBounds().X, template.GetBounds().Y, CornerRadius, CornerRadius, 180, 90);
            path.AddArc(template.GetBounds().X + template.Width - CornerRadius, template.GetBounds().Y, CornerRadius, CornerRadius, 270, 90);
            path.AddArc(template.GetBounds().X + template.Width - CornerRadius, template.GetBounds().Y + template.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
            path.AddArc(template.GetBounds().X, template.GetBounds().Y + template.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
            path.AddLine(template.GetBounds().X, template.GetBounds().Y + template.Height - CornerRadius, template.GetBounds().X, template.GetBounds().Y + CornerRadius / 2);
            template.Graphics.DrawPath(pen, path);

            //draw stamp text
            String s1 = "REVISED\n";
            String s2 = "By Jack at " + DateTime.Now.ToString("HH:mm, MM dd, yyyy");

            template.Graphics.DrawString(s1, font1, brush, new PointF(5, 5));
            PdfTrueTypeFont font2 = new PdfTrueTypeFont(new Font("Gadugi", 12f, FontStyle.Bold), true);

            template.Graphics.DrawString(s2, font2, brush, new PointF(2, 28));

            //create a rubber stamp
            PdfRubberStampAnnotation stamp       = new PdfRubberStampAnnotation(rectangle);
            PdfAppearance            apprearance = new PdfAppearance(stamp);

            apprearance.Normal = template;
            stamp.Appearance   = apprearance;

            //draw stamp into page
            page.AnnotationsWidget.Add(stamp);

            string output = "AddTextStamp.pdf";

            //save pdf document
            document.SaveToFile(output);

            //Launching the Pdf file
            PDFDocumentViewer(output);
        }
Exemplo n.º 9
0
        private void DrawRectangle(PdfPageBase page)
        {
            //notice the watermarker
            //drawing a stright line
            PdfPath path2 = new PdfPath();

            path2.AddLine(new PointF(1f, 310), new PointF(1f, 50f));
            PdfPen pen2 = new PdfPen(Color.Black, 2f);

            page.Canvas.RotateTransform(-45f);
            // page.Canvas.ScaleTransform(85f,85f);
            page.Canvas.DrawPath(pen2, path2);
        }
Exemplo n.º 10
0
        public void GeneratePdf()
        {
            decimal     totale = 0;
            PdfDocument doc    = new PdfDocument();
            PdfPageBase page   = doc.Pages.Add(PdfPageSize.A6);
            PdfPageBase page2  = null;
            PdfPageBase page3  = null;
            PdfPageBase page4  = null;

            PdfPageBase[] pages = { page, page2, page3, page4 };

            //save graphics state
            PdfGraphicsState state = page.Canvas.Save();

            //Draw the text - alignment
            PdfFont       font  = new PdfFont(PdfFontFamily.Courier, 6f);
            PdfFont       font2 = new PdfFont(PdfFontFamily.Courier, 4f);
            PdfFont       font3 = new PdfFont(PdfFontFamily.Courier, 4f, PdfFontStyle.Strikeout);
            PdfSolidBrush brush = new PdfSolidBrush(System.Drawing.Color.Black);

            PdfStringFormat leftAlignment = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);

            page.Canvas.DrawString(DateTime.Now.ToString(), font, brush, 0, 40, leftAlignment);

            PdfStringFormat rightAlignment = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);

            PdfStringFormat centerAlignment
                = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

            page.Canvas.DrawString(Receipe.Name,
                                   font, brush, page.Canvas.ClientSize.Width / 2, 20, centerAlignment);
            PdfStringFormat centerAlignment2
                = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

            page.Canvas.DrawString(Receipe.Address,
                                   font, brush, page.Canvas.ClientSize.Width / 2, 30, centerAlignment2);
            PdfStringFormat centerAlignment3
                = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

            page.Canvas.DrawString("PODSUMOWANIE DNIA",
                                   font, brush, page.Canvas.ClientSize.Width / 2, 50, centerAlignment3);

            PdfPath path = new PdfPath();

            path.AddLine(new PointF(10, 55), new PointF(page.Canvas.ClientSize.Width - 10, 55));

            PdfPen pen = new PdfPen(System.Drawing.Color.Black, 0.8f);

            page.Canvas.DrawPath(pen, path);

            float pageoneh   = 60;
            float pagetwoh   = 20;
            float pagethreeh = 20;
            float pagefourh  = 20;

            //_recp.listOfBoughtProducts.RemoveRange(24, _recp.listOfBoughtProducts.Count-24);
            foreach (var x in _listOfObjects)
            {
                if (x.Name != null)
                {
                    totale += x.TotalPrice;
                    string ilosc = "Ilosc sprzedanych: " + x.Sum.ToString();
                    string cena  = "Suma cenowa: " + x.TotalPrice.ToString();
                    string nazwa = x.Name.Substring(0, x.Name.Length > 45 ? 45 : x.Name.Length) + " " + ilosc;

                    if (pageoneh < 310)
                    {
                        page.Canvas.DrawString(nazwa, font2, brush, 0, pageoneh, leftAlignment);
                        page.Canvas.DrawString(cena, font2, brush, page.Canvas.ClientSize.Width, pageoneh,
                                               rightAlignment);
                        pageoneh += 10;
                    }
                    if (pageoneh == 310)
                    {
                        if (page2 == null)
                        {
                            page2 = doc.Pages.Add(PdfPageSize.A6);
                        }
                    }
                    if (pageoneh == 310 && pagetwoh < 310)
                    {
                        page2.Canvas.DrawString(nazwa, font2, brush, 0, pagetwoh, leftAlignment);
                        page2.Canvas.DrawString(cena, font2, brush, page.Canvas.ClientSize.Width, pagetwoh,
                                                rightAlignment);
                        pagetwoh += 10;
                    }
                    if (pagetwoh == 310)
                    {
                        if (page3 == null)
                        {
                            page3 = doc.Pages.Add(PdfPageSize.A6);
                        }
                    }
                    if (pagetwoh == 310 && pagethreeh < 310)
                    {
                        page3.Canvas.DrawString(nazwa, font2, brush, 0, pagethreeh, leftAlignment);
                        page3.Canvas.DrawString(cena, font2, brush, page.Canvas.ClientSize.Width, pagethreeh,
                                                rightAlignment);
                        pagethreeh += 10;
                    }
                    if (pagethreeh == 310)
                    {
                        if (page4 == null)
                        {
                            page4 = doc.Pages.Add(PdfPageSize.A6);
                        }
                    }
                    if (pagethreeh == 310 && pagefourh < 310)
                    {
                        page4.Canvas.DrawString(nazwa, font2, brush, 0, pagefourh, leftAlignment);
                        page4.Canvas.DrawString(cena, font2, brush, page.Canvas.ClientSize.Width, pagefourh,
                                                rightAlignment);
                        pagefourh += 10;
                    }
                }
            }

            PdfPath path2 = null;
            PdfPen  pen2  = null;

            if (page4 != null)
            {
                path2 = new PdfPath();

                path2.AddLine(new PointF(10, pagefourh + 5),
                              new PointF(page.Canvas.ClientSize.Width - 10, pagefourh + 5));

                pen2 = new PdfPen(System.Drawing.Color.Black, 0.8f);
                page4.Canvas.DrawPath(pen2, path2);

                page4.Canvas.DrawString("UTARG PLN DNIOWY: " + totale, font2, brush, page.Canvas.ClientSize.Width,
                                        pagefourh + 10, rightAlignment);
            }
            else if (page4 == null && page3 != null)
            {
                path2 = new PdfPath();

                path2.AddLine(new PointF(10, pagethreeh + 5),
                              new PointF(page.Canvas.ClientSize.Width - 10, pagethreeh + 5));

                pen2 = new PdfPen(System.Drawing.Color.Black, 0.8f);
                page3.Canvas.DrawPath(pen2, path2);

                page3.Canvas.DrawString("UTARG PLN DNIOWY: " + totale, font2, brush, page.Canvas.ClientSize.Width,
                                        pagethreeh + 10, rightAlignment);
            }
            else if (page3 == null && page2 != null)
            {
                path2 = new PdfPath();

                path2.AddLine(new PointF(10, pagetwoh + 5),
                              new PointF(page.Canvas.ClientSize.Width - 10, pagetwoh + 5));

                pen2 = new PdfPen(System.Drawing.Color.Black, 0.8f);
                page2.Canvas.DrawPath(pen2, path2);

                page2.Canvas.DrawString("UTARG PLN DNIOWY: " + totale, font2, brush, page.Canvas.ClientSize.Width,
                                        pagetwoh + 10, rightAlignment);
            }
            else if (page2 == null && page != null)
            {
                path2 = new PdfPath();

                path2.AddLine(new PointF(10, pageoneh + 5),
                              new PointF(page.Canvas.ClientSize.Width - 10, pageoneh + 5));

                pen2 = new PdfPen(System.Drawing.Color.Black, 0.8f);
                page.Canvas.DrawPath(pen2, path2);

                page.Canvas.DrawString("UTARG PLN DNIOWY: " + totale, font2, brush, page.Canvas.ClientSize.Width,
                                       pageoneh + 10, rightAlignment);
            }
            //page.Canvas.DrawString("Left!", font, brush, 0, 60, leftAlignment);


            //restor graphics
            page.Canvas.Restore(state);
            //Save doc file.
            string fileName = "RaportDniowy.pdf";

            doc.SaveToFile(fileName);
            doc.Close();

            //Launching the Pdf file.
            System.Diagnostics.Process.Start(fileName);
        }
Exemplo n.º 11
0
        public void GeneratePdf()
        {
            PdfDocument doc   = new PdfDocument();
            PdfPageBase page  = doc.Pages.Add(PdfPageSize.A6);
            PdfPageBase page2 = null;
            PdfPageBase page3 = null;
            PdfPageBase page4 = null;

            PdfPageBase[] pages = new PdfPageBase[] { page, page2, page3, page4 };

            //save graphics state
            PdfGraphicsState state = page.Canvas.Save();

            //Draw the text - alignment
            PdfFont       font  = new PdfFont(PdfFontFamily.Courier, 6f);
            PdfFont       font2 = new PdfFont(PdfFontFamily.Courier, 4f);
            PdfFont       font3 = new PdfFont(PdfFontFamily.Courier, 4f, PdfFontStyle.Strikeout);
            PdfSolidBrush brush = new PdfSolidBrush(System.Drawing.Color.Black);

            PdfStringFormat leftAlignment = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);

            page.Canvas.DrawString(_recp.Data.ToString(), font, brush, 0, 40, leftAlignment);

            PdfStringFormat rightAlignment = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);

            page.Canvas.DrawString("Nr. transakcji: " + Convert.ToString(_recp.TransactionNumber), font, brush,
                                   page.Canvas.ClientSize.Width, 40, rightAlignment);

            PdfStringFormat centerAlignment
                = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

            page.Canvas.DrawString(Receipe.Name,
                                   font, brush, page.Canvas.ClientSize.Width / 2, 20, centerAlignment);
            PdfStringFormat centerAlignment2
                = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

            page.Canvas.DrawString(Receipe.Address,
                                   font, brush, page.Canvas.ClientSize.Width / 2, 30, centerAlignment2);
            PdfStringFormat centerAlignment3
                = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

            page.Canvas.DrawString("PARAGON FISKALNY",
                                   font, brush, page.Canvas.ClientSize.Width / 2, 50, centerAlignment3);

            PdfPath path = new PdfPath();

            path.AddLine(new PointF(10, 55), new PointF(page.Canvas.ClientSize.Width - 10, 55));

            PdfPen pen = new PdfPen(System.Drawing.Color.Black, 0.8f);

            page.Canvas.DrawPath(pen, path);

            float pageoneh   = 60;
            float pagetwoh   = 20;
            float pagethreeh = 20;
            float pagefourh  = 20;

            //_recp.listOfBoughtProducts.RemoveRange(24, _recp.listOfBoughtProducts.Count-24);
            foreach (var x in _recp.ListOfBoughtProducts)
            {
                string ilosc = "";
                string cena  = x.ChoseOptionPrice.ToString();
                if (x.OverwallDiscountName != null && x.SigleDiscountName == null)
                {
                    ilosc = (x.Count.ToString() + ",Znizka Cal." + x.OverwallDiscountName);
                }
                else if (x.SigleDiscountName != null && x.OverwallDiscountName == null)
                {
                    ilosc = (x.Count.ToString() + ",Znizka Poj." + x.SigleDiscountName);
                }
                else if (x.SigleDiscountName != null && x.OverwallDiscountName != null)
                {
                    ilosc = (x.Count.ToString() + ",Znizka Cal." + x.OverwallDiscountName + ",Znizka Poj." +
                             x.SigleDiscountName);
                }
                else
                {
                    ilosc = x.Count.ToString();
                }
                string nazwa = x.Name.Substring(0, x.Name.Length > 45 ? 45 : x.Name.Length) + " Il." + ilosc;
                if (pageoneh < 310)
                {
                    page.Canvas.DrawString(nazwa, font2, brush, 0, pageoneh, leftAlignment);
                    page.Canvas.DrawString(cena, font2, brush, page.Canvas.ClientSize.Width, pageoneh, rightAlignment);
                    pageoneh += 10;
                }
                if (pageoneh == 310)
                {
                    if (page2 == null)
                    {
                        page2 = doc.Pages.Add(PdfPageSize.A6);
                    }
                }
                if (pageoneh == 310 && pagetwoh < 310)
                {
                    page2.Canvas.DrawString(nazwa, font2, brush, 0, pagetwoh, leftAlignment);
                    page2.Canvas.DrawString(cena, font2, brush, page.Canvas.ClientSize.Width, pagetwoh, rightAlignment);
                    pagetwoh += 10;
                }
                if (pagetwoh == 310)
                {
                    if (page3 == null)
                    {
                        page3 = doc.Pages.Add(PdfPageSize.A6);
                    }
                }
                if (pagetwoh == 310 && pagethreeh < 310)
                {
                    page3.Canvas.DrawString(nazwa, font2, brush, 0, pagethreeh, leftAlignment);
                    page3.Canvas.DrawString(cena, font2, brush, page.Canvas.ClientSize.Width, pagethreeh,
                                            rightAlignment);
                    pagethreeh += 10;
                }
                if (pagethreeh == 310)
                {
                    if (page4 == null)
                    {
                        page4 = doc.Pages.Add(PdfPageSize.A6);
                    }
                }
                if (pagethreeh == 310 && pagefourh < 310)
                {
                    page4.Canvas.DrawString(nazwa, font2, brush, 0, pagefourh, leftAlignment);
                    page4.Canvas.DrawString(cena, font2, brush, page.Canvas.ClientSize.Width, pagefourh,
                                            rightAlignment);
                    pagefourh += 10;
                }
            }
            if (_recp.ListOfDeletedProducts != null && _recp.ListOfDeletedProducts.Count > 0)
            {
                foreach (var x in _recp.ListOfDeletedProducts)
                {
                    string ilosc = x.Count.ToString();
                    string nazwa = x.Name.Substring(0, x.Name.Length > 45 ? 45 : x.Name.Length) + " Il." + ilosc;
                    string cena  = x.ChoseOptionPrice.ToString();
                    if (pageoneh < 310)
                    {
                        page.Canvas.DrawString(nazwa, font3, brush, 0, pageoneh, leftAlignment);
                        page.Canvas.DrawString(cena, font3, brush, page.Canvas.ClientSize.Width, pageoneh,
                                               rightAlignment);
                        pageoneh += 10;
                    }
                    if (pageoneh == 310)
                    {
                        if (page2 == null)
                        {
                            page2 = doc.Pages.Add(PdfPageSize.A6);
                        }
                    }
                    if (pageoneh == 310 && pagetwoh < 310)
                    {
                        page2.Canvas.DrawString(nazwa, font3, brush, 0, pagetwoh, leftAlignment);
                        page2.Canvas.DrawString(cena, font3, brush, page.Canvas.ClientSize.Width, pagetwoh,
                                                rightAlignment);
                        pagetwoh += 10;
                    }
                    if (pagetwoh == 310)
                    {
                        if (page3 == null)
                        {
                            page3 = doc.Pages.Add(PdfPageSize.A6);
                        }
                    }
                    if (pagetwoh == 310 && pagethreeh < 310)
                    {
                        page3.Canvas.DrawString(nazwa, font3, brush, 0, pagethreeh, leftAlignment);
                        page3.Canvas.DrawString(cena, font3, brush, page.Canvas.ClientSize.Width, pagethreeh,
                                                rightAlignment);
                        pagethreeh += 10;
                    }
                    if (pagethreeh == 310)
                    {
                        if (page4 == null)
                        {
                            page4 = doc.Pages.Add(PdfPageSize.A6);
                        }
                    }
                    if (pagethreeh == 310 && pagefourh < 310)
                    {
                        page4.Canvas.DrawString(nazwa, font3, brush, 0, pagefourh, leftAlignment);
                        page4.Canvas.DrawString(cena, font3, brush, page.Canvas.ClientSize.Width, pagefourh,
                                                rightAlignment);
                        pagefourh += 10;
                    }
                }
            }
            PdfPath path2 = null;
            PdfPen  pen2  = null;

            if (page4 != null)
            {
                path2 = new PdfPath();

                path2.AddLine(new PointF(10, pagefourh + 5),
                              new PointF(page.Canvas.ClientSize.Width - 10, pagefourh + 5));

                pen2 = new PdfPen(System.Drawing.Color.Black, 0.8f);
                page4.Canvas.DrawPath(pen2, path2);

                page4.Canvas.DrawString("PLATNOSC: " + _recp.KindOfPayment, font2, brush, 0, pagefourh + 10,
                                        leftAlignment);
                page4.Canvas.DrawString("SUMA PLN DO ZAPLATY: " + _recp.PriceSum, font2, brush,
                                        page.Canvas.ClientSize.Width, pagefourh + 10, rightAlignment);
            }
            else if (page4 == null && page3 != null)
            {
                path2 = new PdfPath();

                path2.AddLine(new PointF(10, pagethreeh + 5),
                              new PointF(page.Canvas.ClientSize.Width - 10, pagethreeh + 5));

                pen2 = new PdfPen(System.Drawing.Color.Black, 0.8f);
                page3.Canvas.DrawPath(pen2, path2);
                page3.Canvas.DrawString("PLATNOSC: " + _recp.KindOfPayment, font2, brush, 0, pagethreeh + 10,
                                        leftAlignment);
                page3.Canvas.DrawString("SUMA PLN DO ZAPLATY: " + _recp.PriceSum, font2, brush,
                                        page.Canvas.ClientSize.Width, pagethreeh + 10, rightAlignment);
            }
            else if (page3 == null && page2 != null)
            {
                path2 = new PdfPath();

                path2.AddLine(new PointF(10, pagetwoh + 5),
                              new PointF(page.Canvas.ClientSize.Width - 10, pagetwoh + 5));

                pen2 = new PdfPen(System.Drawing.Color.Black, 0.8f);
                page2.Canvas.DrawPath(pen2, path2);
                page2.Canvas.DrawString("PLATNOSC: " + _recp.KindOfPayment, font2, brush, 0, pagetwoh + 10,
                                        leftAlignment);
                page2.Canvas.DrawString("SUMA PLN DO ZAPLATY: " + _recp.PriceSum, font2, brush,
                                        page.Canvas.ClientSize.Width, pagetwoh + 10, rightAlignment);
            }
            else if (page2 == null && page != null)
            {
                path2 = new PdfPath();

                path2.AddLine(new PointF(10, pageoneh + 5),
                              new PointF(page.Canvas.ClientSize.Width - 10, pageoneh + 5));

                pen2 = new PdfPen(System.Drawing.Color.Black, 0.8f);
                page.Canvas.DrawPath(pen2, path2);
                page.Canvas.DrawString("PLATNOSC: " + _recp.KindOfPayment, font2, brush, 0, pageoneh + 10,
                                       leftAlignment);
                page.Canvas.DrawString("SUMA PLN DO ZAPLATY: " + _recp.PriceSum, font2, brush,
                                       page.Canvas.ClientSize.Width, pageoneh + 10, rightAlignment);
            }

            //restor graphics
            page.Canvas.Restore(state);
            //Save doc file.
            String fileName = "Receipe" + _recp.TransactionNumber + ".pdf";

            doc.SaveToFile(fileName);
            doc.Close();

            //Launching the Pdf file.
            System.Diagnostics.Process.Start(fileName);
        }