Image GetBarcodeImage(string selectedBarcode, string barCodeLabel, int width, int height) { width = width * 100; height = height * 20; var label = Regex.Replace(Regex.Replace(barCodeLabel, _barcodeMatchingPattern, ""), @"\D", "0"); if (!_barcodeTypes.ContainsKey(selectedBarcode)) { BarcodeDatamatrix barcodeDatamatrix = new BarcodeDatamatrix { Height = 24, Width = 24, Options = BarcodeDatamatrix.DM_AUTO, ForceSquareSize = true }; barcodeDatamatrix.Generate(label); var image = barcodeDatamatrix.CreateDrawingImage(Color.Black, Color.White); return(Resize(image, 48, 48, false)); } var barcodeType = _barcodeTypes[selectedBarcode]; if (string.IsNullOrEmpty(label)) { label = "0"; } if (barcodeType == BarcodeLib.TYPE.EAN13) { _barcode.IncludeLabel = true; label = label.Substring(0, Math.Min(13, label.Length)).PadLeft(13, '0'); } if (barcodeType == BarcodeLib.TYPE.EAN8) { _barcode.IncludeLabel = true; label = label.Substring(0, Math.Min(8, label.Length)).PadLeft(8, '0'); } if (barcodeType == BarcodeLib.TYPE.Interleaved2of5) { if (label.Length % 2 != 0) { label = "0".Insert(1, label); } } return(_barcode.Encode(barcodeType, label, Color.Black, Color.White, width, height)); }
private Image GetImage(string text, CodeType codeType, PdfContentByte pcb) { switch (codeType) { case CodeType.Code128: Barcode128 barcode128 = new Barcode128 { AltText = text, Code = text }; return(barcode128.CreateImageWithBarcode(pcb, iTextSharp.text.Color.BLACK, iTextSharp.text.Color.BLACK)); case CodeType.Code39: Barcode39 barcode39 = new Barcode39 { Code = text, AltText = text }; return(barcode39.CreateImageWithBarcode(pcb, iTextSharp.text.Color.BLACK, iTextSharp.text.Color.BLACK)); case CodeType.Codabar: BarcodeCodabar barcodeCodabar = new BarcodeCodabar { Code = text, AltText = text }; return(barcodeCodabar.CreateImageWithBarcode(pcb, iTextSharp.text.Color.BLACK, iTextSharp.text.Color.BLACK)); case CodeType.Datamatrix: BarcodeDatamatrix barcodeDatamatrix = new BarcodeDatamatrix(); barcodeDatamatrix.Generate(text); return(barcodeDatamatrix.CreateImage()); case CodeType.EAN: BarcodeEAN barcodeEAN = new BarcodeEAN { CodeType = Barcode.EAN13, Code = text, AltText = text }; return(barcodeEAN.CreateImageWithBarcode(pcb, iTextSharp.text.Color.BLACK, iTextSharp.text.Color.BLACK)); case CodeType.Inter25: BarcodeInter25 barcodeInter25 = new BarcodeInter25 { AltText = text, Code = text, GenerateChecksum = true }; return(barcodeInter25.CreateImageWithBarcode(pcb, iTextSharp.text.Color.BLACK, iTextSharp.text.Color.BLACK)); case CodeType.PDF417: BarcodePDF417 barcodePDF417 = new BarcodePDF417(); barcodePDF417.SetText(text); return(barcodePDF417.GetImage()); case CodeType.Postnet: BarcodePostnet barcodePostnet = new BarcodePostnet { AltText = text, Code = text }; return(barcodePostnet.CreateImageWithBarcode(pcb, iTextSharp.text.Color.BLACK, iTextSharp.text.Color.BLACK)); } return(null); }
public void BarcodeTest01() { String filename = "barcodeDataMatrix01.pdf"; String code = "AAAAAAAAAA;BBBBAAAA3;00028;BBBAA05;AAAA;AAAAAA;1234567;AQWXSZ;JEAN;;;;7894561;AQWXSZ;GEO;;;;1;1;1;1;0;0;1;0;1;0;0;0;1;0;1;0;0;0;0;0;0;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1"; Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(outFolder + filename, FileMode.Create)); document.Open(); document.Add(new Paragraph("Datamatrix test 01")); PdfContentByte cb = writer.DirectContent; cb.ConcatCTM(AffineTransform.GetTranslateInstance(PageSize.A4.Width / 2 - 100, PageSize.A4.Height / 2 - 100)); BarcodeDatamatrix barcode = new BarcodeDatamatrix(); barcode.Generate(code); barcode.PlaceBarcode(cb, BaseColor.GREEN, 5, 5); document.Close(); CompareDocuments(filename); }
public void BarcodeTest02() { String filename = "barcodeDataMatrix02.pdf"; String code = "дима"; String encoding = "UTF-8"; Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(outFolder + filename, FileMode.Create)); document.Open(); document.Add(new Paragraph("Datamatrix test 02")); PdfContentByte cb = writer.DirectContent; cb.ConcatCTM(AffineTransform.GetTranslateInstance(PageSize.A4.Width / 2 - 100, PageSize.A4.Height / 2 - 100)); BarcodeDatamatrix barcode = new BarcodeDatamatrix(); barcode.Generate(code, encoding); barcode.PlaceBarcode(cb, BaseColor.GREEN, 5, 5); document.Close(); CompareDocuments(filename); }
public void BarcodeTest04() { String filename = "barcodeDataMatrix04.pdf"; String code = "01AbcdefgAbcdefg123451231231234"; Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(outFolder + filename, FileMode.Create)); document.Open(); document.Add(new Paragraph("Datamatrix test 04")); PdfContentByte cb = writer.DirectContent; cb.ConcatCTM(AffineTransform.GetTranslateInstance(PageSize.A4.Width / 2 - 100, PageSize.A4.Height / 2 - 100)); BarcodeDatamatrix barcode = new BarcodeDatamatrix(); barcode.Width = 36; barcode.Height = 12; barcode.Generate(code); barcode.PlaceBarcode(cb, BaseColor.BLACK, 5, 5); document.Close(); CompareDocuments(filename); }
public async Task <ActionResult> ArtKFC(int id, string prov) { MemoryStream ms = new MemoryStream(); Document document = new Document(PageSize.LETTER, 25f, 25f, 60f, 50f); PdfWriter pw = PdfWriter.GetInstance(document, ms); string pathImage = Server.MapPath("~/Content/images/KFC-logo.png"); string pathImageMW = Server.MapPath("~/Content/images/KFC-logo.png"); pw.PageEvent = new HeaderFooter(pathImage); //pw.PageEvent = new HeaderFooter(pathImage, pathImageMW); document.Open(); string heroFont = Server.MapPath("~/Content/Fonts/Hero.otf"); BaseFont font = BaseFont.CreateFont(heroFont, BaseFont.CP1250, BaseFont.EMBEDDED); Font fontBlack = new Font(font, 10, 0, BaseColor.BLACK); Font fontRed = new Font(font, 10, 0, BaseColor.RED); Font fontRed2 = new Font(font, 14, 1, BaseColor.RED); PdfPTable tabla = new PdfPTable(7); tabla.WidthPercentage = 100f; var proveedor = await db.Proveedors.Where(x => x.Nombre == prov).FirstOrDefaultAsync(); var provId = proveedor.ProveedorId; var materialesProv = await db.Database.SqlQuery <CodigosMaterialesTotal>("spGetMaterialesCodigosCampañaXProveedor @CampañaId, @ProveedorId", new SqlParameter("@CampañaId", id), new SqlParameter("@ProveedorId", provId)).ToListAsync(); if (materialesProv.Count == 0) { var mensaje = "! NO SE HAN GENERADO CÓDIGOS !"; PdfPCell pCell = new PdfPCell(); pCell = new PdfPCell(new Paragraph(mensaje.ToUpper(), fontRed2)); pCell.VerticalAlignment = Element.ALIGN_MIDDLE; pCell.HorizontalAlignment = Element.ALIGN_CENTER; pCell.Colspan = 7; pCell.Border = 0; tabla.AddCell(pCell); } else { var familias = materialesProv.GroupBy(x => x.Familia).ToList(); //var familias = db.Database.SqlQuery<CodigosMaterialesTotal>("spGetMaterialesCodigosCampañaXProveedor @CampañaId, @ProveedorId", //new SqlParameter("@CampañaId", id), //new SqlParameter("@ProveedorId", provId)).GroupBy(x => x.Familia).ToList(); foreach (var familia in familias) { var materialesFam = materialesProv.Where(x => x.Familia == familia.Key).ToList(); PdfPCell pCell = new PdfPCell(); Chunk linea = new Chunk(new LineSeparator(2f, 100f, BaseColor.BLACK, Element.ALIGN_CENTER, 0f)); if (materialesFam.Count != 0) { pCell = new PdfPCell(new Paragraph(familia.Key.ToUpper(), fontRed2)); pCell.VerticalAlignment = Element.ALIGN_MIDDLE; pCell.HorizontalAlignment = Element.ALIGN_CENTER; pCell.Colspan = 7; pCell.Border = 0; tabla.AddCell(pCell); pCell = new PdfPCell(new Paragraph(linea)); pCell.VerticalAlignment = Element.ALIGN_MIDDLE; pCell.Colspan = 7; pCell.Border = 0; tabla.AddCell(pCell); } foreach (var codigo in materialesFam) { BarcodeDatamatrix datamatrix = new BarcodeDatamatrix(); //datamatrix.Generate(codigo.Codigo.ToString() + " / " + codigo.ArticuloKFC); datamatrix.Generate(codigo.Codigo.ToString()); Image image = datamatrix.CreateImage(); image.ScaleAbsolute(40f, 40f); image.Border = 0; //document.Add(image); pCell = new PdfPCell(image, false); pCell.HorizontalAlignment = Element.ALIGN_CENTER; pCell.VerticalAlignment = Element.ALIGN_MIDDLE; pCell.Border = 0; pCell.PaddingTop = 5f; tabla.AddCell(pCell); pCell = new PdfPCell(new Paragraph(codigo.Codigo.ToString(), fontBlack)); pCell.HorizontalAlignment = Element.ALIGN_LEFT; pCell.VerticalAlignment = Element.ALIGN_MIDDLE; pCell.Border = 0; tabla.AddCell(pCell); pCell = new PdfPCell(new Paragraph(codigo.ArticuloKFC.ToUpper(), fontRed)); pCell.VerticalAlignment = Element.ALIGN_MIDDLE; pCell.Colspan = 5; pCell.Border = 0; tabla.AddCell(pCell); linea = new Chunk(new LineSeparator(2f, 100f, BaseColor.BLACK, Element.ALIGN_CENTER, 0f)); pCell = new PdfPCell(new Paragraph(linea)); pCell.VerticalAlignment = Element.ALIGN_MIDDLE; pCell.Colspan = 7; pCell.Border = 0; tabla.AddCell(pCell); //document.Add(linea); } } } document.Add(tabla); document.Close(); byte[] bytesStream = ms.ToArray(); ms = new MemoryStream(); ms.Write(bytesStream, 0, bytesStream.Length); ms.Position = 0; return(new FileStreamResult(ms, "application/pdf")); }
// =========================================================================== public void Write(Stream stream) { // step 1 using (Document document = new Document(new Rectangle(340, 842))) { // step 2 PdfWriter writer = PdfWriter.GetInstance(document, stream); // step 3 document.Open(); // step 4 PdfContentByte cb = writer.DirectContent; // EAN 13 document.Add(new Paragraph("Barcode EAN.UCC-13")); BarcodeEAN codeEAN = new BarcodeEAN(); codeEAN.Code = "4512345678906"; document.Add(new Paragraph("default:")); document.Add(codeEAN.CreateImageWithBarcode(cb, null, null)); codeEAN.GuardBars = false; document.Add(new Paragraph("without guard bars:")); document.Add(codeEAN.CreateImageWithBarcode(cb, null, null)); codeEAN.Baseline = -1f; codeEAN.GuardBars = true; document.Add(new Paragraph("text above:")); document.Add(codeEAN.CreateImageWithBarcode(cb, null, null)); codeEAN.Baseline = codeEAN.Size; // UPC A document.Add(new Paragraph("Barcode UCC-12 (UPC-A)")); codeEAN.CodeType = Barcode.UPCA; codeEAN.Code = "785342304749"; document.Add(codeEAN.CreateImageWithBarcode(cb, null, null)); // EAN 8 document.Add(new Paragraph("Barcode EAN.UCC-8")); codeEAN.CodeType = Barcode.EAN8; codeEAN.BarHeight = codeEAN.Size * 1.5f; codeEAN.Code = "34569870"; document.Add(codeEAN.CreateImageWithBarcode(cb, null, null)); // UPC E document.Add(new Paragraph("Barcode UPC-E")); codeEAN.CodeType = Barcode.UPCE; codeEAN.Code = "03456781"; document.Add(codeEAN.CreateImageWithBarcode(cb, null, null)); codeEAN.BarHeight = codeEAN.Size * 3f; // EANSUPP document.Add(new Paragraph("Bookland")); document.Add(new Paragraph("ISBN 0-321-30474-8")); codeEAN.CodeType = Barcode.EAN13; codeEAN.Code = "9781935182610"; BarcodeEAN codeSUPP = new BarcodeEAN(); codeSUPP.CodeType = Barcode.SUPP5; codeSUPP.Code = "55999"; codeSUPP.Baseline = -2; BarcodeEANSUPP eanSupp = new BarcodeEANSUPP(codeEAN, codeSUPP); document.Add(eanSupp.CreateImageWithBarcode(cb, null, BaseColor.BLUE)); // CODE 128 document.Add(new Paragraph("Barcode 128")); Barcode128 code128 = new Barcode128(); code128.Code = "0123456789 hello"; document.Add(code128.CreateImageWithBarcode(cb, null, null)); code128.Code = "0123456789\uffffMy Raw Barcode (0 - 9)"; code128.CodeType = Barcode.CODE128_RAW; document.Add(code128.CreateImageWithBarcode(cb, null, null)); // Data for the barcode : String code402 = "24132399420058289"; String code90 = "3700000050"; String code421 = "422356"; StringBuilder data = new StringBuilder(code402); data.Append(Barcode128.FNC1); data.Append(code90); data.Append(Barcode128.FNC1); data.Append(code421); Barcode128 shipBarCode = new Barcode128(); shipBarCode.X = 0.75f; shipBarCode.N = 1.5f; shipBarCode.Size = 10f; shipBarCode.TextAlignment = Element.ALIGN_CENTER; shipBarCode.Baseline = 10f; shipBarCode.BarHeight = 50f; shipBarCode.Code = data.ToString(); document.Add(shipBarCode.CreateImageWithBarcode( cb, BaseColor.BLACK, BaseColor.BLUE )); // it is composed of 3 blocks whith AI 01, 3101 and 10 Barcode128 uccEan128 = new Barcode128(); uccEan128.CodeType = Barcode.CODE128_UCC; uccEan128.Code = "(01)00000090311314(10)ABC123(15)060916"; document.Add(uccEan128.CreateImageWithBarcode( cb, BaseColor.BLUE, BaseColor.BLACK )); uccEan128.Code = "0191234567890121310100035510ABC123"; document.Add(uccEan128.CreateImageWithBarcode( cb, BaseColor.BLUE, BaseColor.RED )); uccEan128.Code = "(01)28880123456788"; document.Add(uccEan128.CreateImageWithBarcode( cb, BaseColor.BLUE, BaseColor.BLACK )); // INTER25 document.Add(new Paragraph("Barcode Interleaved 2 of 5")); BarcodeInter25 code25 = new BarcodeInter25(); code25.GenerateChecksum = true; code25.Code = "41-1200076041-001"; document.Add(code25.CreateImageWithBarcode(cb, null, null)); code25.Code = "411200076041001"; document.Add(code25.CreateImageWithBarcode(cb, null, null)); code25.Code = "0611012345678"; code25.ChecksumText = true; document.Add(code25.CreateImageWithBarcode(cb, null, null)); // POSTNET document.Add(new Paragraph("Barcode Postnet")); BarcodePostnet codePost = new BarcodePostnet(); document.Add(new Paragraph("ZIP")); codePost.Code = "01234"; document.Add(codePost.CreateImageWithBarcode(cb, null, null)); document.Add(new Paragraph("ZIP+4")); codePost.Code = "012345678"; document.Add(codePost.CreateImageWithBarcode(cb, null, null)); document.Add(new Paragraph("ZIP+4 and dp")); codePost.Code = "01234567890"; document.Add(codePost.CreateImageWithBarcode(cb, null, null)); document.Add(new Paragraph("Barcode Planet")); BarcodePostnet codePlanet = new BarcodePostnet(); codePlanet.Code = "01234567890"; codePlanet.CodeType = Barcode.PLANET; document.Add(codePlanet.CreateImageWithBarcode(cb, null, null)); // CODE 39 document.Add(new Paragraph("Barcode 3 of 9")); Barcode39 code39 = new Barcode39(); code39.Code = "ITEXT IN ACTION"; document.Add(code39.CreateImageWithBarcode(cb, null, null)); document.Add(new Paragraph("Barcode 3 of 9 extended")); Barcode39 code39ext = new Barcode39(); code39ext.Code = "iText in Action"; code39ext.StartStopText = false; code39ext.Extended = true; document.Add(code39ext.CreateImageWithBarcode(cb, null, null)); // CODABAR document.Add(new Paragraph("Codabar")); BarcodeCodabar codabar = new BarcodeCodabar(); codabar.Code = "A123A"; codabar.StartStopText = true; document.Add(codabar.CreateImageWithBarcode(cb, null, null)); // PDF417 document.Add(new Paragraph("Barcode PDF417")); BarcodePDF417 pdf417 = new BarcodePDF417(); String text = "Call me Ishmael. Some years ago--never mind how long " + "precisely --having little or no money in my purse, and nothing " + "particular to interest me on shore, I thought I would sail about " + "a little and see the watery part of the world." ; pdf417.SetText(text); Image img = pdf417.GetImage(); img.ScalePercent(50, 50 * pdf417.YHeight); document.Add(img); document.Add(new Paragraph("Barcode Datamatrix")); BarcodeDatamatrix datamatrix = new BarcodeDatamatrix(); datamatrix.Generate(text); img = datamatrix.CreateImage(); document.Add(img); document.Add(new Paragraph("Barcode QRCode")); BarcodeQRCode qrcode = new BarcodeQRCode( "Moby Dick by Herman Melville", 1, 1, null ); img = qrcode.GetImage(); document.Add(img); } }
public void Verify_Barcodes_CanBeCreated() { var pdfFilePath = TestUtils.GetOutputFileName(); var stream = new FileStream(pdfFilePath, FileMode.Create); // step 1 var document = new Document(new Rectangle(340, 842)); // step 2 PdfWriter writer = PdfWriter.GetInstance(document, stream); // step 3 document.AddAuthor(TestUtils.Author); document.Open(); // step 4 PdfContentByte cb = writer.DirectContent; // EAN 13 document.Add(new Paragraph("Barcode EAN.UCC-13")); BarcodeEan codeEan = new BarcodeEan { Code = "4512345678906" }; document.Add(new Paragraph("default:")); document.Add(codeEan.CreateImageWithBarcode(cb, null, null)); codeEan.GuardBars = false; document.Add(new Paragraph("without guard bars:")); document.Add(codeEan.CreateImageWithBarcode(cb, null, null)); codeEan.Baseline = -1f; codeEan.GuardBars = true; document.Add(new Paragraph("text above:")); document.Add(codeEan.CreateImageWithBarcode(cb, null, null)); codeEan.Baseline = codeEan.Size; // UPC A document.Add(new Paragraph("Barcode UCC-12 (UPC-A)")); codeEan.CodeType = Barcode.UPCA; codeEan.Code = "785342304749"; document.Add(codeEan.CreateImageWithBarcode(cb, null, null)); // EAN 8 document.Add(new Paragraph("Barcode EAN.UCC-8")); codeEan.CodeType = Barcode.EAN8; codeEan.BarHeight = codeEan.Size * 1.5f; codeEan.Code = "34569870"; document.Add(codeEan.CreateImageWithBarcode(cb, null, null)); // UPC E document.Add(new Paragraph("Barcode UPC-E")); codeEan.CodeType = Barcode.UPCE; codeEan.Code = "03456781"; document.Add(codeEan.CreateImageWithBarcode(cb, null, null)); codeEan.BarHeight = codeEan.Size * 3f; // EANSUPP document.Add(new Paragraph("Bookland")); document.Add(new Paragraph("ISBN 0-321-30474-8")); codeEan.CodeType = Barcode.EAN13; codeEan.Code = "9781935182610"; BarcodeEan codeSupp = new BarcodeEan { CodeType = Barcode.SUPP5, Code = "55999", Baseline = -2 }; BarcodeEansupp eanSupp = new BarcodeEansupp(codeEan, codeSupp); document.Add(eanSupp.CreateImageWithBarcode(cb, null, BaseColor.Blue)); // CODE 128 document.Add(new Paragraph("Barcode 128")); Barcode128 code128 = new Barcode128 { Code = "0123456789 hello" }; document.Add(code128.CreateImageWithBarcode(cb, null, null)); code128.Code = "0123456789\uffffMy Raw Barcode (0 - 9)"; code128.CodeType = Barcode.CODE128_RAW; document.Add(code128.CreateImageWithBarcode(cb, null, null)); // Data for the barcode : string code402 = "24132399420058289"; string code90 = "3700000050"; string code421 = "422356"; StringBuilder data = new StringBuilder(code402); data.Append(Barcode128.FNC1); data.Append(code90); data.Append(Barcode128.FNC1); data.Append(code421); Barcode128 shipBarCode = new Barcode128 { X = 0.75f, N = 1.5f, Size = 10f, TextAlignment = Element.ALIGN_CENTER, Baseline = 10f, BarHeight = 50f, Code = data.ToString() }; document.Add(shipBarCode.CreateImageWithBarcode( cb, BaseColor.Black, BaseColor.Blue )); // it is composed of 3 blocks whith AI 01, 3101 and 10 Barcode128 uccEan128 = new Barcode128 { CodeType = Barcode.CODE128_UCC, Code = "(01)00000090311314(10)ABC123(15)060916" }; document.Add(uccEan128.CreateImageWithBarcode( cb, BaseColor.Blue, BaseColor.Black )); uccEan128.Code = "0191234567890121310100035510ABC123"; document.Add(uccEan128.CreateImageWithBarcode( cb, BaseColor.Blue, BaseColor.Red )); uccEan128.Code = "(01)28880123456788"; document.Add(uccEan128.CreateImageWithBarcode( cb, BaseColor.Blue, BaseColor.Black )); // INTER25 document.Add(new Paragraph("Barcode Interleaved 2 of 5")); BarcodeInter25 code25 = new BarcodeInter25 { GenerateChecksum = true, Code = "41-1200076041-001" }; document.Add(code25.CreateImageWithBarcode(cb, null, null)); code25.Code = "411200076041001"; document.Add(code25.CreateImageWithBarcode(cb, null, null)); code25.Code = "0611012345678"; code25.ChecksumText = true; document.Add(code25.CreateImageWithBarcode(cb, null, null)); // POSTNET document.Add(new Paragraph("Barcode Postnet")); BarcodePostnet codePost = new BarcodePostnet(); document.Add(new Paragraph("ZIP")); codePost.Code = "01234"; document.Add(codePost.CreateImageWithBarcode(cb, null, null)); document.Add(new Paragraph("ZIP+4")); codePost.Code = "012345678"; document.Add(codePost.CreateImageWithBarcode(cb, null, null)); document.Add(new Paragraph("ZIP+4 and dp")); codePost.Code = "01234567890"; document.Add(codePost.CreateImageWithBarcode(cb, null, null)); document.Add(new Paragraph("Barcode Planet")); BarcodePostnet codePlanet = new BarcodePostnet { Code = "01234567890", CodeType = Barcode.PLANET }; document.Add(codePlanet.CreateImageWithBarcode(cb, null, null)); // CODE 39 document.Add(new Paragraph("Barcode 3 of 9")); Barcode39 code39 = new Barcode39 { Code = "ITEXT IN ACTION" }; document.Add(code39.CreateImageWithBarcode(cb, null, null)); document.Add(new Paragraph("Barcode 3 of 9 extended")); Barcode39 code39Ext = new Barcode39 { Code = "iText in Action", StartStopText = false, Extended = true }; document.Add(code39Ext.CreateImageWithBarcode(cb, null, null)); // CODABAR document.Add(new Paragraph("Codabar")); BarcodeCodabar codabar = new BarcodeCodabar { Code = "A123A", StartStopText = true }; document.Add(codabar.CreateImageWithBarcode(cb, null, null)); // PDF417 document.Add(new Paragraph("Barcode PDF417")); BarcodePdf417 pdf417 = new BarcodePdf417(); string text = "Call me Ishmael. Some years ago--never mind how long " + "precisely --having little or no money in my purse, and nothing " + "particular to interest me on shore, I thought I would sail about " + "a little and see the watery part of the world." ; pdf417.SetText(text); Image img = pdf417.GetImage(); img.ScalePercent(50, 50 * pdf417.YHeight); document.Add(img); document.Add(new Paragraph("Barcode Datamatrix")); BarcodeDatamatrix datamatrix = new BarcodeDatamatrix(); datamatrix.Generate(text); img = datamatrix.CreateImage(); document.Add(img); document.Close(); stream.Dispose(); TestUtils.VerifyPdfFileIsReadable(pdfFilePath); }