2011-11-10 4 views
1

VB.NETと.NET Framework 3.5では、一度に複数のアイテムを購入できるPoint of Sale(POS)アプリケーションを開発しています。私はすべての項目を印刷する必要があります:そのコード、名前の数量、行 - 列の方法で価格。固定幅と動的高さの用紙でvb.netを使用して印刷する方法

SHOP NAME   date 
==========   ===== 
SL CODE  NAME  QTY  PRICE 
== =====  ===== ===  ===== 
1 ANC-059 Pencil 1  $2.00 
2 ASNC-009 Pencil 1  $2.00 
3 ASNC-09 Pencil 1  $2.00 
4 ASNC-009 Pencil 1  $2.00 

ページ幅は固定ですが、高さは動的です。

プリントアウトは、POSシステムで通常使用されるロール紙で印刷されます。

どうすればいいですか?

+0

が、これはプリンタ/ドライバ間で変わる考えると、あなたはより具体的なことができますか? –

+0

WinformsまたはWPF? WPFには、FlowDocumentScrollViewerなどの印刷に便利な機能がいくつかあります。 – Stewbob

+0

事前に、どのタイプのプリンタを使用するのか不明です。だから、私はそれが一般的にプリンタのほとんどをカバーすることを試みています。これらのプリンタにはドライバがあり、他のインクジェットプリンタやデスクジェットプリンタのようにアクセスできます。 –

答えて

4

標準リサイズ印刷:

Try 
    'Set up the document for printing and create a new PrintDocument object. 
    Dim pd As New Printing.PrintDocument 
    'Set the event handler for the printpage event of the PrintDocument. 
    AddHandler pd.PrintPage, AddressOf pd_PrintPage 
    'Set the printer name. 
    pd.PrinterSettings.PrinterName = PrintDialog1.PrinterSettings.PrinterName 
    'Print the document by using the print method for the PrintDocument, which triggers the PrintPage event 
    pd.Print() 
Catch ex As Exception 
    MessageBox.Show(ex.Message) 
End Try 


'The PrintPage event is raised for each page to be printed. 
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As Printing.PrintPageEventArgs) 
    'Set up the default graphics object that will be used to do the actual printing. 
    Dim g As Graphics 
    g = ev.Graphics 

    Dim tHeight as Double 
    Dim txt as String = "My text goes here" 
    g.DrawString(txt, myFont, myBrush, xPosition, yPosition, StringAlignment.Near) 
    'Measure the height (on the page) of the item that you have just drawn, so that 
    'you can place the next item below it. 
    tHeight = g.MeasureString("Customer", fntBlue).Height() 

    txt = "My new line of text" 
    g.DrawString(txt, myFont, myBrush, xPosition, yPosition + tHeight, StringAlignment.Near) 

    '.....continue printing other items 
End Sub 
+0

thnksたくさんの仲間... –

関連する問題