简体   繁体   中英

C# iTextSharp Barcode Code128 Without Text

Hi I'm currently using itextsharp to create a simple export pdf function on my C# window application. I had successfully generated the PDF with barcode, is there anyway to generate the barcode without the text on the bottom?

Here is my code to generate the barcode and put into table cell on the itextsharp :

 iTextSharp.text.pdf.Barcode128 bc = new Barcode128();
            bc.TextAlignment = Element.ALIGN_CENTER;
            bc.Code = palletID;
            bc.StartStopText = false;
            bc.CodeType = iTextSharp.text.pdf.Barcode128.CODE128;
            bc.X = 1f;
            bc.Extended = true;

            iTextSharp.text.Image PatImage1 = bc.CreateImageWithBarcode(cb, iTextSharp.text.BaseColor.BLACK, iTextSharp.text.BaseColor.BLACK);
            PatImage1.ScaleAbsolute(480f, 175.25f);
            PdfPCell palletBarcodeCell = new PdfPCell(PatImage1);
            palletBarcodeCell.Border = iTextSharp.text.Rectangle.RIGHT_BORDER | iTextSharp.text.Rectangle.TOP_BORDER | iTextSharp.text.Rectangle.BOTTOM_BORDER;
            palletBarcodeCell.Colspan = 2;
            palletBarcodeCell.FixedHeight = 61f;
            palletBarcodeCell.HorizontalAlignment = 1;
            palletBarcodeCell.VerticalAlignment = 1;
            table.AddCell(palletBarcodeCell);

I coudn't find any solution through google or the forum. Can any expert here help me on this? Thanks

I think i had found a alternative way.

By using this to put the text to be empty at the barcode there

 bc.AltText = palletID; //Alternative Text on barcode

将字体设置为 null 示例:

bc.Font = null;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM