Results 1 to 3 of 3

Thread: Printing Text File Direct To Printer

  1. #1
    Join Date
    May 2009
    Posts
    45

    Printing Text File Direct To Printer

    I wan to create an application where user can directly print any text File to printer without detecting the printer driver. When i ask my friend about it, he told me that we can do it by using some code in Visual basic, but he also don't know what are the snippet code for the same , i have also try to find it on internet but was not able to get any code. Does anyone can solve my problem.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Printing Text File Direct To Printer

    If you want to use print a text file in Visual Basic then you need to use printer.print command and also add the following code in your programming too.

    Code:
    Open "lpt2:" For Output As #1
    
    Print #1, "File to print"
    
    Close #1

  3. #3
    Join Date
    Jan 2009
    Posts
    113

    Printing Text File Direct To Printer

    You you want to use printer.print command in Visual Basic instead of that i would suggest you to use the below code

    Code:
    Sub PrintLpt1()
      Dim bf As String
       Dim vbEsc As String
      vbEsc = Chr$(29)
      
      'load string with escape codes
      bf = vbEsc & "A" & vbEsc & "A3H0000V0000" & vbEsc & "Z"
      bf = bf & vbEsc & "A" & vbEsc & "%2" & vbEsc & "H478" & vbEsc & "V105"
      bf = bf & vbEsc & "D302054205215670190"
      bf = bf & vbEsc & "H220" & vbEsc & "V105"
      bf = bf & vbEsc & "D302054205215670190"
      bf = bf & vbEsc & "%0" & vbEsc & "H294" & vbEsc & "V30"
      bf = bf & vbEsc & "FW02H0176"
      bf = bf & vbEsc & "H36" & vbEsc & "V30"
      bf = bf & vbEsc & "FW02H0176"
      bf = bf & vbEsc & "%3" & vbEsc & "H245" & vbEsc & "V42"
      bf = bf & vbEsc & "PS" & vbEsc & "$A,24,24,0" & vbEsc & "$=521567"
      bf = bf & vbEsc & "H501" & vbEsc & "V40"
      bf = bf & vbEsc & "$A,24,24,0" & vbEsc & "$=521567"
      bf = bf & vbEsc & "%2" & vbEsc & "H470" & vbEsc & "V30"
      bf = bf & vbEsc & "$A,38,32,0" & vbEsc & "$=RM 720.90"
      bf = bf & vbEsc & "H210" & vbEsc & "V30"
      bf = bf & vbEsc & "$A,38,32,0" & vbEsc & "$=RM 1.90"
      bf = bf & vbEsc & "H480" & vbEsc & "V128"
      bf = bf & vbEsc & "$A,24,24,0" & vbEsc & "$=ABCDEFGHIJKLMNOP"
      bf = bf & vbEsc & "H220" & vbEsc & "V128"
      bf = bf & vbEsc & "$A,24,24,0" & vbEsc & "$=1234567890ABCDEF"
      bf = bf & vbEsc & "Q1"
      bf = bf & vbEsc & "Z"
    
    
      Open "lpt1:" For Output As #1
    
      
      Print #1, bf
      Close #1
      
    End Sub

Similar Threads

  1. Replies: 2
    Last Post: 11-11-2011, 06:54 PM
  2. HP Officejet 7410 Printer via direct ethernet
    By Bon-hwa in forum Portable Devices
    Replies: 5
    Last Post: 04-09-2010, 06:12 AM
  3. Replies: 5
    Last Post: 16-03-2010, 04:51 AM
  4. help on turbo c++ printing text file
    By mstpin in forum Software Development
    Replies: 4
    Last Post: 23-07-2009, 10:18 AM
  5. scheduled printing of a text file using batch files or schtasks
    By Gadgetman in forum Windows XP Support
    Replies: 10
    Last Post: 12-06-2008, 11:48 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,880,931.36716 seconds with 16 queries