Loads the default write options used of this BarcodeWriter from the specified XML file.
public void LoadOptions(string fileName)
Public Overloads Sub LoadOptions( _ByVal fileName As String _)
public:void LoadOptions(String^ fileName)
fileName
The XML file containing the data.
The load/save methods are provided as helper methods for the user. The BarcodeEngine, BarcodeWriter and BarcodeWriter do not use these methods internally.
The default write options can be retrieved using the GetDefaultOptions or GetAllDefaultOptions methods. You can then change the values of the BarcodeWriteOptions object returned (or cast it back to the appropriate derived class). These options are used by the WriteBarcode method when no explicit options are passed by the user.
To save the default options to an XML file, use BarcodeWriter.SaveOptions(string fileName).
To save and load data to an XML stream, use BarcodeWriter.SaveOptions(Stream stream) and BarcodeWriter.LoadOptions(Stream stream).
This example will show how to change, save and then load the options of a BarcodeWriter object.
using Leadtools;using Leadtools.Codecs;using Leadtools.Forms;using Leadtools.Barcode;using Leadtools.ImageProcessing;public void BarcodeWriter_LoadSaveOptionsExample(){string xmlFileName = Path.Combine(LEAD_VARS.ImagesDir, "MyWriteOptions.xml");BarcodeEngine engine1 = new BarcodeEngine();BarcodeWriter writer1 = engine1.Writer;// Show a few of the default optionsShowWriterOptions("Default options 1:", writer1);// Change some optionsOneDBarcodeWriteOptions oneDWriteOptions = writer1.GetDefaultOptions(BarcodeSymbology.UPCA) as OneDBarcodeWriteOptions;oneDWriteOptions.UseXModule = true;QRBarcodeWriteOptions qrWriteOptions = writer1.GetDefaultOptions(BarcodeSymbology.QR) as QRBarcodeWriteOptions;qrWriteOptions.HorizontalAlignment = BarcodeAlignment.Far;// Show themShowWriterOptions("New options 1:", writer1);// Save the options to an XML filewriter1.SaveOptions(xmlFileName);// Now create another BarcodeWriter// We could use the same one, but this example will show that changing the options// for one BarcodeWriter will not change it in any other in the applicationBarcodeEngine engine2 = new BarcodeEngine();BarcodeWriter writer2 = engine2.Writer;// Show a few of the default options, should be the same as the first default optionsShowWriterOptions("Default options 2:", writer2);// Load the options we just savedwriter2.LoadOptions(xmlFileName);// Show them, should be the same as the new options in wirter1ShowWriterOptions("Loaded options 2:", writer2);}private void ShowWriterOptions(string message, BarcodeWriter writer){Console.WriteLine(message);OneDBarcodeWriteOptions oneDWriteOptions = writer.GetDefaultOptions(BarcodeSymbology.UPCA) as OneDBarcodeWriteOptions;Console.WriteLine("OneDBarcodeWriteOptions.UseXModule: {0}", oneDWriteOptions.UseXModule);QRBarcodeWriteOptions qrWriteOptions = writer.GetDefaultOptions(BarcodeSymbology.QR) as QRBarcodeWriteOptions;Console.WriteLine("QRBarcodeWriteOptions.HorizontalAlignment: {0}", qrWriteOptions.HorizontalAlignment);Console.WriteLine("---------------");}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.FormsImports Leadtools.BarcodeImports Leadtools.ImageProcessingPublic Sub BarcodeWriter_LoadSaveOptionsExample()Dim xmlFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "MyWriteOptions.xml")Dim engine1 As New BarcodeEngine()Dim writer1 As BarcodeWriter = engine1.Writer' Show a few of the default optionsShowWriterOptions("Default options 1:", writer1)' Change some optionsDim oneDWriteOptions As OneDBarcodeWriteOptions = DirectCast(writer1.GetDefaultOptions(BarcodeSymbology.UPCA), OneDBarcodeWriteOptions)oneDWriteOptions.UseXModule = TrueDim qrWriteOptions As QRBarcodeWriteOptions = DirectCast(writer1.GetDefaultOptions(BarcodeSymbology.QR), QRBarcodeWriteOptions)qrWriteOptions.HorizontalAlignment = BarcodeAlignment.Far' Show themShowWriterOptions("New options 1:", writer1)' Save the options to an XML filewriter1.SaveOptions(xmlFileName)' Now create another BarcodeWriter' We could use the same one, but this example will show that changing the options' for one BarcodeWriter will not change it in any other in the applicationDim engine2 As New BarcodeEngine()Dim writer2 As BarcodeWriter = engine2.Writer' Show a few of the default options, should be the same as the first default optionsShowWriterOptions("Default options 2:", writer2)' Load the options we just savedwriter2.LoadOptions(xmlFileName)' Show them, should be the same as the new options in wirter1ShowWriterOptions("Loaded options 2:", writer2)End SubPrivate Sub ShowWriterOptions(ByVal message As String, ByVal writer As BarcodeWriter)Console.WriteLine(message)Dim oneDWriteOptions As OneDBarcodeWriteOptions = DirectCast(writer.GetDefaultOptions(BarcodeSymbology.UPCA), OneDBarcodeWriteOptions)Console.WriteLine("OneDBarcodeWriteOptions.UseXModule: {0}", oneDWriteOptions.UseXModule)Dim qrWriteOptions As QRBarcodeWriteOptions = DirectCast(writer.GetDefaultOptions(BarcodeSymbology.QR), QRBarcodeWriteOptions)Console.WriteLine("QRBarcodeWriteOptions.HorizontalAlignment: {0}", qrWriteOptions.HorizontalAlignment)Console.WriteLine("---------------")End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
|
Products |
Support |
Feedback: LoadOptions(String) Method - Leadtools.Barcode |
Introduction |
Help Version 19.0.2017.6.21
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.