printing problem

RonR

Well-known member
Joined
Nov 23, 2007
Messages
82
Programming Experience
5-10
this is a line of code to send to the printer. I want < Staff List > to be printed at the same position even when the client name has a different length. I would also like < Staff List > to be bold but not the client name.


I have experimented with Write & Print but no luck.


MyPrinter.Print(TAB(7), " Client Name> ", TAB(27), Trim$((rsIncidents.Fields("ClientName").Value)), TAB(110), " < Staff List >")
 
question


So a text file is created first, then this code would print the file???

I assume a print preview could be generated for any text file??
 
You dont need to generate a text file first - you can print anything.

For example

VB.NET:
Imports System.Drawing.Printing

Public Class Form1

    Public WithEvents pdPrinter As PrintDocument
    Public ppvwPrinter As PrintPreviewDialog

    Private shtPageNumber As Int16 = 0
    Private shtTotalPages As Int16 = 0


    Private Sub TestPrintPreview(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        pdPrinter = New PrintDocument
        ppvwPrinter = New PrintPreviewDialog
        ppvwPrinter.Document = pdPrinter
        ppvwPrinter.Width = Screen.PrimaryScreen.Bounds.Width
        ppvwPrinter.Height = Screen.PrimaryScreen.Bounds.Height
        ppvwPrinter.PrintPreviewControl.Zoom = 0.66
        ppvwPrinter.ShowDialog()
        pdPrinter.Dispose()
        ppvwPrinter.Dispose()
    End Sub

    Private Sub Begin_Printing(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles pdPrinter.BeginPrint
        pdPrinter.DocumentName = "Test Document"
        pdPrinter.PrintController = New Printing.StandardPrintController()
        shtTotalPages = 3

        shtPageNumber = 0
    End Sub

    Private Sub Test_PrintPage(ByVal sender As System.Object, ByVal e As PrintPageEventArgs) Handles pdPrinter.PrintPage
        shtPageNumber += 1
        Dim f As New Font("Arial", 18, FontStyle.Bold)
        e.Graphics.PageUnit = GraphicsUnit.Millimeter
        e.Graphics.DrawString("TEST PAGE " & shtPageNumber.ToString(), f, Brushes.Black, 15, 12 * shtPageNumber)
        e.Graphics.DrawRectangle(Pens.Black, 10, 10, 210 - 10 - 10, 297 - 10 - 10)
        f.Dispose()


        If shtPageNumber < shtTotalPages Then
            e.HasMorePages = True
        Else
            e.HasMorePages = False
        End If
    End Sub

End Class
 
Back
Top