[cups-devel] how to get supported media information for a particular printer

My Sadhukhan psadhukhan at gmail.com
Mon Jul 31 03:01:11 PDT 2017


Hi All,

I was trying to find the supported media for a particular printer using
non-ppd based API but am encountering a problem.

























*void getMedia(char *name){    cups_dest_t dest;    dest.name
<http://dest.name> = name;    dest.instance = name;    dest.is_default =
0;    cups_dinfo_t *info = cupsCopyDestInfo(CUPS_HTTP_DEFAULT, &dest);;
if (info == NULL) {        printf("CopyDestInfo Request failed %s\n",
cupsLastErrorString());    }    ipp_attribute_t *media =
cupsFindDestSupported(CUPS_HTTP_DEFAULT,
&dest, info, CUPS_MEDIA);    if (media != NULL) {        int i, count =
ippGetCount(media);        printf("count %d\n", count);        for (i = 0;
i < count; i++)            printf(" %s\n", ippGetString(media, i,
NULL));    } else {        printf("FindDestSupported Request failed %s\n",
cupsLastErrorString());    }}int main(void){
getMedia("Ricoh-Aficio-MP-5002");*
*}*

I am getting
-----------
CopyDestInfo Request failed (null)
FindDestSupported Request failed Invalid argument
-----------

Earlier, I was using
char filename = cupsGetPPD("Ricoh-Aficio-MP-5002");
ppd_file_t *ppd = ppdOpenFile(filename);
ppd_option_t *optionPage = ppdFindOption(ppd, "PageSize") and get
optionPage->choices->text
to get the below supported media size information obtained from that
printer ppd.
That is, in* /etc/cups/ppd/Ricoh-Aficio-MP-5002.ppd*,
I have this and I am interested in getting "A3", "A4", "A5", "A6", "B4",
"B5"..."EngQuatro.FullBleed" etc.

but now, since ppd API is deprecated, I want to use the new IPP-based api.

Could anyone suggest what I need to use in above code?

*%========== Information About Media Sizes ==========

*DefaultImageableArea: A4
*ImageableArea A3/A3: "12 12 830 1179"
*ImageableArea A4/A4: "12 12 583 830"
*ImageableArea A5/A5: "12 12 408 583"
*ImageableArea A6/A6: "12 12 285 408"
*ImageableArea B4/B4 (JIS): "12 12 717 1020"
*ImageableArea B5/B5 (JIS): "12 12 504 717"
*ImageableArea B6/B6 (JIS): "12 12 351 504"
*ImageableArea Legal/Legal: "12 12 600 996"
*ImageableArea GovernmentLG/8.25x14: "12 12 582 996"
*ImageableArea EngQuatro/8x10: "12 12 564 708"
*ImageableArea GLT/8x10.5: "12 12 564 744"
*ImageableArea Letter/Letter: "12 12 600 780"
*ImageableArea Statement/5.5x8.5: "12 12 384 600"
*ImageableArea F/8x13: "12 12 564 924"
*ImageableArea Folio/8.25x13: "12 12 583 923"
*ImageableArea FanFoldGermanLegal/8.5x13: "12 12 600 924"
*ImageableArea Tabloid/11x17: "12 12 780 1212"
*ImageableArea 12x18/12x18: "12 12 852 1284"
*ImageableArea 11x15/11x15: "12 12 780 1068"
*ImageableArea 10x14/10x14: "12 12 708 996"
*ImageableArea 10x15/10x15: "12 12 708 1068"
*ImageableArea 11x14/11x14: "12 12 780 996"
*ImageableArea Executive/Executive: "12 12 510 744"
*ImageableArea Env10/Com10 Env.: "12 12 285 672"
*ImageableArea EnvMonarch/Monarch Env.: "12 12 267 528"
*ImageableArea EnvC5/C5 Env.: "12 12 447 637"
*ImageableArea EnvC6/C6 Env.: "12 12 311 447"
*ImageableArea DLEnv/DL Env.: "12 12 299 611"
*ImageableArea 8Kai/8K: "12 12 745 1094"
*ImageableArea 16Kai/16K: "12 12 541 745"
*ImageableArea A3.FullBleed/A3 (Full Bleed): "0 0 842 1190"
*ImageableArea A4.FullBleed/A4 (Full Bleed): "0 0 595 841"
*ImageableArea A5.FullBleed/A5 (Full Bleed): "0 0 420 594"
*ImageableArea A6.FullBleed/A6 (Full Bleed): "0 0 297 419"
*ImageableArea B4.FullBleed/B4 (JIS) (Full Bleed): "0 0 729 1031"
*ImageableArea B5.FullBleed/B5 (JIS) (Full Bleed): "0 0 516 728"
*ImageableArea B6.FullBleed/B6 (JIS) (Full Bleed): "0 0 363 515"
*ImageableArea Legal.FullBleed/Legal (Full Bleed): "0 0 612 1007"
*ImageableArea GovernmentLG.FullBleed/8.25x14 (Full Bleed): "0 0 594 1007"
*ImageableArea EngQuatro.FullBleed/8x10 (Full Bleed): "0 0 576 719"
...
..

Thanks & Regards
Prasanta


More information about the cups-devel mailing list