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

Michael Sweet msweet at apple.com
Wed Aug 2 06:15:20 PDT 2017


What version of CUPS are you using?

(there have been a number of bug fixes over the years...)

> On Aug 2, 2017, at 1:17 AM, My Sadhukhan <psadhukhan at gmail.com> wrote:
> 
> I checked cupsCheckDestSupported() before calling cupsFIndDestSupported()
> for options like CUPS_COPIES,CUPS_FINISHINGS,CUPS_MEDIA,CUPS_ORIENTATION,
> CUPS_SIDES etc and all of them return false,
> although the printer being queried is a MFP and supports duplex,
> orientation etc and I can print a test-page out of it.
> Is it a bug in cups or am I missing calling/initialising something?
> 
> Regards
> Prasanta
> 
> On Tue, Aug 1, 2017 at 10:56 AM, My Sadhukhan <psadhukhan at gmail.com> wrote:
> 
>> Thanks Michael.
>> I used cupsGetNamedDest to initialise cups_dest_t but it still fails in
>> cupsFindDestSupported().
>> ----------
>> void getMedia(char *name)
>> {
>>    cups_dest_t *dest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, name, NULL);
>>    if (dest == NULL) {
>>        printf("cupsGetNamedDest failed %s\n", cupsLastErrorString());
>>        return;
>>    } else {
>>        printf("dest name %s\n", dest->name);
>>    }
>>    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());
>>    }
>> }
>> 
>> ----------------------------citing----------
>> dest name Ricoh-Aficio-MP-5002
>> CopyDestInfo Request failed successful-ok
>> FindDestSupported Request failed Invalid argument
>> ----------------
>> I am not sure if cupsCopyDestInfo() failed or not . The manual does not
>> say the return value if there is error. cupsGetLastErrorString() conveys
>> there is no error yet "info" is NULL.
>> 
>> Could you please suggest as to what else is going wrong?
>> I could not find "_cups_dinfo_s" structure definition in
>> https://www.cups.org/doc/cupspm.html#cups_dinfo_t.
>> Also, cupsFindDestSupported() manual shows "Find the default value(s) for
>> the given option." which is same as cupsFindDestDefault(). I think the
>> former should be texted as "Find supported value(s) for the given option".
>> 
>> Regards
>> Prasanta
>> 
>> On Mon, Jul 31, 2017 at 7:11 PM, Michael Sweet <msweet at apple.com> wrote:
>> 
>>> You can't initialize a cups_dest_t structure directly like that and have
>>> it work.
>>> 
>>> Use:
>>> 
>>>    cups_dest_t *dest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, name, NULL);
>>> 
>>> Then cupsCopyDestInfo will have the information it needs to get the
>>> supported media for you...
>>> 
>>> 
>>>> On Jul 31, 2017, at 6:01 AM, My Sadhukhan <psadhukhan at gmail.com> wrote:
>>>> 
>>>> 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
>>>> _______________________________________________
>>>> cups-devel mailing list
>>>> cups-devel at cups.org
>>>> https://lists.cups.org/mailman/listinfo/cups-devel
>>> 
>>> _________________________________________________________
>>> Michael Sweet, Senior Printing System Engineer
>>> 
>>> _______________________________________________
>>> cups-devel mailing list
>>> cups-devel at cups.org
>>> https://lists.cups.org/mailman/listinfo/cups-devel
>>> 
>> 
>> 
> _______________________________________________
> cups-devel mailing list
> cups-devel at cups.org
> https://lists.cups.org/mailman/listinfo/cups-devel

_________________________________________________________
Michael Sweet, Senior Printing System Engineer



More information about the cups-devel mailing list