Prima::Printer - system printing services |
Prima::Printer - system printing services
Prima::Printer is a descendant of Prima::Drawable class. It provides access to the system printing services, where available. If the system provides no graphics printing, the default PostScript (tm) interface module Prima::PS::Printer is used instead.
Prima::Printer objects are never created directly. During the life of a program, there exists only one instance of a printer object, created automatically by Prima::Application. Prima::Printer object is created only when the system provides graphic printing capabilities - drawing and painting procedures on a graphic device. If there are no such API, Prima::Application creates an instance of Prima::PS::Printer instead, which emulates a graphic device, producing PostScript output. The discretion between Prima::Printer and Prima::PS::Printer is transparent for both the user and the programmer, unless printer device specific adjustments desired.
A printing session is started by begin_doc()
, which switches
the object into the painting state. If finished by end_doc()
,
the document is delivered to a printer device. Alternative finishing
method, abort_doc()
, terminates the printing session with
no information printed, unless the document is multi-paged
and pages were sent to the printer via new_page()
.
A printer object ( that means, both Prima::Printer and Prima::PS::Printer )
provides selection of the printer mechanism. printers()
method
returns array of hashes, each describing a printer device; get_default_printer()
returns a default printer string identifier. A printer device can be selected
via the ::printer
property.
The capabilities of the selected printer can be adjusted via setup_dialog()
method, that invokes a system-provided ( or, in case of Prima::PS::Printer,
toolkit-provided ) printer setup dialog, so the user can adjust settings of a
printer device.
It depends on the system, whether the setup changes only the instance settings, or
the default behavior of a printer driver is affected for all programs.
Some printer capabilities can be queried by the ::size()
property,
that reports the dimension of the page, the ::resolution()
property,
that reports the DPI resolution selected by a printer driver and
font list ( by fonts()
method ), available for usage.
Typical code that prints the document looks like
my $p = $::application-> get_printer; if ( $p-> begin_doc) { ... draw ... $p-> end_doc; }
In addition, a standard package Prima::PrintDialog can be recommended so the user can select a printer device and adjust its setup interactively.
setup_dialog()
.
setup_dialog()
.
abort_doc()
is called, so some information
could still been printed.
begin_doc("")
call.
new_page()
and abort_doc()
methods work. The information
mode is exited via end_paint_info()
method.
abort_doc()
.
begin_paint_info()
and returns the object into the disabled painting state.
undef
,
returns one fonts hash for each of the font families that match the ENCODING
string. If ENCODING is '' or undef
, no encoding match is performed.
If ENCODING is not valid ( not present in font_encodings
result), it is
treated as if it was '' or undef
.
In the special case, when both NAME and ENCODING are '' or undef
,
each font metric hash contains element encodings
, that points to
array of the font encodings, available for the fonts of NAME font family.
Dmitry Karasik, <dmitry@karasik.eu.org>.
Prima, the Prima::Drawable manpage, the Prima::PS::Printer manpage
Prima::Printer - system printing services |