[cups-devel] How to get a list of (or default) page size?
Olivier Guillion - Myriad
olivier at myriad-online.com
Wed May 7 03:43:39 PDT 2014
Hi,
I'm working on Ubuntu 13.10, using cups 1.7rc1.
I would want to get the dimension and margin of the supported page size for
each printer (or at least the default one). Because the PPD API is marked as
deprecated, I'm trying not to use it.
Here is where I am, after 10 hours of struggle (in plain C):
------------
num_dests= cupsGetDests(&dests);
for (i=0,dest=dests;i<num_dests;i++,dest++)
{
http=cupsConnectDest(dest,CUPS_DEST_FLAGS_NONE,5000,
&cancel,resource,1023,NULL,NULL); // 5 sec timeout
dinfo=cupsCopyDestInfo(http,dest);
// trying to get all possible media
nbmedia=cupsGetDestMediaCount(http,dest,dinfo,CUPS_MEDIA_FLAGS_DEFAULT);
printf("%d medias\n",nbmedia);
// always get 0 !!
}
---------------
This code is a simplified version, in which error check has been removed but I
get a valid http_t pointer, as well as a valid dinfo.
If I replace CUPS_MEDIA_FLAGS_DEFAULT by CUPS_MEDIA_FLAGS_BORDERLESS (the
latter is the only one that provides a non-null number of media), I get 1215
media, with paper size of about 137 meters long. I don't own a printer for
football fields, I promise! :)
As a side note,
cupsGetDestMediaByName(http,dest,dinfo,"iso_a4_210x297mm",
CUPS_MEDIA_FLAGS_DEFAULT,&size)
gives the right size and margins, but I don't know how I can get the proper
default media name for the printer.
Thanks for any help you could provide,
Olivier
Olivier Guillion
Myriad
26 rue Michel de Montaigne
31200 Toulouse
FRANCE
-------- WebSite -----------
http://www.myriad-online.com
Download here the latest version of our shareware programs, view the online
tutorials or get info about Myriad and its activities.
---------------------------------
More information about the cups
mailing list