BarcodeTools.com
Professional BarCode Software
Home
Barcode ActiveX
DataMatrix ActiveX
PDF417 ActiveX
MaxiCode ActiveX
QRCode ActiveX
Barcode .NET
DataMatrix .NET
PDF417 .NET
Barcode ASP.NET
DataMatrix ASP.NET
PDF417 ASP.NET
ISAPI
CGI
LabelBar(Pro)
Console Apps
Barcode Recognition
Order
FAQs
Flash Tutorials
Support
Barcode Types
Search
Home arrow PDF417 ActiveX arrow FAQs arrow Programming
Programming FAQ

Programming FAQ

How to create an invisible PDF417 ActiveX in Visual Basic?

How to print a PDF417 barcode from Visual Basic?



How to create an invisible PDF417 ActiveX in Visual Basic?

For the Barcode ActiveX control to be used, there is no need to place it on a form as shown here. You can create an invisible PDF417 barcode control from any application including your DLL.
The first thing needed in order to do it is to create an object using the CreateObject function (as shown below). After the object is created, you can use it as you want.
'Create a new instance of PDF417-ActiveX
Dim oPDF417 As Object
Set oPDF417 = CreateObject("PDF417ActiveX.PDF417Ctrl.1")

'set PDF417-ActiveX properties
oPDF417.DataToEncode = "Hello world"

'using PDF417-ActiveX
Call oPDF417.DrawPDF417ToSize(5, 5, 260, 150, dmPixels, Form1.hdc)

'destroy PDF417-ActiveX object
Set oPDF417 = Nothing



How to print a PDF417 barcode from Visual Basic?

There are a few different ways to print a barcode from Visual Basic using our ActiveX Control.
  1. Using a Visual Basic Printer object.

    Printer.CurrentX = 2048
    Printer.Print "BarcodeTools.com, VB Example"


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

    'print two barcodes
    Call PDF417Ctrl1.DrawPDF417ToSize(10, 10, 30, 30, dmMM)
    Call PDF417Ctrl1.DrawPDF417ToSize(70, 10, 30, 30, dmMM)

    Printer.EndDoc



  2. Using PDF417-ActiveX methods.

    'open a current printer
    Call PDF417Ctrl1.BeginPrint("")

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

    Call PDF417Ctrl1.EndPrint



  3. How to print a PDF417 barcode with a certain x-dimension?.

    To find out what x-dimension is, click here.
    To print a barcode with a certain x-dimension, you should correctly specify the barcode width. You can calculate it using the GetPDF417Size method.

    Private Declare Function GetDeviceCaps Lib "gdi32" _
    (ByVal hdc As Long, ByVal nIndex As Long) As Long
          
    Private Const LOGPIXELSX = 88
    Private Const LOGPIXELSY = 90
    
    Private Sub PrintBarcode()
        'Create a new instance of PDF417-ActiveX
        Dim oPDF417 As Object
        Set oPDF417 = CreateObject("PDF417ActiveX.PDF417Ctrl.1")
    
        'set PDF417-ActiveX properties
        oPDF417.DataToEncode = "Hello world"
        oPDF417.CompactionMode = 0
    
        'open a current printer
        Call oPDF417.BeginPrint("")
        
        'gets the printer resolution (dpi - dots per inch)
        Dim dpiX As Long, dpiY As Long
        dpiX = GetDeviceCaps(Printer.hdc, LOGPIXELSX)
        dpiY = GetDeviceCaps(Printer.hdc, LOGPIXELSY)
    
        'calculate the required PDF417 size (in mm) for the
        'x-dimension of 0.508 mm (20 Mils)
        Dim pdf417Width, pdf417Height
        Call oPDF417.GetPDF417Size(0.508, dpiX, dpiY, dmMM, dmMM, _
           pdf417Width, pdf417Height)
    
        'print a PDF417 barcode
        Call oPDF417.DrawPDF417ToSize(10, 10, pdf417Width, pdf417Height, _
           dmMM, 0)
    
        Call oPDF417.EndPrint
    
        Set oPDF417 = Nothing
    End Sub
    


 

  Home   Order   FAQs   Support   Search

Copyright © 1999-2010, RKD Software, All rights reserved.
All trademarks mentioned are the property of their respective owners.