private async void BarcodeSample()
        {
            MemoryStream stream = new MemoryStream();

            //Create a new instance of PdfDocument class.
            using (PdfDocument document = new PdfDocument())
            {
                //Add a new page to the document.
                PdfPage page = document.Pages.Add();

                //Create Pdf graphics for the page
                PdfGraphics g = page.Graphics;

                //Create a solid brush
                PdfBrush brush = PdfBrushes.Black;

                #region 2D Barcode

                //Set the font
                PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 15f, PdfFontStyle.Bold);

                PdfPen pen   = new PdfPen(brush, 0.5f);
                float  width = page.GetClientSize().Width;

                float xPos = page.GetClientSize().Width / 2;

                PdfStringFormat format = new PdfStringFormat();
                format.Alignment = PdfTextAlignment.Center;

                // Draw String
                g.DrawString("2D Barcodes", font, brush, new PointF(xPos, 10), format);

                #region QR Barcode
                font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f, PdfFontStyle.Bold);
                g.DrawString("QR Barcode", font, brush, new PointF(10, 90));

                //Create QR barcode
                PdfQRBarcode qrBarcode = new PdfQRBarcode();

                //Set input mode
                qrBarcode.InputMode = InputMode.BinaryMode;

                //Set error correction level
                qrBarcode.ErrorCorrectionLevel = PdfErrorCorrectionLevel.High;

                //Set dimension
                qrBarcode.XDimension = 4;

                //Add data
                qrBarcode.Text = "Syncfusion Essential Studio Enterprise edition $995";

                //Draw barcode on Pdf page
                qrBarcode.Draw(page, new PointF(25, 120));

                font = new PdfStandardFont(PdfFontFamily.TimesRoman, 9, PdfFontStyle.Regular);

                g.DrawString("Input Type :   Eight Bit Binary", font, brush, new PointF(250, 160));
                g.DrawString("Encoded Data : Syncfusion Essential Studio Enterprise edition $995", font, brush, new PointF(250, 180));

                g.DrawLine(pen, new PointF(0, 320), new PointF(width, 320));

                #endregion

                #region Datamatrix
                font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f, PdfFontStyle.Bold);
                g.DrawString("DataMatrix Barcode", font, brush, new PointF(10, 340));

                PdfDataMatrixBarcode dataMatrixBarcode = new PdfDataMatrixBarcode("5575235 Win7 4GB 64bit 7Jun2010");

                // Set dimension for each block
                dataMatrixBarcode.XDimension = 4;

                // Draw the barcode
                dataMatrixBarcode.Draw(page, new PointF(25, 540));

                font = new PdfStandardFont(PdfFontFamily.TimesRoman, 9, PdfFontStyle.Regular);

                g.DrawString("Symbol Type : Square", font, brush, new PointF(250, 590));
                g.DrawString("Encoded Data : 5575235 Win7 4GB 64bit 7Jun2010", font, brush, new PointF(250, 610));

                pen = new PdfPen(brush, 0.5f);
                g.DrawLine(pen, new PointF(0, 700), new PointF(width, 700));

                string text = "TYPE 3523 - ETWS/N FE- SDFHW 06/08";

                dataMatrixBarcode = new PdfDataMatrixBarcode(text);

                // rectangular matrix
                dataMatrixBarcode.Size = PdfDataMatrixSize.Size16x48;

                dataMatrixBarcode.XDimension = 4;

                dataMatrixBarcode.Draw(page, new PointF(25, 400));

                g.DrawString("Symbol Type : Rectangle", font, brush, new PointF(250, 420));
                g.DrawString("Encoded Data : " + text, font, brush, new PointF(250, 440));

                pen = new PdfPen(brush, 0.5f);
                #endregion
                #endregion



                page = document.Pages.Add();
                g    = page.Graphics;

                //Set the font
                font = new PdfStandardFont(PdfFontFamily.Helvetica, 15f, PdfFontStyle.Bold);

                // Draw String
                g.DrawString("1D/Linear Barcodes", font, brush, new PointF(150, 10));

                // Set string format.
                format          = new PdfStringFormat();
                format.WordWrap = PdfWordWrapType.Word;

                #region Code39
                // Drawing Code39 barcode
                PdfCode39Barcode barcode = new PdfCode39Barcode();

                // Setting height of the barcode
                barcode.BarHeight = 45;
                barcode.Text      = "CODE39$";

                //Printing barcode on to the Pdf.
                barcode.Draw(page, new PointF(25, 70));

                font = new PdfStandardFont(PdfFontFamily.TimesRoman, 9, PdfFontStyle.Regular);

                g.DrawString("Type : Code39", font, brush, new PointF(200, 80));
                g.DrawString("Allowed Characters : 0-9, A-Z,a dash(-),a dot(.),$,/,+,%, SPACE", font, brush, new PointF(200, 100));

                g.DrawLine(pen, new PointF(0, 150), new PointF(width, 150));
                #endregion

                #region Code39Extended
                // Drawing Code39Extended barcode
                PdfCode39ExtendedBarcode barcodeExt = new PdfCode39ExtendedBarcode();

                // Setting height of the barcode
                barcodeExt.BarHeight = 45;
                barcodeExt.Text      = "CODE39Ext";

                //Printing barcode on to the Pdf.
                barcodeExt.Draw(page, new PointF(25, 200));

                font = new PdfStandardFont(PdfFontFamily.TimesRoman, 9, PdfFontStyle.Regular);

                g.DrawString("Type : Code39Ext", font, brush, new PointF(200, 210));
                g.DrawString("Allowed Characters : 0-9 A-Z a-z ", font, brush, new PointF(200, 230));

                g.DrawLine(pen, new PointF(0, 270), new PointF(width, 270));
                #endregion

                #region Code11Barcode
                // Drawing Code11  barcode
                PdfCode11Barcode barcode11 = new PdfCode11Barcode();

                // Setting height of the barcode
                barcode11.BarHeight = 45;
                barcode11.Text      = "012345678";
                barcode11.EncodeStartStopSymbols = true;

                //Printing barcode on to the Pdf.
                barcode11.Draw(page, new PointF(25, 300));

                font = new PdfStandardFont(PdfFontFamily.TimesRoman, 9, PdfFontStyle.Regular);

                g.DrawString("Type : Code 11", font, brush, new PointF(200, 310));
                g.DrawString("Allowed Characters : 0-9, a dash(-) ", font, brush, new PointF(200, 330));

                g.DrawLine(pen, new PointF(0, 370), new PointF(width, 370));
                #endregion

                #region Codabar
                // Drawing CodaBarcode
                PdfCodabarBarcode codabar = new PdfCodabarBarcode();

                // Setting height of the barcode
                codabar.BarHeight = 45;
                codabar.Text      = "0123";

                //Printing barcode on to the Pdf.
                codabar.Draw(page, new PointF(25, 400));

                font = new PdfStandardFont(PdfFontFamily.TimesRoman, 9, PdfFontStyle.Regular);

                g.DrawString("Type : Codabar", font, brush, new PointF(200, 410));
                g.DrawString("Allowed Characters : A,B,C,D,0-9,-$,:,/,a dot(.),+ ", font, brush, new PointF(200, 430));

                g.DrawLine(pen, new PointF(0, 470), new PointF(width, 470));
                #endregion

                #region Code32
                PdfCode32Barcode code32 = new PdfCode32Barcode();

                code32.Font = font;

                // Setting height of the barcode
                code32.BarHeight           = 45;
                code32.Text                = "01234567";
                code32.TextDisplayLocation = TextLocation.Bottom;
                code32.EnableCheckDigit    = true;
                code32.ShowCheckDigit      = true;

                //Printing barcode on to the Pdf.
                code32.Draw(page, new PointF(25, 500));

                g.DrawString("Type : Code32", font, brush, new PointF(200, 500));
                g.DrawString("Allowed Characters : 1 2 3 4 5 6 7 8 9 0 ", font, brush, new PointF(200, 520));

                g.DrawLine(pen, new PointF(0, 580), new PointF(width, 580));

                #endregion

                #region Code93
                PdfCode93Barcode code93 = new PdfCode93Barcode();

                // Setting height of the barcode
                code93.BarHeight = 45;
                code93.Text      = "ABC 123456789";

                //Printing barcode on to the Pdf.
                code93.Draw(page, new PointF(25, 600));

                g.DrawString("Type : Code93", font, brush, new PointF(200, 600));
                g.DrawString("Allowed Characters : 1 2 3 4 5 6 7 8 9 0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z - . $ / + % SPACE ", font, brush, new RectangleF(200, 620, 300, 200), format);

                g.DrawLine(pen, new PointF(0, 680), new PointF(width, 680));
                #endregion

                #region Code93Extended
                PdfCode93ExtendedBarcode code93ext = new PdfCode93ExtendedBarcode();

                //Setting height of the barcode
                code93ext.BarHeight = 45;
                code93ext.EncodeStartStopSymbols = true;
                code93ext.Text = "(abc) 123456789";

                //Printing barcode on to the Pdf.
                page = document.Pages.Add();
                code93ext.Draw(page, new PointF(25, 50));

                g = page.Graphics;
                g.DrawString("Type : Code93 Extended", font, brush, new PointF(200, 50));
                g.DrawString("Allowed Characters : All 128 ASCII characters ", font, brush, new PointF(200, 70));

                g.DrawLine(pen, new PointF(0, 120), new PointF(width, 120));
                #endregion

                #region Code128
                PdfCode128ABarcode barcode128A = new PdfCode128ABarcode();

                // Setting height of the barcode
                barcode128A.BarHeight              = 45;
                barcode128A.Text                   = "ABCD 12345";
                barcode128A.EnableCheckDigit       = true;
                barcode128A.EncodeStartStopSymbols = true;
                barcode128A.ShowCheckDigit         = true;

                //Printing barcode on to the Pdf.
                barcode128A.Draw(page, new PointF(25, 135));

                g.DrawString("Type : Code128 A", font, brush, new PointF(200, 135));
                g.DrawString("Allowed Characters : NUL (0x00) SOH (0x01) STX (0x02) ETX (0x03) EOT (0x04) ENQ (0x05) ACK (0x06) BEL (0x07) BS (0x08) HT (0x09) LF (0x0A) VT (0x0B) FF (0x0C) CR (0x0D) SO (0x0E) SI (0x0F) DLE (0x10) DC1 (0x11) DC2 (0x12) DC3 (0x13) DC4 (0x14) NAK (0x15) SYN (0x16) ETB (0x17) CAN (0x18) EM (0x19) SUB (0x1A) ESC (0x1B) FS (0x1C) GS (0x1D) RS (0x1E) US (0x1F) SPACE (0x20) \" ! # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ / ]^ _  ", font, brush, new RectangleF(200, 155, 300, 200), format);

                g.DrawLine(pen, new PointF(0, 250), new PointF(width, 250));

                PdfCode128BBarcode barcode128B = new PdfCode128BBarcode();

                // Setting height of the barcode
                barcode128B.BarHeight              = 45;
                barcode128B.Text                   = "12345 abcd";
                barcode128B.EnableCheckDigit       = true;
                barcode128B.EncodeStartStopSymbols = true;
                barcode128B.ShowCheckDigit         = true;

                //Printing barcode on to the Pdf.
                barcode128B.Draw(page, new PointF(25, 280));

                g.DrawString("Type : Code128 B", font, brush, new PointF(200, 280));
                g.DrawString("Allowed Characters : SPACE (0x20) !  \" # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ / ]^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ DEL (\x7F)  ", font, brush, new RectangleF(200, 300, 300, 200), format);

                g.DrawLine(pen, new PointF(0, 350), new PointF(width, 350));

                PdfCode128CBarcode barcode128C = new PdfCode128CBarcode();

                // Setting height of the barcode
                barcode128C.BarHeight              = 45;
                barcode128C.Text                   = "001122334455";
                barcode128C.EnableCheckDigit       = true;
                barcode128C.EncodeStartStopSymbols = true;
                barcode128C.ShowCheckDigit         = true;

                //Printing barcode on to the Pdf.
                barcode128C.Draw(page, new PointF(25, 370));

                g.DrawString("Type : Code128 C", font, brush, new PointF(200, 370));
                g.DrawString("Allowed Characters : 0 1 2 3 4 5 6 7 8 9 ", font, brush, new PointF(200, 390));

                g.DrawLine(pen, new PointF(0, 440), new PointF(width, 440));

                #endregion

                //Save the PDF document
                document.Save(stream);
            }

            stream.Position = 0;

            if (IsToggled)
            {
                PdfViewerUI pdfViewer = new SampleBrowser.PdfViewerUI();
                pdfViewer.PdfDocumentStream = stream;
                if (Device.Idiom != TargetIdiom.Phone && Device.OS == TargetPlatform.Windows)
                {
                    await PDFViewModel.Navigation.PushModalAsync(new NavigationPage(pdfViewer));
                }
                else
                {
                    await PDFViewModel.Navigation.PushAsync(pdfViewer);
                }
            }
            else
            {
                if (Device.OS == TargetPlatform.WinPhone || Device.OS == TargetPlatform.Windows)
                {
                    Xamarin.Forms.DependencyService.Get <ISaveWindowsPhone>().Save("Barcode.pdf", "application/pdf", stream);
                }
                else
                {
                    Xamarin.Forms.DependencyService.Get <ISave>().Save("Barcode.pdf", "application/pdf", stream);
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //Create a pdf document.
            PdfDocument doc = new PdfDocument();

            //margin
            PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
            PdfMargins       margin   = new PdfMargins();

            margin.Top    = unitCvtr.ConvertUnits(2.54f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
            margin.Bottom = margin.Top;
            margin.Left   = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
            margin.Right  = margin.Left;

            PdfSection section = doc.Sections.Add();

            section.PageSettings.Margins = margin;
            section.PageSettings.Size    = PdfPageSize.A4;

            // Create one page
            PdfPageBase page = section.Pages.Add();
            float       y    = 10;

            PdfBrush               brush1 = PdfBrushes.Black;
            PdfTrueTypeFont        font1  = new PdfTrueTypeFont(new Font("Arial", 12f, FontStyle.Bold), true);
            RectangleF             rctg   = new RectangleF(new PointF(0, 0), page.Canvas.ClientSize);
            PdfLinearGradientBrush brush2
                = new PdfLinearGradientBrush(rctg, Color.Navy, Color.OrangeRed, PdfLinearGradientMode.Vertical);

            //draw Codabar
            PdfTextWidget text = new PdfTextWidget();

            text.Font = font1;
            text.Text = "Codabar:";
            PdfLayoutResult result = text.Draw(page, 0, y);

            page = result.Page;
            y    = result.Bounds.Bottom + 2;

            PdfCodabarBarcode barcode1 = new PdfCodabarBarcode("00:12-3456/7890");

            barcode1.BarcodeToTextGapHeight = 1f;
            barcode1.EnableCheckDigit       = true;
            barcode1.ShowCheckDigit         = true;
            barcode1.TextDisplayLocation    = TextLocation.Bottom;
            barcode1.TextColor = Color.Blue;
            barcode1.Draw(page, new PointF(0, y));
            y = barcode1.Bounds.Bottom + 5;


            //draw Code11Barcode
            text.Text = "Code11:";
            result    = text.Draw(page, 0, y);
            page      = result.Page;
            y         = result.Bounds.Bottom + 2;

            PdfCode11Barcode barcode2 = new PdfCode11Barcode("123-4567890");

            barcode2.BarcodeToTextGapHeight = 1f;
            barcode2.TextDisplayLocation    = TextLocation.Bottom;
            barcode2.TextColor = Color.Blue;
            barcode2.Draw(page, new PointF(0, y));
            y = barcode2.Bounds.Bottom + 5;


            //draw Code128-A
            text.Text = "Code128-A:";
            result    = text.Draw(page, 0, y);
            page      = result.Page;
            y         = result.Bounds.Bottom + 2;

            PdfCode128ABarcode barcode3 = new PdfCode128ABarcode("HELLO 00-123");

            barcode3.BarcodeToTextGapHeight = 1f;
            barcode3.TextDisplayLocation    = TextLocation.Bottom;
            barcode3.TextColor = Color.Blue;
            barcode3.Draw(page, new PointF(0, y));
            y = barcode3.Bounds.Bottom + 5;


            //draw Code128-B
            text.Text = "Code128-B:";
            result    = text.Draw(page, 0, y);
            page      = result.Page;
            y         = result.Bounds.Bottom + 2;

            PdfCode128BBarcode barcode4 = new PdfCode128BBarcode("Hello 00-123");

            barcode4.BarcodeToTextGapHeight = 1f;
            barcode4.TextDisplayLocation    = TextLocation.Bottom;
            barcode4.TextColor = Color.Blue;
            barcode4.Draw(page, new PointF(0, y));
            y = barcode4.Bounds.Bottom + 5;


            //draw Code32
            text.Text = "Code32:";
            result    = text.Draw(page, 0, y);
            page      = result.Page;
            y         = result.Bounds.Bottom + 2;

            PdfCode32Barcode barcode5 = new PdfCode32Barcode("16273849");

            barcode5.BarcodeToTextGapHeight = 1f;
            barcode5.TextDisplayLocation    = TextLocation.Bottom;
            barcode5.TextColor = Color.Blue;
            barcode5.Draw(page, new PointF(0, y));
            y = barcode5.Bounds.Bottom + 5;

            page = section.Pages.Add();
            y    = 10;


            //draw Code39
            text.Text = "Code39:";
            result    = text.Draw(page, 0, y);
            page      = result.Page;
            y         = result.Bounds.Bottom + 2;

            PdfCode39Barcode barcode6 = new PdfCode39Barcode("16-273849");

            barcode6.BarcodeToTextGapHeight = 1f;
            barcode6.TextDisplayLocation    = TextLocation.Bottom;
            barcode6.TextColor = Color.Blue;
            barcode6.Draw(page, new PointF(0, y));
            y = barcode6.Bounds.Bottom + 5;


            //draw Code39-E
            text.Text = "Code39-E:";
            result    = text.Draw(page, 0, y);
            page      = result.Page;
            y         = result.Bounds.Bottom + 2;

            PdfCode39ExtendedBarcode barcode7 = new PdfCode39ExtendedBarcode("16-273849");

            barcode7.BarcodeToTextGapHeight = 1f;
            barcode7.TextDisplayLocation    = TextLocation.Bottom;
            barcode7.TextColor = Color.Blue;
            barcode7.Draw(page, new PointF(0, y));
            y = barcode7.Bounds.Bottom + 5;


            //draw Code93
            text.Text = "Code93:";
            result    = text.Draw(page, 0, y);
            page      = result.Page;
            y         = result.Bounds.Bottom + 2;

            PdfCode93Barcode barcode8 = new PdfCode93Barcode("16-273849");

            barcode8.BarcodeToTextGapHeight = 1f;
            barcode8.TextDisplayLocation    = TextLocation.Bottom;
            barcode8.TextColor        = Color.Blue;
            barcode8.QuietZone.Bottom = 5;
            barcode8.Draw(page, new PointF(0, y));
            y = barcode8.Bounds.Bottom + 5;


            //draw Code93-E
            text.Text = "Code93-E:";
            result    = text.Draw(page, 0, y);
            page      = result.Page;
            y         = result.Bounds.Bottom + 2;

            PdfCode93ExtendedBarcode barcode9 = new PdfCode93ExtendedBarcode("16-273849");

            barcode9.BarcodeToTextGapHeight = 1f;
            barcode9.TextDisplayLocation    = TextLocation.Bottom;
            barcode9.TextColor = Color.Blue;
            barcode9.Draw(page, new PointF(0, y));
            y = barcode9.Bounds.Bottom + 5;


            //Save pdf file.
            doc.SaveToFile("Barcode.pdf");
            doc.Close();

            //Launching the Pdf file.
            PDFDocumentViewer("Barcode.pdf");
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Create a pdf document.
            PdfDocument doc = new PdfDocument();

            //margin
            PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
            PdfMargins margin = new PdfMargins();
            margin.Top = unitCvtr.ConvertUnits(2.54f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
            margin.Bottom = margin.Top;
            margin.Left = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
            margin.Right = margin.Left;

            PdfSection section = doc.Sections.Add();
            section.PageSettings.Margins = margin;
            section.PageSettings.Size = PdfPageSize.A4;

            // Create one page
            PdfPageBase page = section.Pages.Add();
            float y = 10;

            PdfBrush brush1 = PdfBrushes.Black;
            PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font("Arial", 12f, FontStyle.Bold), true);
            RectangleF rctg = new RectangleF(new PointF(0, 0), page.Canvas.ClientSize);
            PdfLinearGradientBrush brush2
                = new PdfLinearGradientBrush(rctg, Color.Navy, Color.OrangeRed, PdfLinearGradientMode.Vertical);

            //draw Codabar
            PdfTextWidget text = new PdfTextWidget();
            text.Font = font1;
            text.Text = "Codabar:";
            PdfLayoutResult result = text.Draw(page, 0, y);
            page = result.Page;
            y = result.Bounds.Bottom + 2;

            PdfCodabarBarcode barcode1 = new PdfCodabarBarcode("00:12-3456/7890");
            barcode1.BarcodeToTextGapHeight = 1f;
            barcode1.EnableCheckDigit = true;
            barcode1.ShowCheckDigit = true;
            barcode1.TextDisplayLocation = TextLocation.Bottom;
            barcode1.TextColor = Color.Blue;
            barcode1.Draw(page, new PointF(0, y));
            y = barcode1.Bounds.Bottom + 5;


            //draw Code11Barcode
            text.Text = "Code11:";
            result = text.Draw(page, 0, y);
            page = result.Page;
            y = result.Bounds.Bottom + 2;

            PdfCode11Barcode barcode2 = new PdfCode11Barcode("123-4567890");
            barcode2.BarcodeToTextGapHeight = 1f;
            barcode2.TextDisplayLocation = TextLocation.Bottom;
            barcode2.TextColor = Color.Blue;
            barcode2.Draw(page, new PointF(0, y));
            y = barcode2.Bounds.Bottom + 5;


            //draw Code128-A
            text.Text = "Code128-A:";
            result = text.Draw(page, 0, y);
            page = result.Page;
            y = result.Bounds.Bottom + 2;

            PdfCode128ABarcode barcode3 = new PdfCode128ABarcode("HELLO 00-123");
            barcode3.BarcodeToTextGapHeight = 1f;
            barcode3.TextDisplayLocation = TextLocation.Bottom;
            barcode3.TextColor = Color.Blue;
            barcode3.Draw(page, new PointF(0, y));
            y = barcode3.Bounds.Bottom + 5;


            //draw Code128-B
            text.Text = "Code128-B:";
            result = text.Draw(page, 0, y);
            page = result.Page;
            y = result.Bounds.Bottom + 2;

            PdfCode128BBarcode barcode4 = new PdfCode128BBarcode("Hello 00-123");
            barcode4.BarcodeToTextGapHeight = 1f;
            barcode4.TextDisplayLocation = TextLocation.Bottom;
            barcode4.TextColor = Color.Blue;
            barcode4.Draw(page, new PointF(0, y));
            y = barcode4.Bounds.Bottom + 5;


            //draw Code32
            text.Text = "Code32:";
            result = text.Draw(page, 0, y);
            page = result.Page;
            y = result.Bounds.Bottom + 2;

            PdfCode32Barcode barcode5 = new PdfCode32Barcode("16273849");
            barcode5.BarcodeToTextGapHeight = 1f;
            barcode5.TextDisplayLocation = TextLocation.Bottom;
            barcode5.TextColor = Color.Blue;
            barcode5.Draw(page, new PointF(0, y));
            y = barcode5.Bounds.Bottom + 5;

            page = section.Pages.Add();
            y = 10;


            //draw Code39
            text.Text = "Code39:";
            result = text.Draw(page, 0, y);
            page = result.Page;
            y = result.Bounds.Bottom + 2;

            PdfCode39Barcode barcode6 = new PdfCode39Barcode("16-273849");
            barcode6.BarcodeToTextGapHeight = 1f;
            barcode6.TextDisplayLocation = TextLocation.Bottom;
            barcode6.TextColor = Color.Blue;
            barcode6.Draw(page, new PointF(0, y));
            y = barcode6.Bounds.Bottom + 5;


            //draw Code39-E
            text.Text = "Code39-E:";
            result = text.Draw(page, 0, y);
            page = result.Page;
            y = result.Bounds.Bottom + 2;

            PdfCode39ExtendedBarcode barcode7 = new PdfCode39ExtendedBarcode("16-273849");
            barcode7.BarcodeToTextGapHeight = 1f;
            barcode7.TextDisplayLocation = TextLocation.Bottom;
            barcode7.TextColor = Color.Blue;
            barcode7.Draw(page, new PointF(0, y));
            y = barcode7.Bounds.Bottom + 5;


            //draw Code93
            text.Text = "Code93:";
            result = text.Draw(page, 0, y);
            page = result.Page;
            y = result.Bounds.Bottom + 2;

            PdfCode93Barcode barcode8 = new PdfCode93Barcode("16-273849");
            barcode8.BarcodeToTextGapHeight = 1f;
            barcode8.TextDisplayLocation = TextLocation.Bottom;
            barcode8.TextColor = Color.Blue;
            barcode8.QuietZone.Bottom = 5;
            barcode8.Draw(page, new PointF(0, y));
            y = barcode8.Bounds.Bottom + 5;


            //draw Code93-E
            text.Text = "Code93-E:";
            result = text.Draw(page, 0, y);
            page = result.Page;
            y = result.Bounds.Bottom + 2;

            PdfCode93ExtendedBarcode barcode9 = new PdfCode93ExtendedBarcode("16-273849");
            barcode9.BarcodeToTextGapHeight = 1f;
            barcode9.TextDisplayLocation = TextLocation.Bottom;
            barcode9.TextColor = Color.Blue;
            barcode9.Draw(page, new PointF(0, y));
            y = barcode9.Bounds.Bottom + 5;


            //Save pdf file.
            doc.SaveToFile("Barcode.pdf");
            doc.Close();

            //Launching the Pdf file.
            PDFDocumentViewer("Barcode.pdf");
        }