TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Goran Bibic
474
2.9k
201.2k
Bar code instead text in column c#
Jul 1 2020 7:38 AM
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:
//Adding DataRow
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);
//PdfPCell pdfCell = new PdfPCell();
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);
//100x40
tmpCell.FixedHeight = 40;
//60
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;
//tmpTable.AddCell(new Paragraph(row.Cells[4].Value.ToString().ToUpper(), calibri6));
//tmpTable.AddCell(new Paragraph(row.Cells[12].Value.ToString().ToUpper(), calibri));
// pdfCell.AddElement(tmpTable);
tmpCell.AddElement(tmpTable);
pdfTable.AddCell(tmpCell);
pdfTable.AddCell(cell2);
}
}
Reply
Answers (
2
)
Marshaling code2 : Problem described below
String Construction - Create Table with Parameter