Guidance:
1. Import the Microsoft Access barcode control 9.0 control using "Import ActiveX" under "component. This control (msbcode9.occx) is installed with the Office in the system.
2. You can see the control under "ActiveX" and drag it to the form. You can set the bar code type, content, width, and height through attribute settings.
The data of the bar code is set through the "value" attribute, and the reference database field is also set through datasource. The height and width are set by the height and width of the control. The blank area cannot be reduced.
3 code
After a control has been inserted, you can print it as follows.
I tried to print and read.
If you want to print a file without displaying it on the interface, you can query it by yourself.
Procedure tform1.button1click (Sender: tobject );
VaR
BMP: tbitmap;
Sr, TR: trect;
Begin
// Record the image
BMP: = tbitmap. Create;
SR: = rect (barcodectrl1.left, barcodectrl1.top, barcodectrl1.left + barcodectrl1.width,
Barcodectrl1.top + barcodectrl1.height );
TR: = rect (0, 0, barcodectrl1.width, barcodectrl1.height );
BMP. Width: = barcodectrl1.width;
BMP. Height: = barcodectrl1.height;
BMP. Canvas. copyrect (TR, canvas, Sr );
// BMP. savetofile ('C: \ 1.bmp ');
// Print
Printer. begindoc;
Printer. Canvas. Font. Size: = 15;
Printer. Canvas. textout (10, 10, 'barcodestrl demo ');
Printer. Canvas. Draw (20,100, BMP );
Printer. enddoc;
// Release resources
BMP. Free;
End;
Procedure tform1.formcreate (Sender: tobject );
Begin
// Generate a bar code
Barcodectrl1.value: = '20140901 ';
Barcodectrl1.width: = 400;
Barcodectrl1.height: = 100;
End;
Everything goes well!
---------------------------------
Pay attention to the following points:
1. This control does not seem to be very compliant with the width-to-width ratio of the bar code. Therefore, you need to find a suitable width-to-width ratio to ensure that you can read it.
2. Use the default settings of the printer driver according to the above method. Therefore, you need to select the appropriate page and related processing on the printer driver as the default value. Of course, there should be better ways to set the printer driver, you can search for the network!
3. You can also download some bar code fonts from the Internet and set the print font to the bar code font. This method is simpler, but it has certain precision requirements for printers and scanners.