private void UpdateSymbology(BarcodeModel barcodeModel) { switch (barcodeModel.SymobologyItem) { case "CodaBar": CodabarBarcode codabarBarcode = new CodabarBarcode(); SymbologyItem = codabarBarcode; break; case "Code11": Code11Barcode code11Barcode = new Code11Barcode(); SymbologyItem = code11Barcode; break; case "Code32": Code32Barcode code32Barcode = new Code32Barcode(); SymbologyItem = code32Barcode; break; case "Code39": Code39Barcode code39Barcode = new Code39Barcode(); SymbologyItem = code39Barcode; break; case "Code39Extended": Code39ExtendedBarcode code39ExtendedBarcode = new Code39ExtendedBarcode(); SymbologyItem = code39ExtendedBarcode; break; case "Code93": Code93Barcode code93Barcode = new Code93Barcode(); SymbologyItem = code93Barcode; break; case "Code93Extended": Code93ExtendedBarcode code93ExtendedBarcode = new Code93ExtendedBarcode(); SymbologyItem = code93ExtendedBarcode; break; case "Code128A": Code128ABarcode code128Barcode = new Code128ABarcode(); SymbologyItem = code128Barcode; break; case "Code128B": Code128BBarcode code128BBarcode = new Code128BBarcode(); SymbologyItem = code128BBarcode; break; case "Code128C": Code128CBarcode code128CBarcode = new Code128CBarcode(); SymbologyItem = code128CBarcode; break; case "UpcBarcode": UpcBarcode upcBarcode = new UpcBarcode(); SymbologyItem = upcBarcode; break; case "GS1Code128Barcode": GS1Code128Barcode gS1Code128Barcode = new GS1Code128Barcode(); SymbologyItem = gS1Code128Barcode; break; case "Pdf417Barcode": Pdf417Barcode pdf417Barcode = new Pdf417Barcode(); SymbologyItem = pdf417Barcode; break; } }
public ActionResult Barcode(string InsideBrowser) { //Create a new instance of PdfDocument class. 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, 70)); PdfQRBarcode qrBarcode = new PdfQRBarcode(); // Sets the Input mode to Binary mode qrBarcode.InputMode = InputMode.BinaryMode; // Automatically select the Version qrBarcode.Version = QRCodeVersion.Auto; // Set the Error correction level to high qrBarcode.ErrorCorrectionLevel = PdfErrorCorrectionLevel.High; // Set dimension for each block qrBarcode.XDimension = 2; qrBarcode.Text = "Syncfusion Essential Studio Enterprise edition $995"; // Draw the QR barcode qrBarcode.Draw(page, new PointF(25, 100)); font = new PdfStandardFont(PdfFontFamily.TimesRoman, 9, PdfFontStyle.Regular); g.DrawString("Input Type : Eight Bit Binary", font, brush, new PointF(250, 140)); g.DrawString("Encoded Data : Syncfusion Essential Studio Enterprise edition $995", font, brush, new PointF(250, 160)); g.DrawLine(pen, new PointF(0, 230), new PointF(width, 230)); #endregion #region Datamatrix font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f, PdfFontStyle.Bold); g.DrawString("DataMatrix Barcode", font, brush, new PointF(10, 270)); 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, 310)); font = new PdfStandardFont(PdfFontFamily.TimesRoman, 9, PdfFontStyle.Regular); g.DrawString("Symbol Type : Square", font, brush, new PointF(250, 360)); g.DrawString("Encoded Data : 5575235 Win7 4GB 64bit 7Jun2010", font, brush, new PointF(250, 380)); pen = new PdfPen(brush, 0.5f); g.DrawLine(pen, new PointF(0, 430), new PointF(width, 430)); 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, 470)); g.DrawString("Symbol Type : Rectangle", font, brush, new PointF(250, 490)); g.DrawString("Encoded Data : " + text, font, brush, new PointF(250, 510)); pen = new PdfPen(brush, 0.5f); g.DrawLine(pen, new PointF(0, 570), new PointF(width, 570)); font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f, PdfFontStyle.Bold); g.DrawString("PDF417 Barcode", font, brush, new PointF(10, 620)); Pdf417Barcode pdf417Barcode = new Pdf417Barcode(); pdf417Barcode.Text = "https://www.syncfusion.com/"; pdf417Barcode.ErrorCorrectionLevel = Pdf417ErrorCorrectionLevel.Auto; pdf417Barcode.XDimension = 1f; pdf417Barcode.Size = new SizeF(200, 50); pdf417Barcode.Draw(page, new PointF(25, 670)); font = new PdfStandardFont(PdfFontFamily.TimesRoman, 9, PdfFontStyle.Regular); g.DrawString("Encoded Data : https://www.syncfusion.com/", font, brush, new PointF(250, 680)); #endregion # endregion # region 1D Barcode