Hi everybody...
I need some help with printing in Visual Basic 2005: i have lots of customers that have dot-matrix printers, and, to be more specific, epson tm series of receipt printers (i have installed 1.61 epson tm windows driver). When i print using the PrintDocument, the output are beatiful, but painful slow. So, i want to print header of the receipt in the new fashion, but the rest of receipt (the data) in the traditional factory printerfont. I already studied the print powerpack, but only supports truetype fonts. Any idea? Thanks in advance to community. | | Bernardo Salazar Thursday, March 22, 2007 7:57 PM | The following code lists all the fonts that are supported by Printer Compatibility Library:
Dim Printer As New Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6.Printer
For i As Integer = 0 To Printer.FontCount - 1 Console.WriteLine(Printer.Fonts(i)) Next | | yfdong_MSFT Saturday, March 24, 2007 1:06 AM | Hi Mr. Yun.
Thanks for taking your time to reply my message.
I can comment that im aware of FontCount property. in fact, in my tests, i replaced console.writeline with a checkedlistbox, to see the available fonts. The problem consist that im very needed to print receipts in "text-mode", instead of "graphic" truetype mode. The readme clearly outlines "this powerpack only support truetype fonts", that are useless to me, 'cos graphics printing are very very slow in dot-matrix printers.Im translating a 10-year old DOSfoxpro program, to a new visual basic 2005/SQL 2005equivalent, but i find in visual basic 2005 print routines a big wall to accomplish my task, since my clients (some hundreds) will complain for printing speed (and that customers dont have planned to change the printers just 'cos the new software print slow). The powerpack its a step more to make swift change from old VB6 apps to new VB, but i think MSFT need to present a print powerpack 2.0 that supportsprinter-default fonts. Meanwhile... you have more ideas how to workaround this problem?
Thanks again for your patience.
Bernardo Salazar | | Bernardo Salazar Monday, March 26, 2007 8:49 PM | Trythis:
Imports Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6
Dim Printer As New Printer
Printer.PrintQuality = vbPRPQDraft
Printer.Print("Heading 1")
Printer.EndDoc
It still uses Truetype font, but it will be faster.
| | yfdong_MSFT Tuesday, March 27, 2007 6:57 AM | Hi,
In a shell or ( DOS ) command line window you can do this>>
| Here is the Shell ( Dos ) command that I wrote: |
|
Type C:\whateverPathToYourFile\myFile.txt > LPT1:
| |
Thisshould be faster if your printer is a parallel port one, it should use the default setting or current setting of the built in printer typeface - font.
I don't know if you can do this with a printer on one of the USB ports.
I don't know how to send a command like this to a shell window from VB.Net either.
Regards,
S_DS
| | John Anthony Oliver Tuesday, March 27, 2007 1:00 PM | Hi Mr Yun, greetings from Venezuela
I can comment that i already tried the print.printquality method, but i obtained a blank output. Also, i tried with PrinDocument's property DefaultPageSettings.PrinterResolution.Kind=Printing.PrinterResolutionKind.Draft, with the same result. As i imagine, dot-matrix printer driversdont have a "draft" mode. so, the driver don't understand what is draft, and simply print empty spaces.
The user spidermans suggested the use of DOS shell, i think that is a valid option, but, with a high-tech programming language like Visual Basic 2005, the use of shellto print a text file its like back to the cavern ages, and i dont like this type of "patches" in my programs. Its code elegance related thing. I think the code need to be beautiful inside (forthe programmer's pleasure), and outside (for user's easyness).
I will appreciate more ideas, but at this point im grateful for receiving your attention.
Bernardo Salazar | | Bernardo Salazar Tuesday, March 27, 2007 7:10 PM | Estimated spiderman's darkside
I feel grateful for your interest in help me, i will take your advice in consideration, since not are a elegant solution, but in last instance...
In retribution, take note how to run external apps fron VB.NET
imports system.diagnostincs
...
...
Dim myProcess As System.Diagnostics.Process = New System.Diagnostics.Process()
myProcess.StartInfo.FileName = "calc.exe"
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
myProcess.Start()
Thanks again for your time.
Bernardo Salazar | | Bernardo Salazar Tuesday, March 27, 2007 8:07 PM |
| Bernardo Salazar wrote: |
|
Estimated spiderman's darkside
I feel grateful for your interest in help me, i will take your advice in consideration, since not are a elegant solution, but in last instance...
In retribution, take note how to run external apps fron VB.NET
imports system.diagnostincs
Dim myProcess As System.Diagnostics.Process = New System.Diagnostics.Process()
myProcess.StartInfo.FileName = "calc.exe"
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
myProcess.Start()
Thanks again for your time.
Bernardo Salazar
| |
Hi,
Process.Start method will run launch CMD.Exe but i've been unable to pass any argument(s) to it like
Process.Start( CMD.Exe, "Dir C:\")
it might be>>
Process.Start( "CMD.Exe", "Dir C:\")
i can't remember if 1st set of quotes are needed around the application name to Start.
Regards,
S_DS
| | John Anthony Oliver Thursday, March 29, 2007 12:44 AM | Type C:\whateverPathToYourFile\myFile.txt > LPT1: produced an error like aol missing?
| | VishnuMohan Thursday, August 30, 2007 6:45 AM |
| VishnuMohan wrote: |
Type C:\whateverPathToYourFile\myFile.txt > LPT1: produced an error like aol missing?
| |
Hi Vishnu,
That seems like a very odd error to me.
Regards,
S_DS
| | John Anthony Oliver Sunday, September 02, 2007 9:06 AM | I have same problem please help me
Hello
I have a problem in Printing in pre printed bill .
Bill Size
I am using
OS = Windows XP Visual Basic Enterprise Edition 6
Height : 6 inches Width of paper : 9.1 inches
I wish to print bill by bill, Pre printed stationery is continious paper, I wish to print in one bill after one bill the paper automatically skip to other bill.
Now the problem is after printing one bill paper skips two or more bills. I wish after printing first bill, second bill ......
I used three codes to print . But problem contious. There is no paper size in VB for my paper setting ( height 6 inches , width 9.1 inches)
the problem is : while printing the paper moves for A4/Letter and i cann't able to enable the Tear off Mode.
I am enclosing three codes please rectify my errors :
First code using vb printing ---------------------------------- Private Function printmethod() Dim cy As Long Dim cx As Long Dim tmpval As Double
Printer.ScaleMode = ScaleModeConstants.vbTwips
Printer.Width = 13104 Printer.Height = 8640
Printer.CurrentX = 9360 Printer.CurrentY = 2736 ' 2300 Printer.Print "Bill No: " & Bnotxt.Text Printer.CurrentX = 2880 '3160 Printer.CurrentY = 2304 Printer.Print cnametxt.Text 'Printer.Print "Customer Name : " & cnametxt.Text Printer.CurrentX = 2880 Printer.CurrentY = 2736 ' 2500 Printer.Print cptxt.Text 'Printer.CurrentX = 7200 'Printer.CurrentY = 2304 'Printer.Print "Bill Mode : " & btype 'Printer.CurrentX = 864 '1440 'Printer.CurrentY = 3312 'Printer.Print "Sno Product Name Grams Wastage Price M-Charge S-Charge Amount " Printer.CurrentX = 864 Printer.CurrentY = 3168 '3312 Printer.Print "S.NO" Printer.CurrentX = 1584 Printer.CurrentY = 3168 '3312 Printer.Print "PARTICULARS" Printer.CurrentX = 4064 Printer.CurrentY = 3168 ' 3312 Printer.Print "GRAMS" Printer.CurrentX = 5216 Printer.CurrentY = 3168 Printer.Print "WASTAGE" Printer.CurrentX = 6368 Printer.CurrentY = 3168 Printer.Print "RATE" Printer.CurrentX = 7376 Printer.CurrentY = 3168 Printer.Print "M.C" Printer.CurrentX = 8400 Printer.CurrentY = 3168 Printer.Print "S.C" Printer.CurrentX = 9400 Printer.CurrentY = 3168 Printer.Print "AMOUNT" Printer.FontBold = False Printer.FontSize = 10
cy = 3600 i = 1 While i <= sno mg1.Row = i mg1.Col = 0 Printer.CurrentX = 864 '1440 Printer.CurrentY = cy Printer.Print mg1.Text
Printer.CurrentX = 1584 '2160 Printer.CurrentY = cy mg1.Row = i mg1.Col = 2 Printer.Print mg1.Text
cx = 4064 '2900 Printer.CurrentY = cy mg1.Row = i mg1.Col = 3 '3 tmpval = Format(mg1.Text, "#0.000") Select Case Len(tmpval) Case 4 Printer.CurrentX = cx + 400 Case 5 Printer.CurrentX = cx + 300 Case 6 Printer.CurrentX = cx + 200 Case 7 Printer.CurrentX = cx + 100 Case 8 Printer.CurrentX = cx End Select Printer.Print mg1.Text
cx = 5216 '3800 Printer.CurrentY = cy mg1.Row = i mg1.Col = 5 '4 tmpval = Format(mg1.Text, "#0.000") Select Case Len(tmpval) Case 4 Printer.CurrentX = cx + 400 Case 5 Printer.CurrentX = cx + 300 Case 6 Printer.CurrentX = cx + 200 Case 7 Printer.CurrentX = cx + 100 Case 8 Printer.CurrentX = cx End Select Printer.Print mg1.Text
cx = 6360 '4750 - 6368 Printer.CurrentY = cy mg1.Row = i mg1.Col = 6 '5 tmpval = Format(mg1.Text, "#0.00") Select Case Len(tmpval) Case 4 Printer.CurrentX = cx + 500 Case 5 Printer.CurrentX = cx + 400 Case 6 Printer.CurrentX = cx + 300 Case 7 Printer.CurrentX = cx + 200 Case 8 Printer.CurrentX = cx + 100 Case 9 Printer.CurrentX = cx End Select Printer.Print mg1.Text
cx = 7376 '5600 Printer.CurrentY = cy mg1.Row = i mg1.Col = 7 '6 tmpval = Format(mg1.Text, "#0.00") Select Case Len(tmpval) Case 4 Printer.CurrentX = cx + 400 Case 5 Printer.CurrentX = cx + 300 Case 6 Printer.CurrentX = cx + 200 Case 7 Printer.CurrentX = cx + 100 Case 8 Printer.CurrentX = cx End Select Printer.Print mg1.Text
cx = 8400 '6500 Printer.CurrentY = cy mg1.Row = i mg1.Col = 8 '7 tmpval = Format(mg1.Text, "#0.00") Select Case Len(tmpval) Case 4 Printer.CurrentX = cx + 400 Case 5 Printer.CurrentX = cx + 300 Case 6 Printer.CurrentX = cx + 200 Case 7 Printer.CurrentX = cx + 100 Case 8 Printer.CurrentX = cx End Select Printer.Print mg1.Text '-- SEN DO cx = 9300 ' 7300 -9400 Printer.CurrentY = cy mg1.Row = i mg1.Col = 9 tmpval = Format(mg1.Text, "#0.00") Select Case Len(tmpval) Case 4 Printer.CurrentX = cx + 600 ' 600 Case 5 Printer.CurrentX = cx + 500 ' 500 Case 6 Printer.CurrentX = cx + 400 ' 400 Case 7 Printer.CurrentX = cx + 300 ' 300 Case 8 Printer.CurrentX = cx + 200 '200 Case 9 Printer.CurrentX = cx + 100 ' 100 Case 10 Printer.CurrentX = cx End Select mg1.CellAlignment = 3 Printer.Print mg1.Text i = i + 1 cy = cy + 300 Wend
Printer.FontBold = True Printer.FontSize = 9 Printer.CurrentX = 720 ' 6000 Printer.CurrentY = 7000 'cy + 300 'Printer.Print "Total Amount :" & tottxt.Text Printer.CurrentX = 2880 '6000 Printer.CurrentY = 7000 'cy + 600 Printer.Print "Discount : " & disctxt.Text Printer.CurrentX = 6000 Printer.CurrentY = 7000 ' cy + 900 Printer.Print vattxt.Text Printer.CurrentX = 9216 '6000 Printer.CurrentY = 7488 'cy + 1200 Printer.Print Netamttxt.Text 'Printer.Print "Net Amount : " & Netamttxt.Text Printer.EndDoc 'Printer.NewPage End Function
==================================================== 2. Second code creating Text file and printing =======================================================
Public Function txtprint() Dim bno As String Dim bdate As String cname = cnametxt.Text bdate = datetxt.Text place = cptxt.Text bno = Bnotxt.Text
Call modBillPrinter.OpenPrintFile Call modBillPrinter.PrintPLine(Chr(12)) 'Call modBillPrinter.PrintPLine(Chr(12)) 'Call modBillPrinter.PrintPLine(Chr(12)) 'Call modBillPrinter.PrintPLine(Chr(12))
Call modBillPrinter.PrintPLine(Space(10) + MakeString(Trim(cname), 15, ALIGN_LEFT) + Space(5) + MakeString(Trim(bno), 10, ALIGN_LEFT)) Call modBillPrinter.PrintPLine(Space(10) + MakeString(Trim(place), 15, ALIGN_LEFT) + Space(5) + MakeString(bdate, 10, ALIGN_RIGHT)) Call modBillPrinter.PrintPLine(Chr(12)) Call modBillPrinter.PrintPLine(Space(5) + MakeString(" S.NO", 5, ALIGN_LEFT) + Space(3) + MakeString("Particulars", 20, ALIGN_LEFT) + Space(3) + MakeString("Grms", 6, ALIGN_RIGHT) + Space(3) + MakeString("Wastage", 7, ALIGN_RIGHT) + Space(3) + MakeString("Rate", 4, ALIGN_RIGHT) + Space(3) + MakeString("MC", 5, ALIGN_RIGHT) + Space(3) + MakeString("SC", 5, ALIGN_RIGHT) + Space(3) + MakeString("Amount", 10, ALIGN_RIGHT)) Call modBillPrinter.PrintPLine(Chr(12))
psno = 1
While psno <= sno If tcount > 5 Then Print #1, Chr(12) Call Header tcount = 1 End If mg1.Row = psno mg1.Col = 2: particulars = mg1.Text mg1.Col = 3: grams = mg1.Text mg1.Col = 5: wastage = mg1.Text mg1.Col = 6: trate = mg1.Text mg1.Col = 7: mc = mg1.Text mg1.Col = 8: sc = mg1.Text mg1.Col = 9: amount = mg1.Text Print #1, Spc(8 - Len(CStr(psno))); psno; Spc(3); '8 Print #1, particulars; Spc(20 - Len(CStr(particulars))); '17 Print #1, Spc(9 - Len(CStr(grams))); grams; '7 Print #1, Spc(8 - Len(CStr(wastage))); wastage; Print #1, Spc(11 - Len(CStr(trate))); trate; '7 Print #1, Spc(9 - Len(CStr(mc))); mc; '7 Print #1, Spc(8 - Len(CStr(sc))); sc; '7 Print #1, Spc(12 - Len(CStr(amount))); amount '11 tcount = tcount + 1 psno = psno + 1 Wend
For i = 1 To 9 - tcount Print #1, vbCr Next i
Print #1, Spc(5); "Discount : "; disctxt.Text; Spc(5); "VAT : "; vattxt.Text Print #1, vbCr Print #1, Spc(76 - Len(CStr(Netamttxt.Text))); Netamttxt.Text Print #1, Chr(12)
modBillPrinter.ClosePrintReport If Dir(App.Path + RPTNAME) <> "" Then strFilename = App.Path + RPTNAME Call ViewBills(RPTNAME) Else MsgBox "Report No Initilize" End If Shell App.Path & "\PRINT.BAT", vbHide End Function
==================================================================== 3 Third method - ( In this method no printing no out put in printer totally no print out =====================================================================
Private Function PrintBill() Dim tsno As Integer
'Open "LPT1" For Output As #1 Open "E:\jewelproject\DSREPO.TXT" For Output As #1 Call Header psno = 1
While psno <= sno If tcount > 5 Then Print #1, Chr(12) Call Header tcount = 1 End If mg1.Row = psno mg1.Col = 2: particulars = mg1.Text mg1.Col = 3: grams = mg1.Text mg1.Col = 5: wastage = mg1.Text mg1.Col = 6: trate = mg1.Text mg1.Col = 7: mc = mg1.Text mg1.Col = 8: sc = mg1.Text mg1.Col = 9: amount = mg1.Text Print #1, Spc(8 - Len(CStr(psno))); psno; Spc(3); Print #1, particulars; Spc(17 - Len(CStr(particulars))); Print #1, Spc(6 - Len(CStr(grams))); grams; Print #1, Spc(8 - Len(CStr(wastage))); wastage; Print #1, Spc(7 - Len(CStr(trate))); trate; Print #1, Spc(7 - Len(CStr(mc))); mc; Print #1, Spc(7 - Len(CStr(sc))); sc; Print #1, Spc(11 - Len(CStr(amount))); amount tcount = tcount + 1 psno = psno + 1 Wend
For i = 1 To 9 - tcount Print #1, vbCr Next i
Print #1, Spc(5); "Discount : "; disctxt.Text; Spc(5); "VAT : "; vattxt.Text Print #1, vbCr Print #1, Spc(76 - Len(CStr(Netamttxt.Text))); Netamttxt.Text Print #1, Chr(12) Close #1 'Shell App.Path & "\PRINT.BAT", vbHide Shell "E:\jewelproject\PRINT.BAT", vbHide 'Shell "c:\1.txt", vbHide End Function
Public Function Header()
cname = cnametxt.Text bdate = datetxt.Text place = cptxt.Text bno = Bnotxt.Text
For i = 1 To 6: Print #1,: Next
Print #1, Spc(18); cname; Spc(42 - Len(Name)); bdate Print #1, Spc(18); place; Spc(42 - Len(bno)); bno Print #1, vbCrLf
Print #1, Spc(5); "Sl.No"; Spc(3); "Particulars"; Spc(6); " Grams"; Print #1, " Wastage"; Spc(3); "Rate"; Spc(3); "MC"; Spc(5); "SC"; Spc(6); "Amount" Print #1, vbCrLf
End Function ========================================================================
Please help me to print properly in pre printed bill =======================================================
A.Senthil kumar
- Proposed As Answer byChitharanjan Wednesday, September 16, 2009 5:57 AM
-
| | image india Wednesday, January 16, 2008 6:18 AM | hi
try
Printer.PaperSize = vbPRPSUser to set paper size (no need to set length & width)
printer.killdoc to stop printing
i think it will work | | Chitharanjan Wednesday, September 16, 2009 6:01 AM |
|