X11workbench Toolkit  1.0
Printer utility functions


int WBPrintPostScriptFile (const char *szPrinterName, const char *szFileName)
 Send postscript file to a printer (using lpr-cups or lpr on POSIX systems) More...
char * WBGetPrinterList (void)
 Get a list of printer names. More...

Detailed Description

Utility functions for sending prepared output to a printer, querying printer capabilities, and listing available printers.

Function Documentation

◆ WBGetPrinterList()

char* WBGetPrinterList ( void  )

Get a list of printer names.

a 'WBAlloc() pointer to a list of zero-byte terminated strings containing the printer names, ending with 2 zero-bytes

Use this function to get a list of printer names that can be used with WBPrintPostScriptFile(). On POSIX systems, it will be information from '/usr/local/etc/printcap' or '/etc/printcap'. When CUPS is installed, the '/usr/local/etc/printcap' or '/etc/printcap' file is maintained by CUPS. On non-POSIX systems, this function generates a system-dependent list of printers, which might consist of port names, or actual printer names, or a combination thereof.
NOTE: for IPP see RFC2911 section 4.4 and other related RFCs to request printer info. 'ipptest' may help resolve how to make these things work.
NOTE 2: for CUPS, use 'lpstat -s' and filter the output to get the printer names. URL should be http://localhost:631/printers/printername
NOTE 3: fallback to /etc/printcap /usr/local/etc/printcap and other sources

Header File: platform_helper.h

Definition at line 4955 of file platform_helper.c.

◆ WBPrintPostScriptFile()

int WBPrintPostScriptFile ( const char *  szPrinterName,
const char *  szFileName 

Send postscript file to a printer (using lpr-cups or lpr on POSIX systems)

szPrinterNamethe unique (system) name of the printer
szFileNamethe name of the file containing the postscript data
Zero on success, non-zero on error.

Use this function to send pre-prepared postscript data to a printer. On POSIX systems, it invokes 'lpr-cups' or 'lpr'. On non-POSIX systems, its operation is system-dependent. The version of 'lpr' that is run will be the CUPS version, whenever it is installed. On some systems this may require installing the 'bsd' compatible CUPS utilities
NOTE: This function may need to translate the postscript data into the raw printer format on non-POSIX systems, as needed. The 'ghostscript' package can do this, if present. Other options may be added as required. Entries in the 'printcap' file can configure the ghostscript filter for raster printers.
NOTE 2: some Linux packages require installing the cups version of lpr separately and possibly EXCLUSIVELY from the system version, example debian 'cups-bsd' vs 'lpr'.
NOTE 3: newer Linux versions don't support printcap mods based on CUPS. Using the IPP protocol to discover printers is probably a better idea.
NOTE 4: may need to dynamically link to CUPS libraries, as needed, or invoke ghostscript and/or lpd directly. Additional support for PDF, etc. may be in order.
NOTE 5: 'ipptool' may be the best CUPS method of sending files to a printer
example: ipptool -4 -t http://localhost:631/printers/printername get-printer-attributes.test

Header File: platform_helper.h

Definition at line 4932 of file platform_helper.c.