borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Printing reciept in VB)Next Topic (how to open cash drawer) New Topic New Poll Post Reply
AndreaVB Forum : Printing : Printer Doesn't Eject paper
Poster Message
sm_ashiq
Level: Protégé

Registered: 01-07-2005
Posts: 4

icon Printer Doesn't Eject paper

Hi friend, I use my programme to print a sales invoice in my dot matrix printer (tvs msp 250 champion).

first i write things to text file and i print the file throu API.

But the problem is the printer stops on the last line and paper never comes out.

"paper tear" feature is enabled in my printer and it works while printing in windows mode.

i think that i miss some code.

when i give code "vbformfeed" printer eject the paper 3.6"

i use roll pape the paper size depends up on number of items in the invoice.

This is the code, please help me to solve my problem

Option Explicit
Private Type DOCINFO
    pDocName As String
    pOutputFile As String
    pDatatype As String
End Type

Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long

Private Declare Function EndDocPrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long

Private Declare Function EndPagePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long

Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As Long) As Long

Private Declare Function StartDocPrinter Lib "winspool.drv" Alias "StartDocPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, pDocInfo As DOCINFO) As Long

Private Declare Function StartPagePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long

Private Declare Function WritePrinter Lib "winspool.drv" (ByVal hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, pcWritten As Long) As Long

Private Sub Command1_Click()
Dim lhPrinter As Long
Dim lReturn As Long
Dim lpcWritten As Long
Dim lDoc As Long
Dim sWrittendata As String
Dim MyDocInfo As DOCINFO
Dim Fname

Printer.PaperSize = 256
Printer.Height = 3

Fname = "G:\check\invoice.txt"

lReturn = OpenPrinter("TVS MSP 250/Champion/XL Classic", lhPrinter, 0)
If lReturn = 0 Then
MsgBox "The printer Name you typed wasn't recognised."
Exit Sub
End If

MyDocInfo.pDocName = "Ashiq"
MyDocInfo.pOutputFile = vbNullString
MyDocInfo.pDatatype = vbNullString

lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
Call StartPagePrinter(lhPrinter)

If (lDoc = 0) Then
sWrittendata = Fname
Exit Sub
End If

Open Fname For Input As #1

sWrittendata = ""

While Not EOF(1)
    Line Input #1, sWrittendata
    sWrittendata = sWrittendata + Chr(13) + Chr(10)
   lReturn = WritePrinter(lhPrinter, ByVal sWrittendata, Len(sWrittendata), lpcWritten)
Wend
  
sWrittendata = vbCrLf & vbFormFeed
lReturn = WritePrinter(lhPrinter, ByVal sWrittendata, Len(sWrittendata), lpcWritten)

lReturn = EndPagePrinter(lhPrinter)
lReturn = EndDocPrinter(lhPrinter)
lReturn = ClosePrinter(lhPrinter)
Close #1


End Sub

thank you

05-07-2005 at 06:35 AM
View Profile Send Email to User Show All Posts | Quote Reply
giri
Level: Trainee

Registered: 23-01-2006
Posts: 1
icon Re: Printer Doesn't Eject paper

Hello Ashiq,
                    this is Giri. I am also using TVS Proton dotmatrix printer for billing and roll paper to take a printout but I am facing problem entirely opposite to you. I am reading values from the textbox, listboxes on the vb form and printing. My default paper setting is 8*6. So, if my bill contains less items remaining space in 8*6 page is skipped out from the printer. If my bill contains large items then, leaving some page break in my roll paper and print takes place for remaining items again skipping out remaining space. So i need no space should be  skippedout after printer ends printing and no space should be leaved as page break until printer finishes printing. How to do this in VB 6.0? Is there any printer funtions to do this?? If anyone have idea about this please let me know immediately.



____________________________
With Regards,
P.Mohan Giri

23-01-2006 at 01:42 PM
View Profile Send Email to User Show All Posts | Quote Reply
nappel
Level: Protégé

Registered: 06-12-2004
Posts: 6
icon Re: Printer Doesn't Eject paper

I'm use Word as COM for editing and printing documents.
No problems.



____________________________
http://word.oflameron.ru

04-04-2006 at 06:09 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : Printing : Printer Doesn't Eject paper
Previous Topic (Printing reciept in VB)Next Topic (how to open cash drawer) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder