Created
June 3, 2020 18:01
-
-
Save aspose-com-gists/281552f8ccf17e6b5ae4e313414184a8 to your computer and use it in GitHub Desktop.
Generate barcodes using C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const System::String codeText = u"1234567"; | |
const System::String fileName = u"code39_barcode.jpg"; | |
// Create barcode generator | |
System::SharedPtr<BarcodeGenerator> barcodeGenerator = System::MakeObject<BarcodeGenerator>(EncodeTypes::Code39Standard, codeText); | |
barcodeGenerator->get_Parameters()->set_Resolution(300); | |
// Generate barcode and save as image | |
barcodeGenerator->Save(fileName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System::SharedPtr<BarcodeGenerator> barcodeGenerator = [&] { auto tmp_0 = System::MakeObject<BarcodeGenerator>(EncodeTypes::Aztec, System::String(u"1234567890")); | |
// set broder style | |
tmp_0->get_Parameters()->get_Border()->set_DashStyle(Aspose::BarCode::BorderDashStyle::Solid); | |
// set width | |
tmp_0->get_Parameters()->get_Border()->get_Width()->set_Millimeters(1.0f); | |
// set border visibility | |
tmp_0->get_Parameters()->get_Border()->set_Visible(true); | |
// set background color | |
tmp_0->get_Parameters()->set_BackColor(System::Drawing::Color::get_Black()); | |
// set barcode's bar color | |
tmp_0->get_Parameters()->get_Barcode()->set_ForeColor(System::Drawing::Color::get_Orange()); | |
// set border color | |
tmp_0->get_Parameters()->get_Border()->set_Color(System::Drawing::Color::get_Black()); | |
// set text color | |
tmp_0->get_Parameters()->get_Barcode()->get_CodeTextParameters()->set_Color(System::Drawing::Color::get_Orange()); | |
// set image resolution | |
tmp_0->get_Parameters()->set_Resolution(400); | |
return tmp_0; }(); | |
barcodeGenerator->Save(System::String(u"custom_barcode.jpg")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const System::String codeText = u"1234567"; | |
const System::String fileName = u"QR_Code.jpg"; | |
// Create barcode generator | |
System::SharedPtr<BarcodeGenerator> barcodeGenerator = System::MakeObject<BarcodeGenerator>(EncodeTypes::QR, codeText); | |
barcodeGenerator->get_Parameters()->set_Resolution(300); | |
// Generate barcode and save as image | |
barcodeGenerator->Save(fileName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create instance of BarcodeGenerator class | |
System::SharedPtr<BarCodeReader> reader = System::MakeObject<BarCodeReader>(u"Code128.png", DecodeType::Code128); | |
while (reader->Read()) | |
{ | |
// Display code text and Symbology Type | |
System::Console::WriteLine(System::String(u"CodeText: ") + reader->GetCodeText()); | |
System::Console::Write(System::String(u"Symbology Type: ") + reader->GetCodeType()); | |
} | |
reader->Close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set barcode symbologies | |
System::ArrayPtr<System::SharedPtr<BaseDecodeType>> objArray = System::MakeArray<System::SharedPtr<Aspose::BarCode::BarCodeRecognition::BaseDecodeType>>({ DecodeType::Code39Standard, DecodeType::Pdf417 }); | |
// Initialize the BarCodeReader, Call Read() method in a loop and Display the codetext and symbology type | |
System::SharedPtr<BarCodeReader> reader = System::MakeObject<BarCodeReader>(u"RecognizingMultipleSymbologies.png", objArray); | |
while (reader->Read()) | |
{ | |
System::Console::WriteLine(System::String(u"Codetext: ") + reader->GetCodeText()); | |
System::Console::WriteLine(System::String(u"Symbology type: ") + reader->GetCodeType()); | |
} | |
reader->Close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment