Methods Print E-mail

PDF417 BarCode ActiveX Methods



AboutBox Method
Opens an About window.

Syntax
object.AboutBox()
Return Value
No return value.



ShowProperties Method
Opens a custom properties of the PDF417 Barcode ActiveX Control.

Syntax
object.ShowProperties()
Return Value
No return value.



SaveToImageFile Method
Saves the image of the barcode to a file.

Syntax
object.SaveToImageFile(cx, cy, sFileName, [lRes,] [dm])
Parameters
cxA double that defines the barcode picture width.
cyA double that defines the barcode picture height.
sFileNameA string expression defining the file name.
lResOptional (default 0). A long value that sets the picture resolution.
dmOptional (default dmPixels). This value defines the units that should be used to specify cx and cy. See remarks.
Return Value
No return value.
Remarks
The format the file will be saved in depends on the extension of the file name For example, if you specify sFileName as "img1.jpg", the barcode will be saved as JPEG.
The following extensions can be used - "wmf", "emf", "bmp", "jpg", "jpeg", "gif", "tiff" and "png".

The dm parameter may has the following values:
dmMils = 0, mils(0.001 inches)
dmInches = 1, inches
dmMM = 2, millimeters
dmPixels = 3, pixels

If the size of an image (cx, cy) is not specified in pixels, its actual size will be calculated using the specified picture resolution - lRes.

Warning! For this method to function properly, you should have the GDI+ library (gdiplus.dll) installed on your PC, this library is distributed with Windows XP and higher. if you do not have this library, you can download it here, and copy it to the folder "../Windows/System32/".
Examples
'1.
'Save the image to a file of the JPEG format. The size of the image will be 260x70 pixels with the resolution of 96 dpi.

Call PDF417Ctrl1.SaveToImageFile(260, 70, "c:\pdf417.jpg")

'2.
'Save the image to a file of the JPEG format. The size of the image will be 30x15 millimeters with the resolution of 300 dpi.

Call PDF417Ctrl1.SaveToImageFile(30, 15, "c:\pdf417.jpg", 300, dmMM)



PartialWritePicture Method
Saves the barcode to an existing image file. The barcode can occupy just the part of the image file it needs.

Syntax
object.PartialWritePicture(sFileName, x, y, width, height)
Parameters
sFileNameA string expression defining the file name.
xAn integer value that defines the X coordinate of the barcode.
yAn integer value that defines the Y coordinate of the barcode.
widthAn integer that defines the barcode width.
heightAn integer that defines the barcode height.
Return Value
No return value.
Remarks
The image file defined by the sFileName parameter can be of the following formats: "bmp", "jpg", "jpeg", "gif", "tiff" and "png".
Examples
Call PDF417.PartialWritePicture("c:\1.jpg", 10, 10, 130, 40)

PDF417 Barcode ActiveX saves the barcode image into the existing picture file

You can use this method to add a barcode to any of your image files. This barcode can be used to identify the file or serve other purposes.



CopyToClipboard Method
Copies the image of the barcode onto the clipboard. After that you can insert this image into your program using Ctrl+V or the Paste menu item.

Syntax
object.CopyToClipboard(cx, cy)
Parameters
cxAn integer value that defines the barcode picture width
cyAn integer value that defines the barcode picture height
Return Value
No return value.



DrawPDF417ToSize Method
Draws the PDF417 barcode in the device context. You can use either printer or screen as the device context.

Syntax
object.DrawPDF417ToSize(X, Y, CX, CY, dm, [hDC])

Parameters

XA double value that defines the X coordinate of the barcode.
YA double value that defines the Y coordinate of the barcode.
CXA double that defines the barcode width.
CYA double that defines the barcode height.
dmOptional (default dmPixels). This value defines the units that should be used to specify cx and cy. See here.
hDCOptional (default 0). The handle of the device context where the barcode will be drawn. If this parameter is not specified or set to zero, the printer device context will be used.

Return Value

No return value.
Examples
'Draw a PDF417 to a screen.
Call PDF417Ctrl1.DrawPDF417ToSize(0, 0, 270, 90, dmPixels, Form1.hDC)


'Print the PDF417 barcode
'Open a current printer

Call PDF417Ctrl1.BeginPrint("")

'print the PDF417 to X=10 mm, Y=10 mm, WIDTH=25 mm, HEIGHT=12 mm
Call PDF417Ctrl1.DrawPDF417ToSize(10, 10, 25, 12, dmMM)

Call PDF417Ctrl1.EndPrint



BeginPrint Method
Opens access to a printer.

Syntax
object.BeginPrint(sPrinterName)
Parameters
sPrinterNameA string value that defines the name of the printer. The name of the printer can be determined in the Printer folder of the Control Panel.
If the name is blank, the default printer will be opened.
Return Value
No return value.
Remarks
This function must be called first before other printing features are used.



EndPrint Method
Closes the printer. You cannot use any printing features after that.

Syntax
object.EndPrint()
Return Value
No return value.



NewPage Method
The StartPage function prepares the printer driver to accept data.

Syntax
object.NewPage()
Return Value
No return value.



EndPage Method
The EndPage function notifies the device that the application has finished writing to a page. This function is typically used to direct the device driver to advance to a new page.

Syntax
object.EndPage()
Return Value
No return value.



