Itextsharp
Need in last column instead text need to be bar code 128 from that text
Or can be image to be paste across text in column
Bar code c# code:
-
- foreach (DataGridViewRow row in OperacijeDataGridView.Rows)
- {
- foreach (DataGridViewCell cell in row.Cells)
- {
- PdfPCell cell2 = new PdfPCell(new Phrase(cell.Value.ToString(), calibri));
- cell2.HorizontalAlignment = Element.ALIGN_LEFT;
-
- Barcode128 code128 = new Barcode128();
- code128.CodeType = Barcode.CODE128_RAW;
- code128.ChecksumText = true;
- code128.GenerateChecksum = true;
- code128.Code = Barcode128.GetRawText(row.Cells[1].Value.ToString(), false, Barcode128.Barcode128CodeSet.AUTO);
- System.Drawing.Bitmap bm = new System.Drawing.Bitmap(code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
- iTextSharp.text.Image barCode = iTextSharp.text.Image.GetInstance(bm, System.Drawing.Imaging.ImageFormat.Png);
-
- PdfPTable tmpTable = new PdfPTable(1);
- tmpTable.WidthPercentage = 100;
- PdfPCell tmpCell = new PdfPCell(barCode);
- tmpTable.AddCell(new Paragraph(row.Cells[12].Value.ToString().ToUpper(), calibri));
- barCode.ScaleAbsolute(70, 30);
- tmpCell.FixedHeight = 40;
- tmpCell.HorizontalAlignment = Element.ALIGN_CENTER;
- tmpCell.VerticalAlignment = Element.ALIGN_MIDDLE;
- tmpCell.BorderWidth = 0;
- tmpTable.AddCell(tmpCell);
- tmpTable.DefaultCell.BorderWidth = 0;
- tmpTable.DefaultCell.VerticalAlignment = Element.ALIGN_TOP;
- tmpTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
-
-
-
- tmpCell.AddElement(tmpTable);
- pdfTable.AddCell(tmpCell);
-
- pdfTable.AddCell(cell2);
- }
- }