This class contains QR barcode information for writing QR barcodes.
[DataContractAttribute(Namespace="http://Leadtools.Services.Barcode.DataContracts/2009/01", Name="BarcodeWriteQr")]
public class BarcodeWriteQr
<DataContractAttribute(Namespace="http://Leadtools.Services.Barcode.DataContracts/2009/01", Name="BarcodeWriteQr")>
Public Class BarcodeWriteQr
[DataContractAttribute(Namespace="http://Leadtools.Services.Barcode.DataContracts/2009/01", Name="BarcodeWriteQr")]
public ref class BarcodeWriteQr
The QR standard specifies 40 different sizes of the QR code and the maximum data capacity will vary depending on the size and Error Correction level. The table below lists the maximum data capacity for each ECC level and encoding scheme.
For a table containing information useful when writing QR barcode data see https://www.leadtools.com/sdk/barcode/qr-chart.
using Leadtools.Services;
using Leadtools.Services.Barcode.ServiceContracts;
using Leadtools.Services.Barcode.ServiceImplementations;
byte[] ConvertFromStringArray(string[] data)
{
if (data == null || data.Length == 0)
return null;
List<byte[]> list = new List<byte[]>();
ASCIIEncoding ascii = new ASCIIEncoding();
int length = 0;
for (int i = 0; i < data.Length; i++)
{
byte[] bytes = ascii.GetBytes(data[i]);
list.Add(bytes);
length += bytes.Length;
length++;
}
byte[] ret = new byte[length];
int index = 0;
for (int i = 0; i < list.Count; i++)
{
byte[] bytes = list[i];
bytes.CopyTo(ret, index);
index += bytes.Length + 1;
}
return ret;
}
public void BarcodeWriteQrExample()
{
BarcodeServiceClient client = new BarcodeServiceClient();
RawBinaryData sourceBinaryData = new RawBinaryData();
sourceBinaryData.Data = File.ReadAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "barcode1.tif"));
RasterConvertOptions convertOptions = new RasterConvertOptions();
convertOptions.Source = sourceBinaryData;
convertOptions.Destination = null;
convertOptions.Format = RasterImageFormat.RasPdf;
convertOptions.FirstPage = 1;
convertOptions.LastPage = 1;
convertOptions.BitsPerPixel = 24;
convertOptions.QualityFactor = 2;
LeadRectangle rc = new LeadRectangle();
rc.X = 100;
rc.Y = 100;
rc.Width = 0;
rc.Height = 0;
string[] barcodeText;
barcodeText = new string[1];
barcodeText[0] = "QR Default Size";
BarcodeData data = new BarcodeData();
data.Location = rc;
data.Data = ConvertFromStringArray(barcodeText);
BarcodeColor barColor = new BarcodeColor();
barColor.BarColor = "Black";
barColor.SpaceColor = "White";
Barcode1d bar1d = new Barcode1d();
BarcodeWritePdf barPDF = new BarcodeWritePdf();
BarcodeWriteDatamatrix barDM = new BarcodeWriteDatamatrix();
BarcodeWriteQr barQR = new BarcodeWriteQr();
barQR.EccLevel = BarcodeQrEccLevel.LevelL;
barQR.GroupNumber = 0;
barQR.GroupTotal = 0;
barQR.Justify = BarcodeJustifyFlags.Right;
barQR.XModule = 0;
WriteOptions options = new WriteOptions();
WriteBarcode2DQr qr = new WriteBarcode2DQr();
qr.Type = WriteBarcode2DQrType.Default;
qr.Data = data;
options.Add(qr);
WriteRequest request = new WriteRequest();
request.Code1d = bar1d;
request.CodeColor = barColor;
request.CodeDatamatrix = barDM;
request.CodePdf = barPDF;
request.CodeQr = barQR;
request.ConvertOptions = convertOptions;
request.TypeFlags = BarcodeMajorTypeFlags.BarcodesDatamatrixWrite;
request.Unit = BarcodeUnit.ScanlinesPerPixels;
request.WriteFlags = BarcodeWriteFlags.UseColors | BarcodeWriteFlags.Transparent | BarcodeWriteFlags.InitializationReader | BarcodeWriteFlags.DisableCompression;
request.WriteOptions = options;
WriteResponse response = client.Write(request);
if (response.Destination != null)
{
File.WriteAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "BarcodeWriteQR.Pdf"), (response.Destination as RawBinaryData).Data);
}
client.Close();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Imports Leadtools.Services
Imports Leadtools.Services.Barcode.ServiceContracts
Imports Leadtools.Services.Barcode.ServiceImplementations
Private Function ConvertFromStringArray(ByVal data As String()) As Byte()
If data Is Nothing OrElse data.Length = 0 Then
Return Nothing
End If
Dim list As New List(Of Byte())
Dim ascii As ASCIIEncoding = New ASCIIEncoding()
Dim length As Integer = 0
Dim i As Integer = 0
Do While i < data.Length
Dim bytes As Byte() = ascii.GetBytes(data(i))
list.Add(bytes)
length += bytes.Length
length += 1
i += 1
Loop
Dim ret As Byte() = New Byte(length - 1) {}
Dim index As Integer = 0
i = 0
Do While i < list.Count
Dim bytes As Byte() = list(i)
bytes.CopyTo(ret, index)
index += bytes.Length + 1
i += 1
Loop
Return ret
End Function
Public Sub BarcodeWriteQrExample()
Dim client As BarcodeServiceClient = New BarcodeServiceClient()
Dim sourceBinaryData As RawBinaryData = New RawBinaryData()
sourceBinaryData.Data = File.ReadAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "barcode1.tif"))
Dim convertOptions As RasterConvertOptions = New RasterConvertOptions()
convertOptions.Source = sourceBinaryData
convertOptions.Destination = Nothing
convertOptions.Format = RasterImageFormat.RasPdf
convertOptions.FirstPage = 1
convertOptions.LastPage = 1
convertOptions.BitsPerPixel = 24
convertOptions.QualityFactor = 2
Dim rc As LeadRectangle = New LeadRectangle()
rc.X = 100
rc.Y = 100
rc.Width = 0
rc.Height = 0
Dim barcodeText As String()
barcodeText = New String(0) {}
barcodeText(0) = "QR Default Size"
Dim data As BarcodeData = New BarcodeData()
data.Location = rc
data.Data = ConvertFromStringArray(barcodeText)
Dim barColor As BarcodeColor = New BarcodeColor()
barColor.BarColor = "Black"
barColor.SpaceColor = "White"
Dim bar1d As Barcode1d = New Barcode1d()
Dim barPDF As BarcodeWritePdf = New BarcodeWritePdf()
Dim barDM As BarcodeWriteDatamatrix = New BarcodeWriteDatamatrix()
Dim barQR As BarcodeWriteQr = New BarcodeWriteQr()
barQR.EccLevel = BarcodeQrEccLevel.LevelL
barQR.GroupNumber = 0
barQR.GroupTotal = 0
barQR.Justify = BarcodeJustifyFlags.Right
barQR.XModule = 0
Dim options As WriteOptions = New WriteOptions()
Dim qr As WriteBarcode2DQr = New WriteBarcode2DQr()
qr.Type = WriteBarcode2DQrType.Default
qr.Data = data
options.Add(qr)
Dim request As WriteRequest = New WriteRequest()
request.Code1d = bar1d
request.CodeColor = barColor
request.CodeDatamatrix = barDM
request.CodePdf = barPDF
request.CodeQr = barQR
request.ConvertOptions = convertOptions
request.TypeFlags = BarcodeMajorTypeFlags.BarcodesDatamatrixWrite
request.Unit = BarcodeUnit.ScanlinesPerPixels
request.WriteFlags = BarcodeWriteFlags.UseColors Or BarcodeWriteFlags.Transparent Or BarcodeWriteFlags.InitializationReader Or BarcodeWriteFlags.DisableCompression
request.WriteOptions = options
Dim response As WriteResponse = client.Write(request)
If Not response.Destination Is Nothing Then
File.WriteAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "BarcodeWriteQR.Pdf"), (TryCast(response.Destination, RawBinaryData)).Data)
End If
client.Close()
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
Products |
Support |
Feedback: BarcodeWriteQr Class - Leadtools.Services.Barcode.DataContracts |
Introduction |
Help Version 19.0.2017.6.16
|
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.