Click here to Skip to main content
15,908,015 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
Linear code128 = new Linear();

// Barcode data to encode
code128.Data = txttag.Text;
// Barcode symbology type. Code 128 supports types: CODE128, CODE128A, CODE128B, CODE128C.
code128.Type = BarcodeType.CODE128;
// Apply checksum digit for Code-128
code128.AddCheckSum = true;

/*
* Barcode Image Related Settings
*/
// Unit of meature for all size related setting in the library. 
code128.UOM = UnitOfMeasure.PIXEL;
// Bar module width (X), default is 1 pixel;
code128.X = -5;
// Bar module height (Y), default is 60 pixel;
code128.Y = 15;

// Barcode image left, right, top, bottom margins. Defaults are 0.
code128.LeftMargin = 0;
code128.RightMargin = 0;
code128.TopMargin = 0;
code128.BottomMargin = 0;
// Image resolution in dpi, default is 72 dpi.
code128.Resolution = 72;
// Created barcode orientation.
//4 options are: facing left, facing right, facing bottom, and facing top
code128.Rotate = Rotate.Rotate0;

/*
* Linear barcodes human readable text styles
*/
// Display human readable text under the barcode
code128.ShowText = true;
// Display checksum digit at the end of barcode data.
code128.ShowCheckSumChar = true;
// Human readable text font size, font family and style
code128.TextFont = new Font("Arial", 9f, FontStyle.Regular);
// Space between barcode and text. Default is 6 pixel.
code128.TextMargin = 3;

// Generate Code-128 and encode barcode to gif format
code128.Format = System.Drawing.Imaging.ImageFormat.Png;
code128.drawBarcode("D:\\" + txttag.Text + ".png");

//   DataSet ds = Objcl.AddTag(txttag.Text, Convert.ToByte(code128.drawBarcode()), 20);
}


i have already use this code but i am got output image but not needed i have only need in text p
Posted
v5

Barcodes are not text. They are graphic images which are intended to be machine readable, not text which a human can read. If you want text, then use the Article Number that the barcode represents: people can read that.
 
Share this answer
 
v2
Comments
antish1 28-Mar-14 7:02am    
yeah you are right how can directly print barcode
antish1 28-Mar-14 7:03am    
i have genrate barcode in folder then print but i want to need direct print
OriginalGriff 28-Mar-14 7:12am    
And what environment? Windows? Web?
antish1 28-Mar-14 7:33am    
in web
OriginalGriff 28-Mar-14 7:49am    
Then you pretty much can't do it - you could possibly do it via Javascript (since that ruins on the client) but you can't do it directly from the C# code, as the server has no access to client hardware for security reasons.

Think about it: if you could, so could anybody. Then your printer would permanently be spewing out 100 page documents explaining why you should buy viagra / defrag your memory / make $$$$ while you sleep.

You can send the barcode to the client for printing, or you can include it on your website and use CSS to control what does get printed, but you can't print direct to the user printer.
If you already have the barcode images in disk, then you can display them in your aspx page using IMG tag and then get them printed using javascrip window.print()
Of course, that relies on browser's printing functionality and a print dialog will be displayed to the user. If you want to avoid the print dialog to be displayed, then you'll need the help from an external tool like this but it's not free, sadly.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900