Results 1 to 11 of 11

Thread: Cheque Leaf Printing problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2020
    Posts
    5

    Cheque Leaf Printing problem

    Can u provide me print button source code for study how to adjust the print scale and cheque leaf height and width

  2. #2

    Thread Starter
    New Member
    Join Date
    Jan 2020
    Posts
    5

    Re: cheque printing software

    Email Id sajikumarv2006 AT gmail.com. Please give me the source code vb6 for the print button for cheque leaaf
    Last edited by Shaggy Hiker; Jan 26th, 2020 at 09:46 PM. Reason: Altered email address.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,038

    Re: cheque printing software

    I edited your post to alter the email. You shouldn't post bare email addresses on a public forum. Most visitors are bots who would love to spam an email address.
    My usual boring signature: Nothing

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: cheque printing software

    how to adjust the print scale and cheque leaf height and width
    if they are single page cheque, then you do not need to height or width, just print positions and send .newpage or .enddoc to printer
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2020
    Posts
    5

    Re: cheque printing software

    Quote Originally Posted by westconn1 View Post
    if they are single page cheque, then you do not need to height or width, just print positions and send .newpage or .enddoc to printer
    Thanks for your fast reply. i had done cheque printing software.. and printing successfully. but some printer alignment not matching with the alighment.

    I put cheque in the center of paper tray. ( inside the scale for tighten the cheque ) .
    KIndly inform me how to set the printerscale, currentX and currentY

    Thanks
    Sajikumar

  6. #6

    Thread Starter
    New Member
    Join Date
    Jan 2020
    Posts
    5

    Cheque Leaf Printing problem

    Hai Dear(s) , I am a biggener in vb6 . I am pasting below my print button source code. It is printing perfectly.
    But the problem , settings are ok which i tested printer[ HP LASERJET PRO M12w ] . But printing to another printer
    { Hp color lazerjet CP2025 } printing started from left more than the assigned currentX . For Eg. If assigned location 3.6 inch *1440 but printing from left 1.5 inch *1440.

    Can i know what is the problem !!!

    Expecting your reply , hope you can uderstand my doubt


    ------------------ my code below -------------------
    Code:
    Dim x, y As String
    Dim Ans As String
    If Err.Number = 0 Then
    
    Dim ans1 As String
    MSFlexGrid1.Row = IL
    
    NSTRG = "C_NAME='" & Trim(Combo1.Text) & "'"
    RScompany.MoveFirst
    RScompany.Find NSTRG
    If RScompany.EOF = False Then
    Set Rsbank = New ADODB.Recordset
    Rsbank.Open "SELECT * FROM BANKMASTER WHERE bankname='" & Trim(Combo2.Text) & "'", Dbname, adOpenDynamic, adLockOptimistic
    
    If Rsbank.EOF = False Then
    
    Dim mMaxLen As Integer, mtmpLen As Integer
    Dim mtopmgn As Integer, mleftmgn As Integer, mbottommgn As Integer
    Dim Ax As Integer
    Dim Ay As Integer
    
    
    ' Setting a printer's Height or Width property automatically sets
    ' PaperSize to vbPRPSUser. Below 8.5 etc are inch, for this example
    Dim Chh As Integer
    Dim Chw As Integer
    Printer.Width = Rsbank!leafWidth * 1440 ' 1 in=1440 , 1cm=567twips
    Printer.Height = Rsbank!leafHeight * 1440
    Printer.Orientation = 2
    Chw = Rsbank!leafWidth * 1440 ' Width
    Chh = Rsbank!leafHeight * 1440 ' Height
    
    mtopmgn = 1440
    mleftmgn = 1440
    mbottommgn = (Printer.ScaleTop + Printer.ScaleHeight) - 1.2 * 1440
    Printer.FontName = "Arial" ' Font used for coordinates
    Printer.FontSize = 11
    Printer.FontBold = False
    'Printer.CurrentY = mtopmgn
    Printer.CurrentY = (Printer.ScaleHeight / 2) - (Chw / 2) - 180 ' top margin as per cheque leaf
    
    Ay = Printer.CurrentY
    Ax = ((Printer.ScaleWidth) / 2) - (Chh / 2)
    
    Printer.Print "" ' Initialize printer
    With MSFlexGrid1
    ' For I = 1 To (Rsbank!Racpayee)
    ' Printer.Print
    ' Next I
    Printer.CurrentY = Ay + (Rsbank!racpayee * 1440) ' rsacpayee= 3.6 inch
    
    If Check5.Value = 1 Then ' print account payee
    If Val(.TextMatrix(IL, 8)) = 1 Then ' print account payee seal
    'Printer.ForeColor = RGB(255, 0, 0)
    Printer.FontName = Rsbank!apfontname
    Printer.FontSize = Rsbank!apfontsize
    Printer.CurrentX = Ax + (Rsbank!Cacpayee * 1440) ' Left Margin
    '*************************************************** to be edit
    Printer.FontBold = Rsbank!apfontbold
    Printer.Print "_______________"
    Printer.FontUnderline = True
    Printer.CurrentX = Ax + (Rsbank!Cacpayee * 1440) ' Left Margin
    Printer.Print "A/C PAYEE ONLY";
    Printer.FontUnderline = False
    'Printer.ForeColor = RGB(0, 0, 0)
    Else
    Printer.Print
    Printer.Print
    End If
    Else
    Printer.Print
    Printer.Print
    End If
    Printer.FontName = Rsbank!dfontname
    Printer.FontSize = Rsbank!dfontsize
    Printer.FontBold = Rsbank!dfontbold
    
    If Check1.Value = 1 Then ' print date
    Printer.CurrentY = Ay + (Rsbank!rdt * 1440)
    If IsDate(Format(.TextMatrix(IL, 0), "dd-mm-yyyy")) Then
    Dim pc As Double
    Dim dtstr, dtstr1 As String
    dtstr = Trim(Format(.TextMatrix(IL, 0), "dd-mm-yyyy"))
    dtstr1 = ""
    pc = 0
    If Rsbank!printwspace = 1 Then ' if date printing with column wise
    
    For pc = 1 To Len(dtstr)
    If Mid(dtstr, pc, 1) <> "-" And Mid(dtstr, pc, 1) <> "/" Then
    dtstr1 = dtstr1 + Mid(dtstr, pc, 1) + Space(Rsbank!datespace)
    End If
    Next
    Printer.CurrentX = Ax + (Rsbank!CDT * 1440) ' Left Margin
    Printer.Print dtstr1
    Else
    Printer.CurrentX = Ax + (Rsbank!CDT * 1440) ' Left Margin
    Printer.Print .TextMatrix(IL, 0)
    End If
    Else
    Printer.Print
    End If
    Else
    Printer.Print
    End If
    
    'For I = 1 To Rsbank!rchn
    ' Printer.Print
    'Next I
    'print only date then go to finsih
    If Check1.Value = 1 And Check2.Value = 0 And Check3.Value = 0 Then
    GoTo abc
    End If
    'printing cheque name
    a1 = ""
    a2 = ""
    ans1 = Trim(.TextMatrix(IL, 3))
    
    Printer.FontName = Rsbank!pnfontname
    Printer.FontSize = Rsbank!pnfontsize
    Printer.FontBold = Rsbank!pnfontbold
    
    Printer.CurrentY = Ay + (Rsbank!rchn * 1440) 'position for printing cheque name
    If Check2.Value = 1 Then
    If Len(ans1) > 45 Then
    Printer.FontSize = 10
    Printer.CurrentX = Ax + (Rsbank!Cchn * 1440) 'position for printing cheque name
    Printer.Print ans1 ' OLD column increased only 4 instead off 11
    Else
    'Printer.FontSize = 11
    Printer.CurrentX = Ax + (Rsbank!Cchn * 1440) 'position for printing cheque name
    Printer.Print ans1
    End If
    End If
    Printer.FontSize = 11
    'Printer.FontBold = False
    ' prepare amount in words and store two line in seperate variable
    If Check3.Value = 1 Then
    If Val(MSFlexGrid1.TextMatrix(IL, 5)) > 0 Then
    ans1 = SpellNumber(.TextMatrix(IL, 5), Rsbank!CURNAME, Rsbank!COINNAME)
    ans1 = StrConv(ans1, 1) ' 1= Full capital letter, 3 = all first letter capital letter
    'ans1 = UCase(Left(ans1, 1)) + Mid(ans1, 2, Len(ans1)) ' to make first letter only Caps
    ' For I = 1 To Rsbank!rwords
    ' Printer.Print
    ' Next I
    a1 = ""
    a2 = ""
    If Len(ans1) > Rsbank!RwordsL Then
    For I = 0 To Rsbank!RwordsL
    If Mid(ans1, Rsbank!RwordsL - I, 1) = " " Then
    Exit For
    End If
    Next I
    a1 = Left(ans1, Rsbank!RwordsL - I)
    a2 = Mid(ans1, (Rsbank!RwordsL - I) + 1, Len(ans1))
    Else
    a1 = ans1
    End If
    ' Printer.FontSize = 10
    Printer.FontName = Rsbank!awfontname
    Printer.FontSize = Rsbank!awfontsize
    Printer.FontBold = Rsbank!awfontbold
    
    Printer.CurrentY = Ay + (Rsbank!rwords * 1440)
    Printer.CurrentX = Ax + (Rsbank!CWORDS * 1440) 'position for printing
    Printer.Print a1
    Printer.CurrentY = Ay + (Rsbank!ramt * 1440)
    'Printer.FontSize = 10
    ' decimal space more than 2 it should devided by 1000 else devided by 100
    
    If InStr(Val(.TextMatrix(IL, 5)), ".") > 0 And Len(Trim(Mid(.TextMatrix(IL, 5), InStr(Val(.TextMatrix(IL, 5)), ".") + 1, 3))) > 2 Then
    Printer.CurrentX = Ax + (Rsbank!CAMT * 1440) 'position for printing
    Printer.Print Rsbank!amtprifix; Format(Val(.TextMatrix(IL, 5)), "##,##,###,##0.000"); Rsbank!amtprifix
    Else
    Printer.CurrentX = Ax + (Rsbank!CAMT * 1440) 'position for printing
    Printer.Print Rsbank!amtprifix; Format(Val(.TextMatrix(IL, 5)), "##,##,###,##0.00"); Rsbank!amtprifix
    End If
    'Printer.FontSize = 10
    Printer.FontName = Rsbank!a***ontname
    Printer.FontSize = Rsbank!a***ontsize
    Printer.FontBold = Rsbank!a***ontbold
    
    Printer.CurrentY = Ay + (Rsbank!rwords2 * 1440)
    Printer.CurrentX = Ax + (Rsbank!Cwords2 * 1440) 'position for printing
    Printer.Print a2
    'Printer.FontSize = 10
    If Rsbank!Rguar > 0 And Rsbank!cguar > 0 And .TextMatrix(IL, 12) = "รพ" Then
    Printer.CurrentY = Ay + (Rsbank!Rguar * 1440)
    
    Printer.FontSize = 10
    Printer.CurrentX = Ax + (Rsbank!cguar * 1440) 'position for printing
    Printer.Print "GUARANTEE CHEQUE"
    End If
    
    End If ' If amount more than 0
    End If
    End With
    abc:
    Printer.Font = 11
    Printer.Print
    ' Printer.Line (0, Printer.CurrentY)-(7, Printer.CurrentY), BF
    'Printer.NewPage
    Printer.CurrentY = mtopmgn
    Printer.EndDoc
    End If
    End If
    End If
    
    End Function
    ----------------- end code ------------------
    Last edited by Shaggy Hiker; Jan 28th, 2020 at 04:11 PM. Reason: Added CODE tags.

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Cheque Leaf Printing problem

    use code tags when posting code, makes it much easier to read

    the user should be able to edit the database to adjust the print positions, there is always some trial and error with different printers

    check for default printer margins in control panel, as these may change position on page, though with VB left printing position on a new line should always be 0
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,038

    Re: Cheque Leaf Printing problem

    [CODE][/CODE] tags can be added using the # button. Highlight the code, then press the button, or press the button first, then paste the code between the tags.
    My usual boring signature: Nothing

  9. #9
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: Cheque Leaf Printing problem

    Different Printers may have slightly different maximum print areas and so their top, left print starting points may vary a little. A printout from one printer may not align exactly with one produced by another. Adjustment of exact print position is usually offered in commercial software for the production of CD Labels etc.

    A couple of tips when printing on paper;
    1) Use Printer.ScaleMode vbCentimeters, vbMillimeters, or vbInches at the top of the printing code and then you will be able to use the exact dimensions as specified on a physical ruler.eg.
    Code:
    Printer.ScaleMode vbInches
    Printer.Line(1,1)-(2,2)
    Printer.CurrentX= 5
    Printer CurrentY= 6
    Printer.Print "Hello"
    Will give you a 1 inch square 1 inch down from the top and 1 inch in from the left. And a string starting at 6 inches from the top and 5 inches from the left. Currently, from all the 1440s in your code, I suspect you are currently using Printer.ScaleMode.vbTwips which is probably the default. It is much more intuitive to use physical units when printing, I usually use vbCentimeters.

    2) It is sometimes good to be able to control the top and left margins as in your case. While you cannot increase the printer's maximum print area you can make these margins effectively larger by using Printer.Scale as in;
    Code:
    Printer.ScaleMode vbInches
    Printer.Scale(-1, 0)-(Printer.ScaleWidth - 1, Printer.ScaleHeight)
    Which should set the Left Margin to 1 inch i.e. the x coordinate point the printer cursor returns to when you print a carriage return or do a Printer.CurrentX=0. This makes it easy to tweak the existing Left/Top margin (as in your case) or arrange for indented sections of text in the printout without having too many Printer.CurrentXs in the code.

    Hope this helps

  10. #10
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,064

    Re: Cheque Leaf Printing problem

    Hello, try subtracting the non printable area of the printer from the CurrentX and CurrentY positions:

    Code:
    Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex As Long) As Long
    Private Const PHYSICALOFFSETX As Long = 112
    Private Const PHYSICALOFFSETY As Long = 113
    Code:
        NonPrintableAreaLeft = Printer.ScaleX(GetDeviceCaps(Printer.hDC, PHYSICALOFFSETX), vbPixels, Printer.ScaleMode)
        NonPrintableAreaTop = Printer.ScaleY(GetDeviceCaps(Printer.hDC, PHYSICALOFFSETY), vbPixels, Printer.ScaleMode)

  11. #11

    Thread Starter
    New Member
    Join Date
    Jan 2020
    Posts
    5

    Re: Cheque Leaf Printing problem

    Quote Originally Posted by Magic Ink View Post
    Different Printers may have slightly different maximum print areas and so their top, left print starting points may vary a little. A printout from one printer may not align exactly with one produced by another. Adjustment of exact print position is usually offered in commercial software for the production of CD Labels etc.

    A couple of tips when printing on paper;
    1) Use Printer.ScaleMode vbCentimeters, vbMillimeters, or vbInches at the top of the printing code and then you will be able to use the exact dimensions as specified on a physical ruler.eg.
    Code:
    Printer.ScaleMode vbInches
    Printer.Line(1,1)-(2,2)
    Printer.CurrentX= 5
    Printer CurrentY= 6
    Printer.Print "Hello"
    Will give you a 1 inch square 1 inch down from the top and 1 inch in from the left. And a string starting at 6 inches from the top and 5 inches from the left. Currently, from all the 1440s in your code, I suspect you are currently using Printer.ScaleMode.vbTwips which is probably the default. It is much more intuitive to use physical units when printing, I usually use vbCentimeters.

    2) It is sometimes good to be able to control the top and left margins as in your case. While you cannot increase the printer's maximum print area you can make these margins effectively larger by using Printer.Scale as in;
    Code:
    Printer.ScaleMode vbInches
    Printer.Scale(-1, 0)-(Printer.ScaleWidth - 1, Printer.ScaleHeight)
    Which should set the Left Margin to 1 inch i.e. the x coordinate point the printer cursor returns to when you print a carriage return or do a Printer.CurrentX=0. This makes it easy to tweak the existing Left/Top margin (as in your case) or arrange for indented sections of text in the printout without having too many Printer.CurrentXs in the code.

    Hope this helps
    Dear Sir

    In my case my coding printer.scalemode is not active but active only printer.scale
    Name:  11.png
Views: 236
Size:  7.3 KB
    Once I check my coding while run time the value is not changing.

    Printer.Width = Rsbank!leafWidth * 1440 ' 1 in=1440 , 1cm=567twips Leafwidth = 3.5 * 1440 = 5040
    Printer.Height = Rsbank!leafHeight * 1440' LeafHeight =7.5 * 1440 = 10800

    Still it is shwoing the value of printer.width = 12240 and printer.height = 15840 while running time.
    Ie., printer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width