DrawBarcodeQrCode(String,BarcodeQREncodingMode,BarcodeQRErrorCorrectionLevel,Int32,Int32,Int32,Single,Single,Color,Color) Method
In This Topic
Draws a required QR Code onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space internally when manipulating with the symbol's fill and background colors you have specified.
The coordinates and the dimensions of the code symbol need to be set in the current units with respect to the currently located origin defined in the PDF document, related to the actual page, where the symbol is to be drawn. You can use the GetMeasurementUnit method to determine the currently defined units and you can use the SetMeasurementUnit method to reset the units according to your preference.
Syntax
'Declaration
Public Overloads Function DrawBarcodeQrCode( _
ByVal As String, _
ByVal As BarcodeQREncodingMode, _
ByVal As BarcodeQRErrorCorrectionLevel, _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Single, _
ByVal As Single, _
ByVal As Color, _
ByVal As Color _
) As GdPictureStatus
public GdPictureStatus DrawBarcodeQrCode(
string ,
BarcodeQREncodingMode ,
BarcodeQRErrorCorrectionLevel ,
int ,
int ,
int ,
float ,
float ,
Color ,
Color
)
public function DrawBarcodeQrCode(
: String;
: BarcodeQREncodingMode;
: BarcodeQRErrorCorrectionLevel;
: Integer;
: Integer;
: Integer;
: Single;
: Single;
: Color;
: Color
): GdPictureStatus;
public function DrawBarcodeQrCode(
: String,
: BarcodeQREncodingMode,
: BarcodeQRErrorCorrectionLevel,
: int,
: int,
: int,
: float,
: float,
: Color,
: Color
) : GdPictureStatus;
public: GdPictureStatus DrawBarcodeQrCode(
string* ,
BarcodeQREncodingMode ,
BarcodeQRErrorCorrectionLevel ,
int ,
int ,
int ,
float ,
float ,
Color ,
Color
)
public:
GdPictureStatus DrawBarcodeQrCode(
String^ ,
BarcodeQREncodingMode ,
BarcodeQRErrorCorrectionLevel ,
int ,
int ,
int ,
float ,
float ,
Color ,
Color
)
Parameters
- Data
- The data to encode using the required QR Code symbol.
- EncodingMode
- A member of the BarcodeQREncodingMode enumeration. The QR Code encoding mode.
- ErrorCorrectionLevel
- A member of the BarcodeQRErrorCorrectionLevel enumeration. The error correction level.
These levels are defined in terms of percentage of codewords in the barcode that can be corrected if damaged. The higher the level, the greater the error correction, but also the larger the QR Code version.
- Version
- The version of the QR Code, it specifies the overall dimensions of the symbol.
QR Codes can be generated in 40 different symbol versions, from 21 x 21 modules (version 1) to 177 x 177 modules (version 40), therefore the range for this parameter is 0 - 40. You can use 0 to let the engine decide the minimum version required to encode all specified data.
- QuietZone
- The number of modules composing the quiet zone.
The quiet zone is the margin area around the QR Code symbol, that does not contain any information. It separates the symbol from its surroundings. Specifically, QR Code requires a four-module wide margin at all four sides of a symbol.
- ModuleSize
- The size of each module within the drawn symbol, in points.
The module is the smallest cell in the symbol. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
Specifically for QR Codes, the larger the module is, the more stable and easier to read with a QR Code scanner it becomes. On the other hand, as the QR Code symbol size gets larger, a larger printing area is required.
- DstX
- The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
- DstY
- The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
- FillColor
- A color object that defines the color to be used for drawing a required QR Code symbol.
- BackColor
- A color object that defines the color to be used for drawing a background behind the QR Code symbol.
Return Value
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Example
How to draw various QR Codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeQrCode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, Color.Chocolate, Color.Yellow) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, Color.Chocolate, Color.Yellow) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 8, 12, 2, Color.Chocolate, Color.Yellow) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 2, 12, Color.Yellow, Color.Chocolate) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 3, 4, 6, 12, Color.Yellow, Color.Chocolate) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 8, 12, 12, Color.Yellow, Color.Chocolate) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeQrCode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, Color.Chocolate, Color.Yellow) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, Color.Chocolate, Color.Yellow) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 8, 12, 2, Color.Chocolate, Color.Yellow) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 2, 12, Color.Yellow, Color.Chocolate) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 3, 4, 6, 12, Color.Yellow, Color.Chocolate) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 8, 12, 12, Color.Yellow, Color.Chocolate) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Example
How to draw various QR Codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeQrCode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, Color.Chocolate, Color.Yellow) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, Color.Chocolate, Color.Yellow) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 8, 12, 2, Color.Chocolate, Color.Yellow) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 2, 12, Color.Yellow, Color.Chocolate) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 3, 4, 6, 12, Color.Yellow, Color.Chocolate) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 8, 12, 12, Color.Yellow, Color.Chocolate) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeQrCode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, Color.Chocolate, Color.Yellow) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, Color.Chocolate, Color.Yellow) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 8, 12, 2, Color.Chocolate, Color.Yellow) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 2, 12, Color.Yellow, Color.Chocolate) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 3, 4, 6, 12, Color.Yellow, Color.Chocolate) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 8, 12, 12, Color.Yellow, Color.Chocolate) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
See Also
Reference
GdPicturePDF Class
GdPicturePDF Members
Overload List
GetMeasurementUnit Method
SetMeasurementUnit Method
SetMeasurementUnit Method
SetOrigin Method
GetMeasurementUnit Method
GetOrigin Method
DrawBarcode1D(Barcode1DWriterType,String,Single,Single,Single,Single,Byte,Byte,Byte) Method
DrawBarcodeAztec(String,BarcodeAztecCodeVersion,Int32,Int32,Int32,Single,Single,Byte,Byte,Byte) Method
DrawBarcodeDataMatrix(String,BarcodeDataMatrixEncodingMode,BarcodeDataMatrixVersion,Int32,Single,Single,Byte,Byte,Byte) Method
DrawBarcodeMicroMicroQrCode(String,BarcodeQREncodingMode,BarcodeMicroQRErrorCorrectionLevel,Int32,Int32,Single,Single,Color) Method
DrawBarcodePDF417(String,BarcodePDF417EncodingMode,BarcodePDF417ErrorCorrectionLevel,Int32,Int32,Int32,Int32,Single,Single,Byte,Byte,Byte) Method