Dynamic paper height using .NET PrintDocument using TVS dot matrix printer

My requirement is that I need to print an invoice, it can contain 10 lines or it can contain 20 lines. Each item must be in one account.

For example, if you go to any supermarket, if you buy 3 items, you can get a small account size. If you buy 30 items, you can get a large invoice size. I want to implement the same in my vb.NET application.

Precisely I need to increase the page length of the printer through the program according to the nature of the account.

I am using a dot matrix printer with graphical print mode. A.

What I tried:

At the moment, I created a text file and printed it using the command line using the following command

Type Printfile.txt > prn

But the problem is that I can not format my text file with a different font, weight or size, since I write it as a text file (notepad).

I am using a streamwriter to write files from VB.NET, and at the moment I am trying to format it in text files.

I want to format some words so that they are highlighted in bold or italics and change the font size, but I can not do this, because the formatting is text files.

Below is the format:


Store Name
Store Address
----------------------------------------      
Gift Receipt

Transaction #:          105
Date: 11/10/2009     Time: 6:10:10
Cashier:  2          Register: 5
----------------------------------------      
Item           Description       Quantity
----------------------------------------   
567577         xyz                2
687687         abc                4
–  –           – –                –
----------------------------------------  
                     Net Amount : 6

Thank You for shopping
XYZ StoreName
We hope you’ll come back soon!

+6
source share
2 answers

WebBrowser html. , - , . . , , . css.

WebBrowser

Dim html =
    "<html>" &
        "<head>" &
            "<style>" &
                "table, th" &
                "{" &
                    "border: 1px solid black;" &
                    "table-layout: fixed;" &
                    "width: 100px;" &
                    "border-collapse: collapse;" &
                "}" &
                ".title" &
                "{" &
                    "color: blue;" &
                "}" &
            "</style>" &
        "</head>" &
        "<body>" &
            "<p><b><div class=""title"">Store Name</div></b></p>" &
            "<p>Store Address</p>" &
            "<p><hr/></p>" &
            "<p><b>Gift Receipt</b></p>" &
            "<p>Transaction #:          105</p>" &
            "<p>Date: 11/10/2009     Time: 6:10:10</p>" &
            "<p>Cashier:  2          Register: 5</p>" &
            "<p><hr/></p>" &
            "<table>" &
                "<tr>" &
                    "<th>Item</th>" &
                    "<th>Description</th>" &
                    "<th>Quantity</th>" &
                "</tr>" &
                "<tr>" &
                    "<th>567577</th>" &
                    "<th>xyz</th>" &
                    "<th>2</th>" &
                "</tr>" &
                "<tr>" &
                    "<th>687687</th>" &
                    "<th>abc</th>" &
                    "<th>4</th>" &
                "</tr>" &
                "<tr>" &
                    "<th>- -</th>" &
                    "<th>- -</th>" &
                    "<th>-</th>" &
                "</tr>" &
                "<tr>" &
                    "<th colspan=""2"">Net Amount</th>" &
                    "<th>6</th>" &
                "</tr>" &
            "</table>" &
            "<p><hr/></p>" &
            "<p>Thank You for shopping</p>" &
            "<p>XYZ StoreName</p>" &
            "<p>We hope you’ll come back soon!</p>" &
        "</body>" &
    "</html>"

Me.WebBrowser1.DocumentText = html

( , ShowPrintDialog() ).

Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    Me.WebBrowser1.ShowPrintDialog()
End Sub

, , .

enter image description here

+4

, ( ), , ascii, , .

FF ( , ), ESC O ( ), ESC 0/ESC 1 ( /w 70 > ) /: escape- - BEL

. (PDL). HP (PCL). Epson PDL.

An #, win32 api

0

Source: https://habr.com/ru/post/1016952/


All Articles