public void SaveOptions(
string fileName
)
public:
void SaveOptions(
String^ fileName
)
def SaveOptions(self,fileName):
fileName
Name of the XML file to create
The load/save methods are provided as helper methods for the user. The BarcodeEngine, BarcodeReader and BarcodeWriter do not use these methods internally.
The default read options can be retrieved using the GetDefaultOptions or GetAllDefaultOptions methods. You can then change the values of the BarcodeReadOptions object returned (or cast it back to the appropriate derived class). These options are used by the ReadBarcode and ReadBarcodes methods when no explicit options are passed by the user.
To load the default options from an XML file, use BarcodeReader.LoadOptions(string fileName).
To save and load data to an XML stream, use BarcodeReader.SaveOptions(Stream stream) and BarcodeReader.LoadOptions(Stream stream).
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Barcode;
using Leadtools.ImageProcessing;
public void BarcodeReader_LoadSaveOptionsExample()
{
string xmlFileName = Path.Combine(LEAD_VARS.ImagesDir, "MyReadOptions.xml");
BarcodeEngine engine1 = new BarcodeEngine();
BarcodeReader reader1 = engine1.Reader;
// Show a few of the default options
ShowReaderOptions("Default options 1:", reader1);
// Change some options
OneDBarcodeReadOptions oneDReadOptions = reader1.GetDefaultOptions(BarcodeSymbology.UPCA) as OneDBarcodeReadOptions;
oneDReadOptions.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical;
QRBarcodeReadOptions qrReadOptions = reader1.GetDefaultOptions(BarcodeSymbology.QR) as QRBarcodeReadOptions;
qrReadOptions.EnableDoublePass = true;
// Show them
ShowReaderOptions("New options 1:", reader1);
// Save the options to an XML file
reader1.SaveOptions(xmlFileName);
// Now create another BarcodeReader
// We could use the same one, but this example will show that changing the options
// for one BarcodeReader will not change it in any other in the application
BarcodeEngine engine2 = new BarcodeEngine();
BarcodeReader reader2 = engine2.Reader;
// Show a few of the default options, should be the same as the first default options
ShowReaderOptions("Default options 2:", reader2);
// Load the options we just saved
reader2.LoadOptions(xmlFileName);
// Show them, should be the same as the new options in reader1
ShowReaderOptions("Loaded options 2:", reader2);
}
private void ShowReaderOptions(string message, BarcodeReader reader)
{
Console.WriteLine(message);
OneDBarcodeReadOptions oneDReadOptions = reader.GetDefaultOptions(BarcodeSymbology.UPCA) as OneDBarcodeReadOptions;
Console.WriteLine("OneDBarcodeReadOptions.SearchDirection: {0}", oneDReadOptions.SearchDirection);
QRBarcodeReadOptions qrReadOptions = reader.GetDefaultOptions(BarcodeSymbology.QR) as QRBarcodeReadOptions;
Console.WriteLine("QRBarcodeReadOptions.EnableDoublePass: {0}", qrReadOptions.EnableDoublePass);
Console.WriteLine("---------------");
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.junit.*;
import org.junit.Test;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import static org.junit.Assert.*;
import leadtools.*;
import leadtools.barcode.*;
import leadtools.codecs.*;
import leadtools.imageprocessing.*;
import leadtools.internal.ManualResetEvent;
public void barcodeReaderLoadSaveOptionsExample() {
final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";
String xmlFileName = combine(LEAD_VARS_IMAGES_DIR, "MyReadOptions.xml");
RasterCodecs codecs = new RasterCodecs();
BarcodeEngine engine1 = new BarcodeEngine();
BarcodeReader reader1 = engine1.getReader();
// Show a few of the default options
showReaderOptions("Default options 1:", reader1);
// Change some options
OneDBarcodeReadOptions oneDReadOptions = (OneDBarcodeReadOptions) reader1
.getDefaultOptions(BarcodeSymbology.UPC_A);
oneDReadOptions.setSearchDirection(BarcodeSearchDirection.HORIZONTAL_AND_VERTICAL);
QRBarcodeReadOptions qrReadOptions = (QRBarcodeReadOptions) reader1.getDefaultOptions(BarcodeSymbology.QR);
qrReadOptions.setEnableDoublePass(true);
// Show them
showReaderOptions("New options 1:", reader1);
// Save the options to an XML file
codecs.saveOptions(xmlFileName);
// Now create another BarcodeReader
// We could use the same one, but this example will show that changing the
// options
// for one BarcodeReader will not change it in any other in the application
BarcodeEngine engine2 = new BarcodeEngine();
BarcodeReader reader2 = engine2.getReader();
// Show a few of the default options, should be the same as the first default
// options
showReaderOptions("Default options 2:", reader2);
// Load the options we just saved
codecs.loadOptions(xmlFileName);
// Show them, should be the same as the new options in reader1
showReaderOptions("Loaded options 2:", reader2);
assertTrue("File unsuccessfully saved to " + xmlFileName, (new File(xmlFileName)).exists());
System.out.println("Successfully saved to " + xmlFileName);
}
private void showReaderOptions(String message, BarcodeReader reader) {
System.out.println(message);
OneDBarcodeReadOptions oneDReadOptions = (OneDBarcodeReadOptions) reader
.getDefaultOptions(BarcodeSymbology.UPC_A);
System.out.printf("OneDBarcodeReadOptions.SearchDirection: %s%n", oneDReadOptions.getSearchDirection());
QRBarcodeReadOptions qrReadOptions = (QRBarcodeReadOptions) reader.getDefaultOptions(BarcodeSymbology.QR);
System.out.printf("QRBarcodeReadOptions.EnableDoublePass: %s%n", qrReadOptions.getEnableDoublePass());
System.out.println("---------------");
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document