Printing with VB'Net - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Printing with VB'Net

Description:

When your program writes or draws to the screen you do not have to worry about ... Graphics are drawn to a virtual display which Windows maps to the actual one ... – PowerPoint PPT presentation

Number of Views:60
Avg rating:3.0/5.0
Slides: 11
Provided by: cisUso
Category:
Tags: draws | net | printing

less

Transcript and Presenter's Notes

Title: Printing with VB'Net


1
Printing with VB.Net
  • R. Johnson ITE285

2
Windows Graphics
  • When your program writes or draws to the screen
    you do not have to worry about the video card or
    monitor specifics.
  • This is called device independent graphics.
  • Graphics are drawn to a virtual display which
    Windows maps to the actual one using the video
    card driver for your hardware.
  • Printing is handled in a similar way. You
    describe a virtual page which is then mapped to
    the actual capabilities (colors, dpi) of the
    printer with its driver.

3
Printing Basics
  • A PrintDocument serves as the virtual page.
  • Its PrintPage event handler is where you write
    the code to draw on the page.
  • The Graphics objects methods are used to draw
  • .DrawString() for text
  • .DrawLine() .DrawImage()
  • .DrawRectangle() .DrawEllipse()
    et cetera

4
Drawing Details
  • DrawString() requires a Font object
  • A Font has a name, size and style.
  • Drawing colors, fill lines are set with Brushes
  • Drawing position is in X-Y coordinates, Y is
    positive down the page.
  • Default units are in points (72pts 1inch)

5
Printing in Columns
  • Easy method
  • Pick a fixed pitch (monospaced) font such as
    Courier New. All chars take the same space.
  • Pad the output string with the space character,
    easiest with String.Format()
  • Alternate method
  • Print column items with separate DrawString()
    calls for the same x coordinate.

6
String.Format()good for listboxes and printing
columns
  • First param is a format string.
  • Following params are a list of vars to be
    formatted into the fields.
  • Returns a string padded with spaces.
  • 0,101,202,15 has field, widthwidth is
    of characters.
  • Default is right alignment within field.
  • To get left alignment, negative width, ex.
    2,-10

7
Printer Dialog Object
  • This object connects to the printer driver.
  • The PrinterDialog must be associated with the
    PrintDocument object.

8
Printer Settings
  • The document itself can have virtual settings
    orientation, page size, etc.
  • These can be temporarily changed with the Printer
    Dialog

9
Printing the Document
  • Document is printed with the PrintDocuments
    .Print() method
  • Simply drawing past the page bounds causes output
    to span to another page during printing.
  • Managing multiple pages for repeating headers,
    etc. is more complex.

10
Print Preview
  • The PrintPreview Dialog is a virtual printer.
  • Printed output can be viewed on the display. You
    can then print on the printer.
Write a Comment
User Comments (0)
About PowerShow.com