![]() |
in |
|
look for | Delphi |
Also see Delphi Files, Directories, Disks, I/O Page
Single Most Frequently Asked Question:
How can I print a bitmap?
| Abort dialog | How to Print in Windows, Borland TI 188D. Includes AbortCallBack example. |
| Add Printer dialog | How can I execute the Add Printer wizard?
Download efg's translation to Delphi of most of the C++ code in Microsoft's Knowledge Base Article Q153751Using Printers with Windows 95 Shell: SHPrinters.ZIP |
| Background Printing | A TPrintThread class and example is in Chapter 5, Concurrent Programming, in Delphi in a Nutshell, pp. 103-108. |
| Bins | Bin Selection: Peter Below's UseNet Post about TPrinter
and Bin Selection
Determine Available PaperBins with DeviceCapabilities API Getting Bin Names from Your Printer, Borland FAQ 1455D ChangePrinterBin: Xavier Pacheco's UseNet Post with ChangePrinterBin procedure Changing Paper Trays: Peter Below's UseNet Post and suggestions Also see DeviceCapabilities |
| Brush Styles | What line styles and
brushes are available with my printer? See efg's Printer Demo #2
See Brush Styles on Delphi Graphics VCL/RTL page See E-mail note from Hel Skovorodnikov about filling a print canvas area with a user-defined brush. |
| Color | How Do I Print in Color? Borland FAQ 2685D Printing in color Joe Hecht's UseNet Post with functions IsColorPrinter and SetPrinterColorMode Non-Delphi: WinColorKit: Windows Color Quality Test Kit for Device OEMs Different Font Colors Print As Same Color Color Printer Test Page Also see efg's Color and Computers page and Delphi Graphics Color page |
| Components | BDPrint. Delphi 5.0 freeware component to print a full form (on screen
and offscreen portions) and all components on that form. Scan a printed form, put
the TBitmap in a TImage at design time, and put necessary components
such as TEdit, TCheckBox on top of the image. At runtime, fill out
the information on the screen and print the completed form. This clever solution is
by Bob Dalton, President, Digital Logistics Software Company.
ftp://ftp.digitallogistics.com/bdprint.zip
EDSprint component: This component allows Delphi developers to programmatically get/set the various properties of the current printer. www.onedomain.com/edsprint.htm MPrtInfo. This component let you access to Windows95/98 and NT structures containing virtually any information provided by the system about installed printers and their pending jobs. Structures available are: PRINTER_INFO_1, 2, 3, 4 and 5, DEVMODE, JOB_INFO_1 and 2 (see Win32 online help for details), plus some obvious properties (installed printer names list, selected printer name and index in the list and so on). Methods to pause, resume and clear printers and jobs, some printer configuration dialogs. Events to monitor printer and printer jobs status changes. http://delphi.icm.edu.pl/ftp/d30free/mprtinfo.zip TAsciiPrinter is a non-visual component which gives control over printers back to the developer, just like in DOS PRINT, but through windows. Ideal for DOT MATRIX printers, as text is printed as ASCII, rather than a graphic. http://delphi.icm.edu.pl/ftp/d10share/asciprnt.zip TDBPrinterSetupDialog is a TPrinterSetupDialog
component with capability of getting/setting printersetup-values
(orientation, papersize etc) at designtime and runtime. List of Printer-Related Components |
| Default Printer | Peter Below's UseNet
Post about changing default printer in D6
How to get the default printer name Changing Windows Default Printer in Code. Borland FAQ 2618D. This Borland example is very weak. While accurate, the example is incomplete when it does not show how to form the string needed in the WinIni.WriteString call. FAQ 1109D, Getting the Printer driver and port name from TPrinter's, does give the needed clue but doesn't provide all the needed details. For a complete D3/D4 example of how to change the Windows 95/98 default printer -- WITH persistence -- see PrinterDefault.ZIP. Peter Below's UseNet Post about Programmatically Changing the Default Printer. "Win32 error. Code123." when no Default Printer exists Change the default printer in MS Windows "Changing the Default Printer," Delphi 5 Developer's Guide by Teixeira and Pacheco in Online "CD" Chapters, pp. 189-190 Printing to another printer than the default one, Borland FAQ 2984D No Default Printer Selected Error Message, Borland FAQ 2386 D |
| Device Independence | How can I draw something (images, lines, etc.) on a screen canvas and then print exactly the same thing on the printer? In general, a printer has many more pixels than your video monitor. Sometimes you can just dump the screen's contents to the printer (which is possible), but normally you'll want to draw your images or lines directly on the printer's canvas to take advantage of its higher resolution. See efg's Printer Demo #2 for an example of how to do this. |
| DeviceCapabilities | Alex Weidauer's UseNet
Post with example of listing printer device capabilities
Mihai Nicolae Teognoste's UseNet Post with WinSpool.DeviceCapabilities example for DC_ENUMRESOLUTIONS Calling ExtDeviceMode/DeviceCapabilities in
Win32s App The DeviceCapabilities function retrieves the
capabilities of a printer device driver. DeviceCapabilities Function Sample Code Determine Available PaperBins with DeviceCapabilities API Also see Bins, DEVMODE, GetDeviceCaps |
| DEVMODE | Peter Below's UseNet
Post with example
DEVMODE Structure |
| Draft Mode | Woody's UseNet Post about selecting draft mode using the device mode commands |
| Drivers | Getting the Printer
driver and port name from TPrinter's, Borland FAQ 1109D
Programmatically Installing Printer Driver, Borland FAQ 1361D Imager SDK, a suite of OEM fax software components (SDK toolkit) offers client and server solutions for Windows 95/98/ME/NT/2000, including Imager Print Drivers. www.meta-soft.com Print to graphics file format using special
printer driver: PEERNET.DRV Pro Driver www.eurosistemi.it/uk_vpd.htm Virtual Printer works like a common printer - but you don't get any
printout! It gives you the whole printout as a collection of Enhanced
Metafiles that you can view (and print) with the EMF-Viewer. |
| Envelopes | Printing Envelopes in Delphi 5 Developer's Guide by Teixeira and Pacheco, pp. 166-183 (on the CD) |
| Errors | Detecting Print Errors, Borland FAQ 1762D No Default Printer Selected Error Message, Borland FAQ 2386 D "Printing in Progress" Error. Do not try to reset the Printer.Orientation after a Printer.BeginDoc has been issued. The Printer Orientation should be set before calling Printer.BeginDoc. See Error Codes page |
| Floodfill | UseNet Post with responses to "How can I use FloodFill on Printer.Canvas?". Steve Schafer: "Not all GDI devices support FloodFill. Printers are especially unlikely to support it." Joe Hecht: "the reason is there is often no frame buffer used for a printer. FloodFilling against pixels already printed is kinda difficult" |
| Fonts | The size of my text characters changes on
different printers -- OK on some printers and very small on other printers. How can I set
the font size to be the same physical size on different printers?
The best way to fix a bug in TPrinter: Use a resident font for printing? www.scalabium.com/faq/dct0068.htm How to use the default resident font in the printer, Borland FAQ 1133D How can I print using a rotated font? Assuming the printer supports rotating fonts, and the font is a TrueType or other rotatable font, see Joe Hecht's solution. Different Font Colors Print As Same Color |
| Generic/Text Printer | Peter Below's UseNet Post with PrintLineToGeneric procedure to print a line to the generic/text printer without formfeed |
| GetDeviceCaps | Getting Printer Capabilities (printing graphics, large
bitmaps, DIBs),
Borland FAQ 1475D
How can I determine my printer's resolution? What other useful information can I get using the
GetDeviceCaps API call? "GetDeviceCaps and DeviceCapabilities," Delphi 5 Developer's Guide by Teixeira and Pacheco in Online "CD" Chapters, pp. 191-207 Passing TPrinter handle to GetDeviceCaps in Borland FAQ 2610D Also see DeviceCapabilities |
| GetPrinter / SetPrinter | ChangePrinter: Stephen Brown's UseNet Post with ChangePrinter
procedure
Changing the Printer Port in Code, Borland FAQ 2921D Changing the Papersize of a Print Job, Borland FAQ 603D See Reset below. |
| Installed Printers | Finn Tolderlund's UseNet
Post with AnyPrintersInstalled routine
MPrtInfo. This component let you access to Windows95/98 and NT structures containing virtually any information provided by the system about installed printers and their pending jobs. Structures available are: PRINTER_INFO_1, 2, 3, 4 and 5, DEVMODE, JOB_INFO_1 and 2 (see Win32 online help for details), plus some obvious properties (installed printer names list, selected printer name and index in the list and so on). Methods to pause, resume and clear printers and jobs, some printer configuration dialogs. Events to monitor printer and printer jobs status changes. http://delphi.icm.edu.pl/ftp/d30free/mprtinfo.zip |
| List of Printers | EnumPrinters. API call to enumerate available printers, print servers, domains, or print providers. |
| Margins | Marginal Printing. Your printer knows its own limitations -- all you have to do
is ask. March/April 1999, Visual Developer, pp. 96-97 Getting the Printing Margin of the Page, Borland FAQ 1115D |
| NT Tips | Jeff Hamblin's UseNet Post with
solution for some NT printing problems.
Direct Commands to Printer -- Passthrough/Escape, Borland TI 1497D See EnumPrinterData under Printer Properties |
| Online | Checking if Printer is Online Peter Below's UseNet Post showing how to capture WMSpoolerStatus messages. Peter Below's UseNet Post about checking whether printer is "on". Peter Below's UseNet Post about EnumJobs for printer status in WinNT. Detecting Printer Status, www.undu.com/Articles/990228a.html Testing Printer Status: Chris' UseNet Post Q160129: HOWTO Get the Status of a Printer and a Print Job |
| Orientation | How can I tell what direction a printer will rotate
output on a landscape page? See Joe Hecht's UseNet Post Detecting what direction a printer will rotate for a portrait, Borland FAQ 902D |
| Packages | StatPlot -- TP 4 or later plotting software for HP LaserJet 2
or later StatUnit at www.math.ku.dk/ims/software/index.html |
TExcellent
FormPrinter
by Joe C. Hecht. www.code4sale.com/joehecht/prnform.htm TExcellent ImagePrinter
by Joe C. Hecht. www.code4sale.com/joehecht/prndib.htm GmPrintSuite Professional is a set of
print/print preview components which provide... |
|
| Paper Bins | See Bins |
| Paper Names | Paper Formats for Default Printer www.gnomehome.demon.nl/uddf/pages/printer.htm#printer12 OFF: Macro to Obtain a List of Paper Names
Supported by the Active Printer |
| Paper Size | Changing the Papersize of a Print Job, Borland
FAQ 603D
Peter Below's UseNet Post about setting
printer paper size. Also see TDeviceMode. |
| Pen Styles | What line styles and
brushes are available with my printer? See efg's Printer Demo #2 Line Styles and Colors. Steve Schafer's (Team B) UseNet Post: "GDI drivers are not required to support line styles other than psSolid and psClear if the line width is anything more than 1 pixel. Some drivers do support wide styled lines, but most do not. The only sure-fire fix that I know of is to draw all of the dashes and dots yourself." |
| Postscript | Determining if a given printer is capable of printing a
PostScript file Borland FAQ 914D |
| Print Preview | Print preview of TRichEdit, www.howtodothings.com/showarticle.asp?article=432 Greatis Print Suite. Components for Print and Preview. An extremely convenient set of components which provides advanced print and preview features into Delphi and C++ Builder applications. http://www.greatis.com/printsuite.htm In an E-mail, Adirano Urbano suggests using Quick Reports for a print preview (19 Jan 2001). For example:
GmPrintSuite is collection of 6 components based around the GmPreview
print preview component. Add Print Preview to Your Applications
SPRINT: Print & Preview Engine for Delphi. It has never been
easier to create multi-column multi-grouped reports with FULL control of
every little printer pixel. Component by Ben Ziegler PrintDrv. Print preview component that allows you to code your own reports without the need for visual report writers or complicated printer calculations. This component wraps the device-independent methods used to ensure good print outs regardless of printer and provides a scalable preview form allowing users to preview any report before printing. http://delphi.icm.edu.pl/ftp/d20free/printdrv.zip Print/preview the MS Access's report, www.scalabium.com/faq/dct0083.htm |
| Printer Queue | How can I show the Printer Queue? Download efg's translation to Delphi of most of the C++ code in Microsoft's Knowledge Base Article Q153751,Using Printers with Windows 95 Shell: SHPrinters.ZIP |
| Printer Properties | How can I display the Windows 95 Printer
Properties dialog? Download efg's translation
to Delphi of most of the C++ code in Microsoft's
Knowledge Base Article Q153751Using Printers with Windows 95 Shell: SHPrinters.ZIP
EDSprint component: This component allows Delphi developers to programmatically get/set the various properties of the current printer. www.onedomain.com/edsprint.htm Property changes in same print EnumPrinterData. API call to enumerate configuration data for a specified printer. (New in Windows NT). From the Win32 Developer's References: "A printer's configuration data consists of a set of named and typed values. The EnumPrinterData function obtains one of these values, and its name and a type code, each time you call it. Call the EnumPrinterData function several times in succession to obtain all of a printer's configuration data values. Printer configuration data is stored in the registry. While enumerating printer configuration data, you should avoid calling registry functions that might change that data." |
| Printer Settings / Setup | How can I get a printer's settings? www.scalabium.com/faq/dct0019.htm How can I set a printer settings? TPrinterSetupDialog. This non-visual Delphi component that can be used to change the default Windows printer, but it does not provide persistence for the next time a program is run. TPBPrinterSetupDialog is a TPrinterSetupDialog component
with capability of getting/setting printer setup values
(orientation, paper size, etc.) at design time and runtime. Settings
can be saved so users don't have to setup the printer every time they run
your program. How can I read a printer settings - page sizes and margins? Changing the Printer Setup between Printed Pages Borland's FAQ 2618D and FAQ 1109D give clues about how to implement persistence for Windows 95/98, but are missing details and do not provide a complete example. For a complete D3/D4 example of how to change the Windows 95/98 default printer -- WITH persistence -- see PrinterDefault.ZIP. |
| Printers | I'm not getting the same printouts on different printers.
What am I doing wrong? Getting the "same" printout on a wide variety of
Windows printers is almost impossible. See efg's Printer Demo #1.
HP Printers Printing graphics to a HP LaserJet (using HP PCL), Borland TI 71D (D1 only?) Epson Printers. E-mail comments from Armindo Da Silva: "I have noticed a few weeks ago that if you don't set printer.title, you won't be able to print on Epson Stylus Color x60 series.... Another bug is that if you use the ICC mode with big pictures you will get false color compared to small pictures." Try getting the latest printer drivers to solve these problems. Printing Graphics to an Epson Compatible, Borland TI 80D (D1 only) |
| Printers, Multiple | Simultaneously Printing to Multiple Printers, Borland FAQ 1367D |
| Printers Unit | www.doit.com/delphi/undu/dn0524i.htm |
| Printing Bitmaps | How can I print a bitmap?
1. A good and "free" method.
Use the StretchDIBits API call. (Make sure you have a DIB by
setting PixelFormat to pf24bit, or setting HandleType to bmDIB.) See Rodney E. Geraghty's UseNet Post about "How do I print a bitmap?" with code for D1/D2/D3 How to print a JPEG displayed in a TImage efg's UseNet Post explaining how to print a TPanel object Chris Rorden's version of how to print a
JPEG with these improvements: Why is StretchDIBits necessary? IF (GetDeviceCaps(Printer.Canvas.Handle, RASTERCAPS) AND Joe C. Hecht's 14 May 99 comments from UseNet Post to borland.public.codecentral: "The only way to print an image (form or otherwise) reliably is to use StretchDIBits(). You are much better off not calling GetDIBits() to get the image bits, as the palette is often neglected in the process. The best thing to do is to manufacture a really good DIB header and color table. If the image is coming from a res file, disk file, or other *reliable* DIB source, then the job is easy, providing you do not mind retrieving the DIB directly from the source, with no VCL code sitting in between you and the image. Note that building a *good* bitmap reader is not exactly easy (as evidenced in the VCL). "Getting a good color table from a screen image is more difficult, since you must take into account the correct palette should the device be a palette device. That includes 1, 4, and 8 bit images, as they all have a color table. Finally, should the printer be a palette device (rare), you must make a palette available to the printer. Under NT, just about every printer has at least palette structure under the hood (even if it is internally bypassed) (not that that info is actually valuable here)." Which VCL methods can I use while printing images? Any the VCL methods for drawing raster images should never be used to a printer. Problems are caused by sending a bitmap based on another device to the printer (and you should never do that). Joe Hecht pioneered the workaround for this problem at driver level. Some drivers are now able to detect this error and work around it, but you cannot rely on all drivers to do this. The damage that can be done includes bringing down the entire NT system! [Thanks to Joe Hecht for E-mailing me this information. 19 Jan 99] See efg's Printer Demo #1 for a complete example and a comparison of using Draw and StretchDraw instead of StretchDIBits. (You're very lucky if Draw and StretchDraw work for you!) Delphi 4/5 Books are still WRONG about printing bitmaps. Mastering Delphi 5 by Marco Cantù still incorrectly shows to use Printer.Canvas.StretchDraw on p. 867 to print a bitmap. I sent an E-mail to Marco and he says this will be shown in the "bug list" and corrected in future editions. "Printing a Bitmap" in Delphi 5 Developer's Guide by Teixeira and Pacheco in Online "CD" Chapters, p.158, still incorrectly shows to use StretchDraw. I sent an E-mail to the publisher and the authors about this issue. 2. "Better" free method. Use StretchDIBits but don't ignore palettes (which may be needed on some printers). A Better Way to Print A Form (by Joe Hecht), Borland's TI 1412D. 3. Best method (but not free). See links to Joe Hecht's TExcellent products (below) |
Print Matrix of images on a single page. See efg's Slide Show Lab Report |
|
| Printing Files | College Student Guide to Reading and Writing Files,
Borland TI 641D
Printing to a File, Borland FAQ 2394D |
| Printing Graphics | To print a graphics file, convert to a TBitmap
and use StretchDIBits. See Printing
Bitmap
How can I print a TMetaFile to the printer? UseNet Post by Mat Ballard Sending an Image to the Printer. Borland FAQ 1211D (Formerly Q&A 821) There is a missing "NOT" in the second sentence, but I can't get anyone at Borland to fix this. The statement should read "This means you should NOT use the VCL canvas methods Draw, StretchDraw,CopyRect, BrushCopy, and the like to transfer a bitmap to the printer." Better Way to Print A Form, Borland TI 1412DInteresting
approach: |
| PrintScreen | See Screen Capture |
| "Raw" printer access | RawPrint. Delphi unit that allows sending raw data, including control
characters, to a Windows printer. The data is sent to the printer in the approved
Windows manner, as opposed to opening the LPT port and writing directly to it.
(Writing directly to the LPT port will not work under Windows NT or future Windows
versions.) 32-bit only. www.pcisys.net/~robr/download.htm
Writing a Raw String of Data to the Printer, Borland FAQ 651D Joe Hecht's PrtRaw.PAS demonstrates
a 16/32 bit TDxPrinter. Send data directly to any windows printer Printing Raw Data Printing Directly to a Printer, www.undu.com/DN970101/00000008.htm How to Print in Windows, Borland TI 188D Peter Below's UseNet Post showing how to print to HP LaserJet Direct Commands to Printer -- Passthrough/Escape, Borland TI 1497D Send command strings to printer Determining if a given printer is capable of printing a
PostScript file |
| Reports | Delphi Report Builder Components http://digital-metaphors.com/subpages/reportbuilder/main_delphi_components.html Printing Reports Using Word Printing Delphi controls using Quick Reports Printing a footer on only the last page of a report, Borland FAQ 2994D I have relatively modest printing requirements. The various report writers seem like overkill. How can I print fairly simple reports directly in Delphi? Formatting and Printing Output for the Printer HardCopy example on efg's Printer Projects Page |
| Reset | ResetPrinter. borland.public.delphi.winapi post by Peter Below (23 March
2000): The Printer object sometimes needs to be kicked to correctly load the selected printers device context: // call this procedure before the BeginDoc procedure ResetPrinter; var Device, Driver, Port: array[0..80] of Char; DevMode: THandle; begin Printer.GetPrinter(Device, Driver, Port, DevMode); Printer.SetPrinter(Device, Driver, Port, 0) end; |
| ResetTPrinter. Nick Ryan's UseNet Post for correcting some weird bug in Delphi's TPrinter that causes information to be retained from a previous print session (D3) | |
| Screen Capture |
Links
about Screen Capture involving printing Print a bitmap snapshop of virtual form than can be larger
than client area Delphi 5.0 freeware component to print a full form (on screen and offscreen portions)
and all components on that form. Scan a printed form, put the TBitmap in a TImage
at design time, and put necessary components such as TEdit, TCheckBox on
top of the image. At runtime, fill out the information on the screen and print the
completed form. This clever solution was contributed by Bob Dalton, President, Digital Logistics Software Company. |
| Shades of gray | See efg's Printer Demo #2 Postscript: This topic may need more research. While Printer Demo #2 shows shades of gray on many printers, slight color hues appear on at least one printers, Epson Color Stylus 850. |
| Shapes | Printing Shapes, pp. 14-16, Chapter 22 of Mastering Delphi 5 by Marco Cantù. |
| Spooler | Detecting How Many Jobs are in the Print Spooler,
Borland FAQ 1727D Adding
PRN file directly to Spooler in Windows WM_SPOOLERSTATUS. Windows message sent whenever a job is added or removed from the print queue. (but not in Windows 2000). See UseNetPost by Finn Tolderlund. Checking if Printer is Online List of jobs in the MS Windows print spooler Windows
95/98 Limiations withPrinting and Print Spooler |
| Status | See Online |
| Stop Print Jobs | Peter Below's UseNet Post with suggestion about how to stop all print jobs and delete them |
| StringGrid / TDBGrid |
How do I Print a TStringGrid / TDBGrid? Borland FAQ 2681D |
| TDeviceMode | "The TDeviceMode Structure" in Delphi 5
Developer's Guide by Teixeira and Pacheco, pp. 182-189 (on the CD)
Also see DEVMODE |
| Tips | Printer: Unofficial Delphi Developers FAQ www.gnomehome.demon.nl/uddf/pages/printer.htm Delphi Companion: Printing Printing in Delphi 5. Delphi 5 Developer's Guide by Teixeira and Pacheco in Online "CD" Chapters, pp. 154-207 Printing/Printer SWAG (Software Archive Group): 56
examples (efg's translation to Delphi of most of the C++ code in Microsoft's Knowledge Base Article Q1537 |
| TListBox | Printing the Contents of a TMemo or TListBox, Borland TI 785D |
| TMemo | Printing the Contents of a TMemo or TListBox, Borland TI 785D |
| TPanel | efg's UseNet Post explaining how to print a TPanel object |
| TPrintDialog | Setting the MaxPage property of the PrintDialog component. Borland FAQ 936D |
| TPrinter | Using an instance of TPrinter, Borland FAQ 2052D Setting the Pixels Per Inch Property of TPrinter, Borland TI 1517D Printing in Delphi without using the TPrinter Unit, Borland FAQ 1139D |
| Transparency | How can I use transparency while printing? Transparency on printers is not guaranteed. In fact, many do not correctly support anything but SRCCOPY, BLACKNESS, and WHITENESS for ROP codes (Postscript printers especially). The concept of ROP'ing bitmaps on the printer is an invalid concept anyway. You simply cannot ROP on something that's already printed. If it does work on a given driver, it is because the driver holds back the raster buffer for an entire page. You simply cannot count on that across the board. If you need transparency, you should do the work up front (combining images as needed), then send the image to the printer (as a DIB). [Thanks to Joe Hecht for E-mailing me this information. 19 Jan 99] |
| Trays | See Bins |
| TRichEdit |
TRichEdit Printing in Delphi 2 & Windows NT 4.0, Borland TI 1532D |
| TStringGrid | How do I Print a TStringGrid / TDBGrid? Borland FAQ 2681D |
| TTreeview | Peter Below's UseNet Post about how to print a treeview |
| TWIP | Peter Below's (Team B) 7 Oct 99 UseNet Post: "A twip is 1/20 of a point or 1/1440 of an inch. These units come from the typesetters trade as far as I know, they predate the computer age by quite some time." |
| Utilities | Garbo Shareware Library http://garbo.uwasa.fi/pc/printer.html http://garbo.uwasa.fi/windows/printer.html |
| Web Browser | How to print an HTML document from inside of
your application http://community.borland.com/article/0,1410,26402,00.html |
| Windows Limitations | Printing and Print Spooler http://msdn.microsoft.com/library/psdk/win95/chilimit_8wit.htm |
| WM_PRINT | Window Contents Capturing using WM_PRINT
Message www.fengyuan.com/article/wmprint.html |
Links Verified 29 Oct 2000
Updated 10 Jun 2003
since 1 Nov 1998