How to add a barcode to printable forms 1c. Entering Barcode Information

An example of creating barcodes in a spreadsheet document 1C: Enterprise 8.2 / 8.3 in the managed application mode. Below are examples for EAN-13, GS1-128, QR Code, and other common barcode formats.

To run the example, you need to install the StrokeScribe software.

The example is intended only for the managed application mode and has been tested for compatibility with versions 1C 8.2 / 8.3.

The example requires StrokeScribe version 4.2 or later to be installed.

Preparing a layout for barcode output

1. Create a new report in the 1C: Enterprise 8.2 designer and give it a name Report Barcode(this name will be used in the module below).

2. For the report Report Barcode create a spreadsheet document layout under the name Layout barcode.

3. In the layout, create an area of ​​arbitrary size with the name Area Barcode.

4. Place a picture in the area (the Table-> Pictures-> Picture menu) with the dimensions of the future barcode. Specify a name in the image properties - Drawing barcode.

As a result of all actions, you should get a report layout similar to the one shown in the figure:

Report module

& AtServer Function DockServer () TabDoc = New TabularDocument; Layout = Reports.ReportBarcode.Get Layout ("LayoutBarcode"); Area = Layout.GetArea ("AreaBarcode"); // Pay attention to the coincidence of the report, layout and area names in the module and in the design barcode = GetCOMObject ("", "STROKESCRIBE.StrokeScribeClass.1"); // Did you forget to install StrokeScribe? FileName = GetTemporaryFileName ("wmf"); // Temporary file in temporary directory with extension .wmf barcode.Alphabet = 25; // QR CODE barcode.Text = "123ABCD"; // Data for barcode code = barcode.SavePicture (FileName, 7, // 7 = WMF 100 , // The width of the barcode picture is 100); // Barcode height If the code<>0 Then // Check the result of barcode generation Report (string (code) + "-" + barcode.ErrorDescription); Return False; EndIf; // Make sure that the name of the drawing object matches here and in the design pic = Area.Drawings.FigureBarcode; Fig. Picture Size = Picture Size. Proportional; fig.Line = New Line (LineType of TabularDocument Drawing.No Line); // There should not be a picture frame around the barcode. Picture = New Picture (FileName); // Load a picture with a barcode // Specify the same file name as in SavePicture TabDoc.Out (Area); DeleteFiles (FileName); // Erase a temporary file with a picture Return TabDocs; EndFunction & OnClient ProcedureCommandProcessing (CommandParameter, CommandParameters) TabDok1 = DockOnServer (); If TabDok1<>False Then TabDok1.Show (); EndIf; End of Procedure

Notes on the report module:

To successfully complete the call GetCOMObject () don't forget to install the StrokeScribe software. When operating in client-server mode, StrokeScribe must be installed on the server. StrokeScribe does not need to be installed on client PCs.

Call GetTemporaryFileName () is required to get an arbitrary name of an intermediate file in which the barcode image will be saved before transferring it to the spreadsheet document. The file must exist before the call TabDoc.Withdraw (Region)... The temporary file can then be deleted. If you plan to create several barcodes in one area, then a temporary file must be created for each barcode. As SavePicture saves the barcode in WMF format, the corresponding extension is assigned to the generated file.

If desired, a fixed filename can also be used, for example: FileName = "c: \ temp \ barcode.wmf"... It goes without saying that the folder "c: \ temp" must exist and be available to create files.

Assignment barcode.Alphabet = sets the barcode format. Barcode type constants are available in the documentation. Examples of creating the most common barcodes are shown below.

Data assigned barcode.Text, depend on the barcode format. For example, EAN-13 cannot display letters and has a fixed length, and CODE 128 does not work with Cyrillic. If StrokeScribe cannot process the string, then a nonzero value will be written to the Error property. The module uses simplified error checking - the result of all operations is put together in a variable code: code = barcode.SavePicture ().

