I wish to print invoice using printer.print method ( using USB dot matrix printer in continous paper)
Some invoice contain 6 lines, some 15 lines. Now afer printing 5 lines printer ejectng paper. so paper waster ( paper width 5 inches, continous paper). I wish to top printing after printing invoice without ejecting paper.
i am using
'Printer.Height
'Printer.Width
property but no use ? please suggest me to overcome the problem

Dani AI

Generated

Short summary and practical fixes tied to the thread: the printer is deciding where a page ends (tear‑off/form‑feed) — not VB6 alone. The useful options are (1) stop the printer from auto‑advancing, (2) give Windows/Crystal a matching custom form length, or (3) bypass the Windows driver and send printer control (ESC) commands directly.

Disable auto tear/auto feed on the dot‑matrix (printer defaults or control‑panel). Many impact printers advance to the tear‑off edge when they see a full page or a form‑feed; the auto‑tear/auto‑feed behavior is a firmware/driver feature you can turn off. (manualzilla.com)

If you use Crystal Reports, create a Windows “form” (custom paper) that matches the maximum invoice length and pick that paper in Printer Setup before designing/printing the report — Crystal reads the OS printer forms. Create the same named form on every machine (CR stores a paper ID that can differ across PCs). ()

If you need programmatic control from VB6 (to avoid the driver eject), send printer‑ready ESC/P (or your printer’s) sequences as RAW bytes to the spooler instead of using high‑level GDI page breaks. Use the Winspool APIs (OpenPrinter/StartDocPrinter/WritePrinter) with pDatatype = "RAW" and include only the vertical‑feed or set‑page‑length ESC commands you want (for example ESC J to advance). This prevents the driver from inserting an unexpected form‑feed. Example skeleton (VB6):

' Module: RawPrinter
Private Type DOCINFO1
  pDocName As String
  pOutputFile As String
  pDatatype As String
End Type
Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pName As String, ph As Long, ByVal pDefault As Long) As Long
Private Declare Function StartDocPrinter Lib "winspool.drv" Alias "StartDocPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, di As DOCINFO1) As Long
Private Declare Function WritePrinter Lib "winspool.drv" (ByVal hPrinter As Long, ByVal pBuf As Any, ByVal cdBuf As Long, ByRef pcWritten As Long) As Long
' ... OpenPrinter, StartDocPrinter, WritePrinter, EndDocPrinter sequence ...
' Build a raw string: Chr$(27) & "@" & "line1" & vbLf & ... & (ESC feed commands) and send via WritePrinter

References for ESC/P control and raw printing APIs. (support2.epson.net)

Recommended test plan: pick one simple invoice, disable auto‑tear on printer, create a Windows form sized for your longest invoice, test printing from Crystal using that form, then (if still ejecting) send the same invoice as RAW with controlled ESC feeds to confirm no unwanted eject.

Recommended Answers

All 3 Replies

This is most challanging to a developer to control a printer properly. To do it you must have to calculate the cursor position with page height to feed next page and print properly. This is most tedious job. You can use Crystal Report which can solve your problems most effectively.

Thanks for reply, I am facing same problem in crstal report 8.5. How can fix paper height in continous stationery . ( paper width 5 inches , Continous staioner -roll paper). some invoice may 5 to 7 lines , some invoice may contain 10 to 20 lines. In this situation how can set paper size in crystal report 8.5 ?

Which type of printer you are using ?
only dot matrix printer can support roll paper. If you use TVS then it has a paper size of 8" X 6" i.e. 8" width and 6" height. but epson has no paper size like this. In XP there was an option to set custom paper size but in win 7 or above it omits.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.