GetPrinterHDC Method
The function returns the handle of the printer previously opened with the help of the BeginPrint function.

Syntax
object.GetPrinterHDC()

Return Value
HDC



SetPrinterHDC Method
Defines the handle of the printer that will be used for printing. If this function is called, you do not have to call BeginPrint. In this case the entire process of closing/opening the printer, etc. will be controlled outside the PDF417 ActiveX Control.

Syntax
object.SetPrinterHDC(hDC)
Parameters
hDCValue that specifies the printer handle.
Return Value
No return value.
Example
Printer.CurrentX = 2048
Printer.Print "BarcodeControls.com, VB Example"

'PDF417-ActiveX will use the Visual Basic Printer object
Call PDF417Ctrl1.SetPrinterHDC(Printer.hDC)

'print the PDF417 barcodes
Call PDF417Ctrl1.DrawPDF417ToSize(10, 10, 30, 15, dmMM)
Call PDF417Ctrl1.DrawPDF417ToSize(70, 10, 30, 15, dmMM)

Printer.EndDoc



BinaryWritePicture Method
This method is similar to SaveToImageFile, but instead of saving the image to a file it represents it as a byte array.

Syntax
object.BinaryWritePicture(sFmt, CX, CY)

Parameters

sFmtString that specifies the file name extension.
The following extensions can be used - "wmf", "emf", "bmp", "jpg", "jpeg", "gif", "tiff" and "png".
CXA integer that defines the barcode width
CYA integer that defines the barcode height

Return Value

Variant that specifies safe array of the bytes.
Remarks
This method can be useful for sending the image over the Internet. For example, it can be used by the IIS server.

Warning! For this feature to function properly, you should have the GDI+ library (gdiplus.dll) installed on your PC, this library is distributed with Windows XP and higher. if you do not have this library, you can download it here, and copy it to the folder "../Windows/System32/".

Example
There is a short example of the ASP page distributed together with our PDF417-ActiveX Control.
<%
' pdf417.asp
' (c) 1999-2005 www.BarcodeControls.com

' we are sending a GIF image to the client
Response.ContentType = "image/gif"
Response.BinaryWrite Barcode.BinaryWritePicture("gif", 270, 100)

SET Barcode=nothing
%>
			
Note
This method requires the Server License.



GetPDF417Size Method
This method calculates the PDF417 size needed to get the module of the necessary size. Module is a single cell in a PDF417 symbology used to encode one bit of data.

Syntax
object.GetPDF417Size(module, xRes, yRes, dmIn, dmOut, width, height)
Parameters
moduleA double that defines the PDF417 module.
xResA long value that defines the resolution in dpi) along X axis.
yResA long value that defines the resolution in dpi) along Y axis.
dmInThis value defines the units that should be used to specify module.
dmOutThis value defines the units that should be used to specify width and height.
widthA variable that receives the PDF417 width.
heightA variable that receives the PDF417 height.
Examples
Print PDF417 with the module size of 40 Mils. The PDF417 must begin with X=10 mm, Y=10 mm
'open a current printer
Call PDF417Ctrl1.BeginPrint("")

'gets the printer resolution ( in dpi - dots per inch)
Dim dpiX As Long, dpiY As Long
dpiX = GetDeviceCaps(Printer.hdc, LOGPIXELSX)
dpiY = GetDeviceCaps(Printer.hdc, LOGPIXELSY)

'gets the required PDF417 width and height in units determined by the dmOut parameter
Dim Width, Height
Call PDF417Ctrl1.GetPDF417Size(40, dpiX, dpiY, dmMils, dmMM, Width, Height)

'prints the PDF417
Call PDF417Ctrl1.DrawPDF417ToSize(10, 10, Width, Height, dmMM)

'close the printer
Call PDF417Ctrl1.EndPrint


Save the PDF417 to a file so that the module is equal to 4 pixels.
'if dmIn and dmOut are specified in pixels, you do not have to specify the resolution (xRes, yRes), but it must not be equal to 0.
Dim Width, Height
Call PDF417Ctrl1.GetPDF417Size(4, 1, 1, dmPixels, dmPixels, Width, Height)

Call PDF417Ctrl1.SaveToImageFile(Width, Height, "c:\pdf417.bmp")



FreezeEncode Method
This method pauses or resumes encoding the PDF417. It makes sense to use this method in heavily loaded application, for example, web services, etc.

Syntax
object.FreezeEncode(bFreeze)
Parameters
bFreezeBoolean that specifies whether to pause encoding the PDF417 or not.
Return Value
No return value.
Example

You need to set several properties of the PDF417 control. Each time some properties are set (DataToEncode, CompactionMode, ErrorCorrectionLevel and others) the PDF417 is re-encoded, i.e. the Reed-Solomon codes are calculated, the PDF417 is build, etc. It takes a lot of CPU time. To improve the performance of the application, you can pause encoding and resume it only after all properties are set.
PDF417Ctrl1.FreezeEncode (True)
PDF417Ctrl1.DataToEncode = "1234567"
PDF417Ctrl1.CompactionMode = cmByte
PDF417Ctrl1.ErrorCorrectionLevel = ecl_2
PDF417Ctrl1.FreezeEncode (False)



 

Copyright (c) 1999-2013, VBC Software. All rights reserved.
All trademarks mentioned are the property of their respective owners