The SavePicture () call saves the barcode image to a temporary file. Specifying 7 in the second parameter of the SavePicture () call will create a scalable vector WMF image. The commercial version of StrokeScribe also offers JPG, PNG, GIF, BMP24 and EMF formats. Barcode raster imaging is not recommended due to the large amount of data and poor scalability, but can be used if the thin client does not support WMF.

In construction If the code<>0 the result of saving the barcode image in the file is checked. The code will be nonzero even if a non-existent barcode type is specified or in the property Text sent data that is not displayed by the selected barcode type. A textual explanation of the error code is available in the property ErrorDescription... The result of each operation with a barcode object can be further controlled by checking the value of the Error property.

To display a lot of barcodes, it is enough to organize a circular assignment Text =, Alphabet =(optional) and method call SavePicture... Each call to SavePicture must have a separate file name for each barcode within the same area prior to calling TabDoc.Display ()... After the area is displayed, the files can be deleted.

Below are examples of how to create some common barcode formats. Since some of the formats have additional settings, we recommend referring to the pages focused on a specific barcode format (see the site menu on the left) and to the documentation on the StrokeScribe properties.

Please note- 1C: Enterprise version 8.2.12.96, which was tested, incorrectly centers WMF images, shifting them to the right. Therefore, it is not recommended to reduce the blank zones of barcodes (HBorderSize and QuietZone2D properties) in order to avoid the loss of part of the barcode lines.

Barcode.Alphabet = 3; // EAN13 barcode.Text = "123456789012"; code = barcode.SavePicture (FileName, 7, 100, 60);

Barcode.Alphabet = 5; // CODE128 barcode.Text = "123ABC" + Symbol (9) + "def"; code = barcode.SavePicture (FileName, 7, 100, 60);

Symbol (9)- language function 1C - encodes a tabulation character (ASCII TAB). All unreadable characters are displayed as * in the signature under the barcode. CODE 128 allows you to specify an arbitrary signature text that will be displayed under the barcode instead of the standard display of encoded data:

Barcode.Alphabet = 7; // ITF14 barcode.Text = "1234567890123"; barcode.ITF14BearerBox = 1; code = barcode.SavePicture (FileName, 7, 100, 30);

Property ITF14BearerBox prints ITF-14 with a rectangular border typically found on corrugated dies. To output a barcode with only horizontal security lines, specify ITF14BearerBox = 0.

Detailed examples on creating GS1 strings can be found here. For a list of formats supported by GS1 identifiers, see the compatibility list.

Modify the source code of the module as shown below:

Barcode.Alphabet = 17; // EAN128 GS = Symbol (29); barcode.Text = "10" + "1234" + GS + "3301" + "123456" + "17" + "010517"; barcode.ITF14BearerBox = 1; code = barcode.SavePicture (FileName, 7, 100, 30);

Large amounts of GS1 data can be stored in GS1 DATAMATRIX 2D barcodes.

Barcode.Alphabet = 8; // DATAMATRIX barcode.Text = "123abcDEF"; code = barcode.SavePicture (FileName, 7, 100, 100);

To print the Aztec code, modify the source code of the module as shown below:

Barcode.Alphabet = 33; // AZTEC barcode.Text = "123ABcd"; code = barcode.SavePicture (FileName, 7, 100, 100);

The example provided here is for generating QR code for mobile applications. Most warehouse and office applications in Russia (when recognized by specialized scanners) require direct text transmission in the CP1251 code page. To do this, install UTF8 = 0... Installation QrECL is given here by way of example and is optional.

Barcode.Alphabet = 25; // QRCODE barcode.Text = "Cyrillic"; barcode.UTF8 = 1; barcode.QrECL = 2; code = barcode.SavePicture (FileName, 7, 100, 100);

Version 8.0.16.4.

If, when generating receipts, the message “Component 1C: Barcode printing is not installed on this computer! You can find detailed information on installing the components on our website. this means that you need to install Component 1C: Barcode Printing 1CBarCode.exe

