Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!europa.chnt.gtegsc.com!news.sprintlink.net!cs.utexas.edu!news.ti.com!ticipa!clw
From: clw@ticipa.works.ti.com (Chris Winemiller)
Subject: Re: Need printer demos in Smalltalk VST 3.0
Message-ID: <1995Jul4.030627.2305@ticipa.works.ti.com>
Organization: None
References: <3t1pda$e1@socrate>
Date: Tue, 4 Jul 1995 03:06:27 GMT
Lines: 41

In article <3t1pda$e1@socrate> emayrand@riq.qc.ca (Etienne Mayrand) writes:
>Does anyone have a working demo (or class) that sucessfully
>uses the Printer class in VST 3.0?

The following is some simplified coding of what I am using.  You'll have
to produce code to fill in several of the variables, but the essential
part of accessing a printer and printing to it should work.  NOTE: This
code will only print one page.  If the text you try to print is longer
than one page, the remainder is essentially truncated.

| stringToPrint marginsRectangle theFont  dialog hDCPrinter printer |
stringToPrint := 'Hello, world.'.
theFont := Font systemFont.
marginsRectangle := 1.0 @ 0.75 extent: 1.0 @ 0.75. "Left,Top,Right,Bottom
                                                    margins (inches)"
dialog := PrintDialog new
            noSelection;
            noPages;
            open.
(hDCPrinter := dialog hDCPrinter) isNil
  ifFalse: [
    printer := Printer fromDC: hDCPrinter.
    [ [printer
         print: stringToPrint
         font: theFont
         title: String new
         collate: dialog collate
         copies: dialog copies
         wordwrap: true
         marginsRect: marginsRectangle]
      on: Error
      do: [MessageBox message: 'Cannot honor print request.'] ]
    forkAt: Processor lowPriority.

Regards,
Chris
==============================================================
Chris Winemiller               Internet: clw@works.ti.com
Disclaimer: I do not speak for TI.
==============================================================

