Sends data to the current printer (or spooler, if the user has a spooler set up). There are two syntaxes that you can use with DataWindows:
To |
Use |
---|---|
Send the contents of a DataWindow control or DataStore to the printer as a print job. |
|
Include a visual object, such as a window or a graph control in a print job. For a description of system print commands, see the PowerScript Reference. |
Third-party software required for printing
You must install the FieldSoftware PrinterCE SDK before you
can use print methods in PocketBuilder applications deployed to
a Pocket PC device. An evaluation version of this software is available
from the FieldSoftware Web site.
Sends the contents of a DataWindow control or DataStore object to the printer as a print job.
integer dwcontrol.Print ( { boolean canceldialog } )
Argument |
Description |
---|---|
dwcontrol |
The name of the DataWindow control, DataStore, or child DataWindow that contains the information to be printed. |
canceldialog (optional) |
A boolean value indicating whether you want to display a nonmodal dialog that allows the user to cancel printing. Values are:
|
Returns 1 if it succeeds and -1 if an error occurs. If any argument’s value is NULL, Print returns NULL.
Printed output uses the same fonts and layout that appear on screen for the DataWindow object.
Printing multiple DataWindows in a single job
PocketBuilder manages a print job by opening the job, sending
data, and closing the job. When you use Syntax 1, print job management
happens automatically. You do not need to use the PrintOpen and
PrintClose functions.
Use Syntax 1 to print the contents of a single DataWindow object. The Print method prints all the rows that have been retrieved. To print multiple DataWindows as a single job, do not use Print. Instead, open the print job with PrintOpen, call the PowerScript system function PrintDataWindow for each DataWindow, and close the job.
Events for DataWindow printing
When you use Print for DataWindow controls or DataStores,
it triggers a PrintStart event just before any data is sent to the
printer (or spooler), a PrintPage event for each page break, and
a PrintEnd event when printing is complete.
The PrintPage event has return codes that let you control whether to print the page about to be formatted. You can skip the upcoming page by returning a value of 1 in the PrintPage event.
This statement sends the contents of dw_employee to the current printer:
dw_employee.Print()
PrintDataWindow in the PowerScript Reference
Includes a visual object, such as a window or a graph control, in a print job that you have started with the PrintOpen function.
integer objectname.Print ( long printjobnumber, integer x, integer y {, integer width, integer height } )
Argument |
Description |
---|---|
objectname |
The name of the object that you want to print. The object must be either a window or an object whose ancestor type is DragObject, which includes all the controls that you can place in a window. |
printjobnumber |
The number the PrintOpen function assigns to the print job. |
x |
An integer whose value is the x coordinate on the page of the left corner of the object, in thousandths of an inch. |
y |
An integer whose value is the y coordinate on the page of the left corner of the object, in thousandths of an inch. |
width (optional) |
An integer specifying the printed width of the object in thousandths of an inch. If omitted, PocketBuilder uses the object’s original width. |
height (optional) |
An integer specifying the printed height of the object in thousandths of an inch. If omitted, PocketBuilder uses the object’s original height. |
Returns 1 if it succeeds and -1 if an error occurs. If any argument’s value is NULL, Print returns NULL.
PocketBuilder manages a print job by opening the job, sending data, and closing the job. When you use Syntax 2, you must call the PrintOpen function and the PrintClose or PrintCancel functions yourself to manage the process. For more information, see the PowerScript Reference.
Print area and margins
The print area is the physical page size minus any margins
in the printer itself. Depending on the printer, you might be able
to change margins using PrintSend and printer-defined escape sequences.
This example prints the CommandButton cb_close in its original size at location 500, 1000:
long Job
Job = PrintOpen( )
cb_close.Print(Job, 500,1000)
PrintClose(Job)
This example opens a print job, which defines a new page, then prints a title using the third syntax of Print. Then it uses this syntax of Print to print a graph on the first page and a window on the second page:
long Job
Job = PrintOpen( )
Print(Job, "Report of Year-to-Date Sales")
gr_sales1.Print(Job, 1000,PrintY(Job)+500, &
6000,4500)
PrintPage(Job)
w_sales.Print(Job, 1000,500, 6000,4500)
PrintClose(Job)
Print in the PowerScript Reference
PrintClose in the PowerScript Reference
PrintOpen in the PowerScript Reference
PrintScreen in the PowerScript Reference
Copyright © 2004. Sybase Inc. All rights reserved. |
![]() |