Direct print on printer RRS feed

  • Question

  • I want to send direct print on the printer without view, I have applied this if more new information else of these printing option tell me with example.

    Error on this first line (Dim P As New PrinterClass(Application.StartupPath)
    Error Printer class not define ?

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim P As New PrinterClass(Application.StartupPath)
    With P
    'Printing Title
    .Bold = True

    'Printing Date

    'Printing Header

    'Printing Items
    Dim i As Integer
    For i = 1 To 6
    .WriteChars("Item# " & (Rnd() * 100) \ 1)
    .WriteChars(Rnd() * 10 \ 1)
    .WriteChars((Rnd() * 50 \ 1) & " JD(s)")

    'Printing Totals
    .WriteChars((Rnd() * 300 \ 1) & " JD(s)")
    End With
    End Sub

    Friday, January 3, 2020 9:57 AM


All replies

  • What language are you using?

    This forum is for visual

    This shows how to use the printer document to print in

    • Marked as answer by CompuTechSide Tuesday, January 7, 2020 2:53 PM
    Friday, January 3, 2020 10:56 AM
  • I using

    Without viewing print 

    Friday, January 3, 2020 11:36 AM
  • I using

    Without viewing print 

    It does not look like to me. I don't see how the code you show would work for anything but maybe I don't understand it?

    Try using the example in the link I gave. If you don't want to view first then don't use the print preview features. The example in the link appears not use print preview.

    Are you trying to print raw print data to a POS terminal printer? Where did you get the code you show?

    Friday, January 3, 2020 11:46 AM
  • Yes you saying right print data to a POS terminal printer 

    before this i was using  crystal report. Print is going on printer but i want without view I have applied this 

    CrystalReportViewer1.SelectionFormula = "{Invoice_Table.Invoice_no} = '" &  TxtParticular.Text & "'"

    but have used this line for without viewing see this

    DirectPrint.PrintToPrinter(1, False, 0, 0) ' But all Invoices_no printing on this line i want use where clause for particular record print just.

    you can see in crystal report selection formula

    Friday, January 3, 2020 12:03 PM
  • If you search I think I have seen forum examples of printing like you want without crystal reports (cr) direct from but I don't have the equipment. So I am not going to try.

    I don't think cr is supported by Microsoft anymore you need to go their forum if no one from this forum can help.

    Friday, January 3, 2020 12:12 PM
  • Hi CompuTechSide, 

    Thank you for posting here.

    According to your description, you need to define ‘PrinterClass’ class in your project.

    I find your code may related to the following reference:

    POS Printing: The Easy Way

    You can download the project in the reference and install ‘Microsoft.VisualBasic.PowerPacks.Vs’ dll.

    Then you can find ‘PrinterClass’ class in the project with no errors.

    Besides, you can also choose to use the PrintDocument object to print.

    Hope it can help you.

    Best Regards,

    Xingyu Zhao

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, January 6, 2020 7:59 AM