예제 #1
0
        public static void AddAztecToPDF()
        {
            // Create a new PDF document.
            PdfDocument document = new PdfDocument();

            // Create a page.
            PdfPage page = document.AddPage();

            // Get graphics object from pdf page
            XGraphics g = XGraphics.FromPdfPage(page);

            // Create a pdf barcode object
            PdfBarcode barcode = new PdfBarcode();

            // Set the barcode type to aztec symbol
            barcode.BarType = BarCodeType.Aztec;

            // Input the barcode data content
            barcode.Data = "xspdf123456789";

            // Change foreground and background color of barcode
            barcode.BarcodeColor    = XColors.Black;
            barcode.BackgroundColor = XColors.White;

            // Set aztec layer mode
            barcode.AztecLayer = LayerMode.Default;

            // Set aztec code error correction
            barcode.AztecErrorCorrection = 33;

            // Set the barcode Position and location
            barcode.Location = new XPoint(100, 100);

            // Set the barcode width and height
            barcode.Size = new XSize(200, 200);

            barcode.DrawBarcode(g);

            // Save and show the document
            document.Save("Barcode.pdf");
            Process.Start("Barcode.pdf");
        }
예제 #2
0
        public static void AddEAN13ToPDF()
        {
            // Create a new PDF document.
            PdfDocument document = new PdfDocument();

            // Create a page.
            PdfPage page = document.AddPage();

            // Get graphics object from pdf page
            XGraphics g = XGraphics.FromPdfPage(page);

            // Create a pdf barcode object
            PdfBarcode barcode = new PdfBarcode();

            // Set the barcode type to ean-13 symbol
            barcode.BarType = BarCodeType.EAN13;

            // Input the barcode data content, only need 12 digital data
            // our library will add the check sum automatically
            barcode.Data = "123456789012";

            // Change foreground and background color of barcode
            barcode.BarcodeColor    = XColors.Black;
            barcode.BackgroundColor = XColors.White;

            // Set 1d barcode human-readable text to display
            barcode.ShowText = true;

            // Set the barcode Position and location
            barcode.Location = new XPoint(100, 100);

            // Set the barcode width and height
            barcode.Size = new XSize(200, 50);

            barcode.DrawBarcode(g);

            // Save and show the document
            document.Save("Barcode.pdf");
            Process.Start("Barcode.pdf");
        }
예제 #3
0
        public static void AddCode39ToPDF()
        {
            // Create a new PDF document.
            PdfDocument document = new PdfDocument();

            // Create a page.
            PdfPage page = document.AddPage();

            // Get graphics object from pdf page
            XGraphics g = XGraphics.FromPdfPage(page);

            // Create a pdf barcode object
            PdfBarcode barcode = new PdfBarcode();

            // Set the barcode type to code 3 of 9 symbol
            barcode.BarType = BarCodeType.Code39;

            // Set barcode date to encode
            barcode.Data = "123456789";

            // Change foreground and background color of barcode
            barcode.BarcodeColor    = XColors.Black;
            barcode.BackgroundColor = XColors.White;

            // Set 1d barcode human-readable text to display
            barcode.ShowText = true;

            // Set the barcode Position and location
            barcode.Location = new XPoint(100, 100);

            // Set the barcode width and height
            barcode.Size = new XSize(200, 50);

            barcode.DrawBarcode(g);

            // Save and show the document
            document.Save("Barcode.pdf");
            Process.Start("Barcode.pdf");
        }
예제 #4
0
        public static void AddPDF417ToPDF()
        {
            // Create a new PDF document.
            PdfDocument document = new PdfDocument();

            // Create a page.
            PdfPage page = document.AddPage();

            // Get graphics object from pdf page
            XGraphics g = XGraphics.FromPdfPage(page);

            // Create a pdf barcode object
            PdfBarcode barcode = new PdfBarcode();

            // Set the barcode type to pdf417 symbol
            barcode.BarType = BarCodeType.PDF417;

            // Set barcode date to encode
            barcode.Data = "xspdf123456789";

            // Change foreground and background color of barcode
            barcode.BarcodeColor    = XColors.Black;
            barcode.BackgroundColor = XColors.White;

            // Set pdf417 compact/truncated
            barcode.PDF417Compact = false;

            // Set the barcode Position and location
            barcode.Location = new XPoint(70, 50);

            // Set the barcode width and height
            barcode.Size = new XSize(200, 100);

            barcode.DrawBarcode(g);

            // Save and show the document
            document.Save("Barcode.pdf");
            Process.Start("Barcode.pdf");
        }
예제 #5
0
        public static void AddDataMatrixToPDF()
        {
            // Create a new PDF document.
            PdfDocument document = new PdfDocument();

            // Create a page.
            PdfPage page = document.AddPage();

            // Get graphics object from pdf page
            XGraphics g = XGraphics.FromPdfPage(page);

            // Create a pdf barcode object
            PdfBarcode barcode = new PdfBarcode();

            // Set the barcode type to data matrix symbol
            barcode.BarType = BarCodeType.DataMatrix;

            // Input the barcode data content
            barcode.Data = "xspdf123456789";

            // Change foreground and background color of barcode
            barcode.BarcodeColor    = XColors.Black;
            barcode.BackgroundColor = XColors.White;

            //Set datamatrix shape mode: rectangle or square
            barcode.DataMatrixShape = SymbolShapeMode.Square;

            // Set the barcode Position and location
            barcode.Location = new XPoint(100, 100);

            // Set the barcode width and height
            barcode.Size = new XSize(200, 200);

            barcode.DrawBarcode(g);

            // Save and show the document
            document.Save("Barcode.pdf");
            Process.Start("Barcode.pdf");
        }
예제 #6
0
        public static void AddCode128ToPDF()
        {
            // Create a new PDF document.
            PdfDocument document = new PdfDocument();

            // Create a page.
            PdfPage page = document.AddPage();

            // Get graphics object from pdf page
            XGraphics g = XGraphics.FromPdfPage(page);

            // Create a pdf barcode object
            PdfBarcode barcode = new PdfBarcode();

            // Set the barcode type to code 128 symbol
            barcode.BarType = BarCodeType.Code128;

            // Input the barcode data content
            barcode.Data = "123456789";

            // Change foreground and background color of barcode
            barcode.BarcodeColor    = XColors.Black;
            barcode.BackgroundColor = XColors.White;

            // Set the barcode Position and location
            barcode.Location = new XPoint(100, 100);

            // Set the barcode width and height
            barcode.Size = new XSize(200, 100);

            // Only 1D barcodes support show the data text under the barcode graphics
            barcode.ShowText = true;

            barcode.DrawBarcode(g);

            // Save and show the document
            document.Save("Barcode.pdf");
            Process.Start("Barcode.pdf");
        }