summaryrefslogtreecommitdiff
path: root/man/libXp.man
blob: df7cf72650f3ef6961cb02923f00a7a269b9ce7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
.\"
.\" Copyright 1996 Hewlett-Packard Company
.\" Copyright 1996 International Business Machines Corp.
.\" Copyright 1996, 1999, 2004, Oracle and/or its affiliates. All rights reserved.
.\" Copyright 1996 Novell, Inc.
.\" Copyright 1996 Digital Equipment Corp.
.\" Copyright 1996 Fujitsu Limited
.\" Copyright 1996 Hitachi, Ltd.
.\" Copyright 1996 X Consortium, Inc.
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining a
.\" copy of this software and associated documentation files (the "Software"),
.\" to deal in the Software without restriction, including without limitation
.\" the rights to use, copy, modify, merge, publish, distribute,
.\" sublicense, and/or sell copies of the Software, and to permit persons
.\" to whom the Software is furnished to do so, subject to the following
.\" conditions:
.\"
.\" The above copyright notice and this permission notice shall be
.\" included in all copies or substantial portions of the Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
.\" IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.
.\"
.\" Except as contained in this notice, the names of the copyright holders
.\" shall not be used in advertising or otherwise to promote the sale, use
.\" or other dealings in this Software without prior written authorization
.\" from said copyright holders.
.\"
.TH libXp 3Xp __xorgversion__ "XPRINT FUNCTIONS"
.SH NAME
libXp \- X Print Client Library
.SH SYNOPSIS
.B cc
[
.B flag...
]
file...-lXp
[
.B library...
]
.BR
.nf
\&#include <X11/extensions/Print.h>
.fi
.SH DESCRIPTION
.LP
libXp provides public APIs to allow client applications to render to non-display devices.

When an application wishes to print, it makes a display connection to the X print server and asks
to see the list of
printers available with an
.I XpGetPrinterList()
request. Once the application has selected a printer, it creates and sets a print context using
.I XpCreateContext()
and
.I XpSetContext().

The Print Context represents the embodiment of the printer selected. It is initialized by the
Xprint server at
.I XpCreateContext()
time to contain a printer's default capabilities, as well as, the description of its overall
capabilities, and to maintain
the state of settings on the printer, the state of rendering against the printer, and the rendered
output.

The Print Context affects how the DDX driver generates its page description language (PDL) and how
the PDL is submitted to
a spooler. The print context may also affect fonts and other elements in the dix layer of the X
Print Server. The print
contexts can be shared among processes. Applications can enlist the help of secondary processes to
manipulate print options
in the Print context rather than taking on the task directly.

Once an application has set options within the print context, it makes calls such as
.I XpStartJob()
to delineate jobs, documents, and pages within a sequence of normal X calls.

A job is a collection of documents, where each document is in turn a collection of pages. When
.I XpEndJob()
is called, the resulting PDL is either sent to a print spooler or can be retrieved by the
application itself.

The developer basically has to make changes to the X application to make use of the X Print
Service.
.LP

A simple X application supplemented with some of the libXp routines might look like this:


.\" Note: C Comments and include statements in the sample code must use the
.\" zero-width non-printing nroff entity \& to prevent the C pre-processor
.\" from processing or stripping them out during the build

.nf

\&#include <X11/Xlib.h>
\&#include <X11/extensions/Print.h>

main()
{
    Display *pdpy;
    Screen *pscreen;
    Window pwin;
    XPPrinterList plist;
    XPContext pcontext;
    int plistCnt;
    char *attrPool;
\&#define NPOOLTYPES 5
    XPAttributes poolType[NPOOLTYPES] = {XPJobAttr,XPDocAttr,XPPageAttr,
					 XPPrinterAttr,XPServerAttr};
    int i;
    unsigned short width, height;
    XRectangle rect;
    char *printServerName = ":1";
    char *mylaser = "varos";

    /\&*
     * connect to the X print server
     *\&/
    pdpy = XOpenDisplay( printServerName );

    /\&*
     * see if the printer "mylaser" is available
     *\&/

    plist =  XpGetPrinterList (pdpy, mylaser, &plistCnt );

    /\&*
     * Initialize a print context representing "mylaser"
     *\&/

    pcontext = XpCreateContext( pdpy, plist[0].name );
    XpFreePrinterList( plist );

	/\&*
	 * Possibly modify attributes in the print context
	 *\&/
    for(i=0;i < NPOOLTYPES;i++) {
	if(attrPool = XpGetAttributes( pdpy, pcontext, poolType[i] )) {
	    /\&* twiddle attributes *\&/
	    /\&*
	      XpSetAttributes( pdpy, pcontext, poolType[i],
	                       attrPool, XPAttrMerge );
	    *\&/
	    XFree(attrPool);
	}
    }


    /\&*
     * Set a print server, then start a print job against it
     *\&/

    XpSetContext( pdpy, pcontext );
    XpStartJob( pdpy, XPSpool );

    /\&*
     * Generate the first page
     *\&/

    pscreen = XpGetScreenOfContext( pdpy, pcontext );
    XpGetPageDimensions( pdpy, pcontext, &width, &height,
			 &rect);
    pwin = XCreateSimpleWindow( pdpy, RootWindowOfScreen( pscreen ),
				rect.x, rect.y, rect.width, rect.height, 2,
				BlackPixelOfScreen( pscreen),
				WhitePixelOfScreen( pscreen));

    XpStartPage( pdpy, pwin );
    /\&* usual rendering stuff..... *\&/
    XpEndPage( pdpy );

    XpStartPage( pdpy, pwin );
    /\&* some more rendering.....   *\&/
    XpEndPage( pdpy );

    /\&*
     * End the print job - the final results are sent by the X print
     * server to the spooler sub system.
     *\&/

    XpEndJob( pdpy );
    XpDestroyContext( pdpy, pcontext );
    XCloseDisplay( pdpy );
}

.fi
.SH "SEE ALSO"
.BR Xprt (1),
.BR XpCreateContext (3Xp),
.BR XpDestroyContext (3Xp),
.BR XpEndJob (3Xp),
.BR XpEndPage (3Xp),
.BR XpFreePrinterList (3Xp),
.BR XpGetAttributes (3Xp),
.BR XpGetPageDimensions (3Xp),
.BR XpGetPrinterList (3Xp),
.BR XpSetAttributes (3Xp),
.BR XpSetContext (3Xp),
.BR XpStartJob (3Xp),
.BR XpStartPage (3Xp)

.I X Print Service Extension Library