Vig*_*r A 6 .net vb.net printing printdocument point-of-sale
我的要求是我需要打印发票,它可能包含10行或者可能包含20行.每件东西都应该在一张发票里.
例如,如果您去任何超市,如果您购买3件物品,您可能会收到小额账单.如果您购买30件商品,您可能会收到大笔账单.我想在我的vb.NET应用程序中实现相同的功能.
我确实需要根据账单的性质通过程序增加打印机页面长度.
我正在使用点阵打印机和图形模式打印.
我尝试过的:
截至目前,我已经创建了文本文件,并使用命令行打印使用以下命令打印它
Type Printfile.txt > prn
Run Code Online (Sandbox Code Playgroud)
但是,问题是我无法使用不同的字体,重量或大小来格式化我的文本文件,因为我将其写为文本文件(记事本).
我正在使用streamwriter从VB.NET写入文件,到目前为止我正在尝试在文本文件中格式化它.
我想将一些单词格式化为粗体或斜体和字体大小变化,但由于我使用文本文件格式化,因此我无法这样做.
以下是格式:
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!
Run Code Online (Sandbox Code Playgroud)
您可以使用 WebBrowser 控件来打印 html 格式的发票。您仍然需要根据您的需要弄清楚如何从文本文件填充发票。这可以自动化。例如,创建一个循环来添加每个表行。你甚至可以使用CSS。
\n\n将 WebBrowser 控件添加到您的窗体,然后运行此代码
\n\nDim html =\n "<html>" &\n "<head>" &\n "<style>" &\n "table, th" &\n "{" &\n "border: 1px solid black;" &\n "table-layout: fixed;" &\n "width: 100px;" &\n "border-collapse: collapse;" &\n "}" &\n ".title" &\n "{" &\n "color: blue;" &\n "}" &\n "</style>" &\n "</head>" &\n "<body>" &\n "<p><b><div class=""title"">Store Name</div></b></p>" &\n "<p>Store Address</p>" &\n "<p><hr/></p>" &\n "<p><b>Gift Receipt</b></p>" &\n "<p>Transaction #: 105</p>" &\n "<p>Date: 11/10/2009 Time: 6:10:10</p>" &\n "<p>Cashier: 2 Register: 5</p>" &\n "<p><hr/></p>" &\n "<table>" &\n "<tr>" &\n "<th>Item</th>" &\n "<th>Description</th>" &\n "<th>Quantity</th>" &\n "</tr>" &\n "<tr>" &\n "<th>567577</th>" &\n "<th>xyz</th>" &\n "<th>2</th>" &\n "</tr>" &\n "<tr>" &\n "<th>687687</th>" &\n "<th>abc</th>" &\n "<th>4</th>" &\n "</tr>" &\n "<tr>" &\n "<th>- -</th>" &\n "<th>- -</th>" &\n "<th>-</th>" &\n "</tr>" &\n "<tr>" &\n "<th colspan=""2"">Net Amount</th>" &\n "<th>6</th>" &\n "</tr>" &\n "</table>" &\n "<p><hr/></p>" &\n "<p>Thank You for shopping</p>" &\n "<p>XYZ StoreName</p>" &\n "<p>We hope you\xe2\x80\x99ll come back soon!</p>" &\n "</body>" &\n "</html>"\n\nMe.WebBrowser1.DocumentText = html\nRun Code Online (Sandbox Code Playgroud)\n\n您将需要一个文档完成处理程序(或一个单独的打印按钮,但要点是ShowPrintDialog()在文档完成之前无法调用)。
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted\n Me.WebBrowser1.ShowPrintDialog()\nEnd Sub\nRun Code Online (Sandbox Code Playgroud)\n\n上面的代码生成了这个基本的(尽管是格式化的)收据。
\n\n\n| 归档时间: |
|
| 查看次数: |
724 次 |
| 最近记录: |