Native C++ external component for 1C:Enterprise
for generating 2D barcodes in clean SVG format
Overview • Features • Architecture • Building • Usage from 1C • Testing • Documentation
SVG Barcode Generator for 1C is a cross-platform native C++ external component for 1C:Enterprise.
It generates 2D barcodes and returns them as SVG markup, making the result suitable for:
- printed forms;
- reports;
- documents;
- labels;
- web pages;
- scalable UI rendering.
The project uses ZXing-cpp for barcode encoding and converts the generated barcode matrix into SVG.
| QR Code | Generate QR codes as SVG |
| DataMatrix | Generate DataMatrix codes as SVG |
| Aztec | Generate Aztec barcodes as SVG |
| 1C Integration | Native external component API integration |
| Cross-platform | Windows, Linux, and macOS builds |
| Modern C++ | C++20, modular architecture, CMake build system |
| Barcode type | Status | Output |
|---|---|---|
| QR Code | Supported | SVG |
| DataMatrix | Supported | SVG |
| Aztec | Supported | SVG |
SVG output is useful because it is:
- scalable without quality loss;
- easy to embed into HTML;
- suitable for printing;
- lightweight;
- independent from raster image formats;
- easy to store as plain text.
include/ Public headers, interfaces, and declarations
src/ Component implementation and core logic
external/ Third-party libraries: ZXing-cpp and 1C Native API SDK
docs/ Project documentation, architecture notes, and UML diagrams
tests/ Unit tests for encoders, services, factories, and renderers
The project follows a layered architecture where barcode encoding, rendering, service logic, and 1C integration are separated into independent modules.
| Layer | Component | Responsibility |
|---|---|---|
| Encoder interface | IEncoder |
Common contract for all barcode encoders |
| Encoders | QREncoder, DataMatrixEncoder, AztecEncoder |
Barcode-specific encoding logic |
| Factory | EncoderFactory |
Creates an encoder for the requested barcode type |
| Service | BarcodeService |
Main API for generating barcode SVG output |
| Rendering | SvgRenderer |
Converts barcode matrices into SVG markup |
| 1C integration | ComponentInterface |
Bridges C++ logic with the 1C external component API |
- CMake 3.20+
- C++20-compatible compiler
- ZXing-cpp
- 1C Native API SDK
| Platform | Compiler |
|---|---|
| Windows | MSVC, MinGW-w64, Clang |
| Linux | GCC, Clang |
| macOS | Apple Clang |
git clone https://github.com/Triler1/1c-barcode-generator.git
cd 1c-barcode-generatorMake sure all third-party dependencies in external/ are available before building.
Windows build
The 1C:Enterprise client on Windows is commonly used as a 32-bit application.
When targeting a 32-bit 1C client, build the component as x86.
cmake -B build -S . -G "Visual Studio 17 2022" -A Win32
cmake --build build --config ReleaseResult:
build/Release/BarcodeGenerator.dll
cmake -B build -S . -G "MinGW Makefiles" ^
-DCMAKE_C_COMPILER=i686-w64-mingw32-gcc ^
-DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++
cmake --build buildResult:
build/BarcodeGenerator.dll
macOS build
The 1C:Enterprise client for macOS is commonly built for x86_64.
On Apple Silicon, it may run through Rosetta, so build the component for x86_64 unless your target 1C client requires another architecture.
xcode-select --install
brew install cmakecmake -B build -S . -DCMAKE_OSX_ARCHITECTURES=x86_64
cmake --build buildResult:
build/libBarcodeGenerator.dylib
Linux build
sudo apt update
sudo apt install cmake g++ ninja-buildcmake -B build -S .
cmake --build buildResult:
build/libBarcodeGenerator.so
| Platform | Library |
|---|---|
| Windows | BarcodeGenerator.dll |
| Linux | libBarcodeGenerator.so |
| macOS | libBarcodeGenerator.dylib |
After building the native library, it can be loaded in 1C as an external component.
ПутьКомпоненты = "C:\Path\To\BarcodeGenerator.dll";
Подключено = ПодключитьВнешнююКомпоненту(
ПутьКомпоненты,
"BarcodeGenerator",
ТипВнешнейКомпоненты.Native
);
Если Не Подключено Тогда
ВызватьИсключение "Failed to load BarcodeGenerator component";
КонецЕсли;
Генератор = Новый("AddIn.BarcodeGenerator.BarcodeGenerator");For Linux and macOS, use the corresponding shared library:
// Linux
ПутьКомпоненты = "/path/to/libBarcodeGenerator.so";
// macOS
ПутьКомпоненты = "/path/to/libBarcodeGenerator.dylib";Данные = "https://example.com";
РазмерМодуля = 10;
Отступ = 4;
SVG = Генератор.GenerateQR(
Данные,
РазмерМодуля,
Отступ
);Данные = "010460123456789021ABC123";
РазмерМодуля = 10;
Отступ = 4;
SVG = Генератор.GenerateDataMatrix(
Данные,
РазмерМодуля,
Отступ
);Данные = "AZTEC-123456";
РазмерМодуля = 10;
Отступ = 4;
SVG = Генератор.GenerateAztec(
Данные,
РазмерМодуля,
Отступ
);ПутьФайла = "C:\Temp\barcode.svg";
Запись = Новый ЗаписьТекста;
Запись.Открыть(ПутьФайла, КодировкаТекста.UTF8);
Запись.Записать(SVG);
Запись.Закрыть();
Сообщить("SVG barcode saved to: " + ПутьФайла);| Parameter | Type | Description |
|---|---|---|
data |
String | Text or payload to encode |
moduleSize |
Number | Size of one barcode module in SVG units |
margin |
Number | Quiet zone around the barcode |
Example:
SVG = Генератор.GenerateDataMatrix("1234567890", 8, 2);| Method | Description |
|---|---|
GenerateQR(data, moduleSize, margin) |
Generates QR Code SVG |
GenerateDataMatrix(data, moduleSize, margin) |
Generates DataMatrix SVG |
GenerateAztec(data, moduleSize, margin) |
Generates Aztec SVG |
The component also provides Russian aliases for barcode generation methods.
You can use either English method names:
SVG = Генератор.GenerateQR("Hello", 10, 4);
SVG = Генератор.GenerateDataMatrix("1234567890", 10, 4);
SVG = Генератор.GenerateAztec("AZTEC-123", 10, 4);or Russian aliases:
SVG = Генератор.СформироватьQR("Hello", 10, 4);
SVG = Генератор.СформироватьДатаМатрикс("1234567890", 10, 4);
SVG = Генератор.СформироватьAztec("AZTEC-123", 10, 4);| English method | Russian alias | Description |
|---|---|---|
GenerateQR |
СформироватьQR |
Generates QR Code SVG |
GenerateDataMatrix |
СформироватьДатаМатрикс |
Generates DataMatrix SVG |
GenerateAztec |
СформироватьAztec |
Generates Aztec SVG |
Both English method names and Russian aliases accept the same parameters:
data, moduleSize, margin
Функция СоздатьГенераторШтрихкодов() Экспорт
ПутьКомпоненты = "C:\Path\To\BarcodeGenerator.dll";
Подключено = ПодключитьВнешнююКомпоненту(
ПутьКомпоненты,
"BarcodeGenerator",
ТипВнешнейКомпоненты.Native
);
Если Не Подключено Тогда
ВызватьИсключение "Failed to load BarcodeGenerator component";
КонецЕсли;
Возврат Новый("AddIn.BarcodeGenerator.BarcodeGenerator");
КонецФункцииГенератор = СоздатьГенераторШтрихкодов();
SVG = Генератор.СформироватьДатаМатрикс(
"010460123456789021ABC123",
10,
4
);
ПутьФайла = "C:\Temp\datamatrix.svg";
Запись = Новый ЗаписьТекста;
Запись.Открыть(ПутьФайла, КодировкаТекста.UTF8);
Запись.Записать(SVG);
Запись.Закрыть();Генератор = СоздатьГенераторШтрихкодов();
QRCodeSVG = Генератор.СформироватьQR(
"https://example.com",
10,
4
);
DataMatrixSVG = Генератор.СформироватьДатаМатрикс(
"010460123456789021ABC123",
10,
4
);
AztecSVG = Генератор.СформироватьAztec(
"AZTEC-123456",
10,
4
);Генератор = СоздатьГенераторШтрихкодов();
Данные = "1234567890";
// Smaller barcode
SVGSmall = Генератор.СформироватьДатаМатрикс(
Данные,
5,
2
);
// Larger barcode
SVGLarge = Генератор.СформироватьДатаМатрикс(
Данные,
12,
6
);Попытка
Генератор = СоздатьГенераторШтрихкодов();
SVG = Генератор.СформироватьДатаМатрикс(
"1234567890",
10,
4
);
Исключение
Сообщить("Barcode generation failed: " + ОписаниеОшибки());
КонецПопытки;- The returned value is an SVG string.
- SVG can be saved to a file, embedded into HTML, or used in generated documents.
- For initial testing, use digits or Latin characters.
- Full Unicode handling depends on string conversion between 1C and the native component.
Unit tests are located in the tests/ directory.
The test suite covers:
- QR encoder;
- DataMatrix encoder;
- Aztec encoder;
- encoder factory;
- barcode service;
- SVG renderer;
- barcode matrix behavior.
Project documentation, architecture notes, implementation details, and UML diagrams are located in the docs/ directory.
| Document | Description |
|---|---|
| Project Documentation | Main documentation entry point |
| Architecture | Architecture overview |
| Implementation Plan | Development plan and implementation notes |
| UML Class Diagram | Visual class diagram |
| Library | Purpose | License |
|---|---|---|
| ZXing-cpp | Barcode encoding | Apache License 2.0 |
| 1C Native API SDK | 1C external component integration | See SDK license |
The project is under active development.
Current focus:
- stable barcode generation core;
- 1C external component integration;
- SVG rendering;
- cross-platform builds;
- unit test coverage.
Planned improvements:
- improved Unicode handling;
- more complete platform-specific build documentation;
- CI builds for Windows, Linux, and macOS;
- expanded test coverage;
- example generated SVG previews;
- release packages for each supported platform.
This project is licensed under the Apache License 2.0.
See the LICENSE file for details.
- ZXing-cpp — Apache License 2.0
See licenses/LICENSE.zxing-cpp.
Made for 1C:Enterprise barcode generation in clean SVG format.