The component for printing barcodes 1CBarCode.exe is supplied on ITS disks or you can download 1CBarCode_8.0.16.4.exe from the following link.

Instructions for installing the 1CBarCode.exe component:
1. Download the file 1CBarCode_8.0.16.4.rar from the link above, save it to your computer and unzip the file.
2. Click on the file and select the installation language, click the "Ok" button
3. The installation welcome and warning window will appear, click the "Next" button
4. After the window of the license agreement will be released Components 1C: Printing barcodes, select the item "I accept the terms of the license agreement" and press the button "Next"
5. To continue, you must select the type of installation:
Full - all program components will be installed (set by default for regular users)
Custom - select the required program components and the folder in which they will be installed. (designed for advanced users)
6. Confirm the readiness of the installation of the program, click the "Install" button. To view or change the installation parameters, press the "Back" button or the "Cancel" button to exit the program.
7. We are waiting for the end of the installation and click the "Finish" button
When generating receipts, the barcodes "One-dimensional" or "Two-dimensional" will be issued, depending on the choice in the "Accounting policy (Housing)" setting (Accounting in Housing and Utilities - Accounting Policy (Housing) - Barcode)

Version 8.0.16.4.

If, when generating receipts, the message “Component 1C: Barcode printing is not installed on this computer! You can find detailed information on installing the components on our website. this means that you need to install Component 1C: Barcode Printing 1CBarCode.exe

The component for printing barcodes 1CBarCode.exe is supplied on ITS disks or you can download 1CBarCode_8.0.16.4.exe from the following link.

Instructions for installing the 1CBarCode.exe component:
1. Download the file 1CBarCode_8.0.16.4.rar from the link above, save it to your computer and unzip the file.
2. Click on the file and select the installation language, click the "Ok" button
3. The installation welcome and warning window will appear, click the "Next" button
4. After the window of the license agreement will be released Components 1C: Printing barcodes, select the item "I accept the terms of the license agreement" and press the button "Next"
5. To continue, you must select the type of installation:
Full - all program components will be installed (set by default for regular users)
Custom - select the required program components and the folder in which they will be installed. (designed for advanced users)
6. Confirm the readiness of the installation of the program, click the "Install" button. To view or change the installation parameters, press the "Back" button or the "Cancel" button to exit the program.
7. We are waiting for the end of the installation and click the "Finish" button
When generating receipts, the barcodes "One-dimensional" or "Two-dimensional" will be issued, depending on the choice in the "Accounting policy (Housing)" setting (Accounting in Housing and Utilities - Accounting Policy (Housing) - Barcode)

Sometimes, as part of barcoding documents or labels, an arbitrary barcode must be displayed on the 1C 8.2 (8.3) printing form.

How to do this, we will consider below.

To output a barcode necessarily (except for configurations based on BSP 2 and higher), the component must be installed. You can find it on the ITS disk or on the 1C user portal.

Inserting a barcode on a 1C printing form

The first step is to create a new object - a drawing. To do this, in the layout, click Table - Pictures - Insert Object ... The system will offer to select the type of object:

Get 267 1C video tutorials for free:

You need to choose Control element1C.V8.Print barcodes... Let's call the picture-object "Barcode". For programmatic output to a printed form, you can use the following code:

CodeType = GetValue of aBarcodeTypeForEU (PlansViewsCharacteristics .Types ofBarcodes. Code39); If CodeType = - 1 Then GeneralPurpose. ReportBug ( "For barcode format""" + Plans of SpeciesCharacteristics. Types of Barcodes. EAN13 + "" "there is no corresponding type in EI""1C: Printing barcodes"". | The position will be skipped "); EndIf; Region. Drawings. Barcode. An object. CodeType = CodeType; Region. Drawings. Barcode. An object. Message =? (EmptyString (""), Barcode, ""); Region. Drawings. Barcode. An object. TextCode = Barcode;