libXp(3Xp)
π libXp(3Xp) π
okay so we're in the XPRINT FUNCTIONS manual, bestie, and this page is all about libXp β the X Print Client Library. It's giving "print girlie" energy, but make it Unix π.
πΈ NAME πΈ
libXp - X Print Client Library
β¨ SYNOPSIS β¨
cc [ flag... ] file...-lXp [ library... ]
#include <X11/extensions/Print.h>
π¦ DESCRIPTION π¦
Okay bestie, so libXp provides public APIs to allow client applications to render to non-display devices. Yes, non-display devices β that's the whole assignment π
.
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 XpGetPrinterList() request. Once the application has selected a printer, it creates and sets a print context using XpCreateContext() and XpSetContext(). Slay.
The Print Context represents the embodiment of the printer selected. It is initialized by the Xprint server at 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. It's giving full printer lore π¨οΈβ¨.
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. Very teamwork, very demure π«Ά.
Once an application has set options within the print context, it makes calls such as 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 XpEndJob() is called, the resulting PDL is either sent to a print spooler or can be retrieved by the application itself. So the app can be like "send it" or "actually, hand it to me" π¬.
The developer basically has to make changes to the X application to make use of the X Print Service. No cap β that's the assignment.
A simple X application supplemented with some of the libXp routines might look like this:
#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 );
}
π SEE ALSO π
Xprt(1)XpCreateContext(3Xp)XpDestroyContext(3Xp)XpEndJob(3Xp)XpEndPage(3Xp)XpFreePrinterList(3Xp)XpGetAttributes(3Xp)XpGetPageDimensions(3Xp)XpGetPrinterList(3Xp)XpSetAttributes(3Xp)XpSetContext(3Xp)XpStartJob(3Xp)XpStartPage(3Xp)
And the vibe is brought to you by the X Print Service Extension Library π.
π signed off from the footer energy: X Version 11, libXp 1.0.4, libXp(3Xp) β no date on this one, bestie. bye! π β¨
π¦ where this page comes from
- arch rolling: libxp 1.0.4-3 Β· X11 AND X11-distribute-modifications-variant
- nixos 26.05: libxp 1.0.4
- nixpkgs unstable: libxp 1.0.4
- opensuse-leap 16.0: libXp-devel 1.0.4-bp160.1.12 Β· MIT
- opensuse-leap 16.0: libXp-devel 1.0.4-bp160.1.12 Β· MIT
- opensuse-leap 16.0: libXp-devel 1.0.4-bp160.1.12 Β· MIT
- opensuse-leap 16.0: libXp-devel 1.0.4-bp160.1.12 Β· MIT
- 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
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms