Hi,
Try These Functions
AddForm(hPrinter, nLevel, pForm) To Add a new Form To your printer,
you should declare a function like this
Private Declare Function AddForm Lib "winspool.drv" Alias "AddFormA" (ByVal hPrinter As IntPtr, ByVal Level As Integer, ByRef pForm As Byte) As Integer
and then define a structure Form_Info_1
Public Structure FORM_INFO_1
Dim Flags As Integer
Dim pName As String
Dim Size As SIZEL
Dim ImageableArea As RECTL
End Structure
Dim frmInf As FORM_INFO_1
ReDim arByte() As Byte
With frmInf
.Flags = 0
.pName = "MiCustomForm"
.Size.cx = 160000
.Size.cy = 250000
End With
you have to copy the structure to a byte array
ReDim arByte(Marshal.SizeOf(frmInf))
Marshal.Copy(frmInf, arByte, 0, Marshal.SizeOf(frmInf))
And Finally Call Then Function
Dim hPrinter As IntPtr
Dim defaultSetting As IntPtr
Dim PrnVar As System.Drawing.Printing.PrintDocument = New System.Drawing.Printing.PrintDocument
If OpenPrinter(PrnVar.PrinterSettings.PrinterName, hPrinter, defaultSetting) Then
Try
retVal = AddForm(hPrinter, 1, arByte(0))
Catch ex As Exception
MsgBox(ex.Message)
End Try
ClosePrinter(hPrinter)
End If