通过libcups以编程方式打印双工的正确方法是什么?

时间:2013-09-25 11:40:22

标签: printing c cups c++

这是我目前采用的方法,不能按预期工作。它只是在所有三种情况下打印单面。

#include <cups/cups.h>

int main(int argc, char *argv[])
{
cupsSetUser("myuser");
cups_dest_t *defaultP = cupsGetDest (NULL, NULL,num_dests,dests);

int jobid;
int num_options = 0;
cups_option_t *options=NULL;

//SIMPLEX
num_options = cupsAddOption ("Duplex", "None",num_options,&options);
jobid = cupsPrintFile(defaultP->name,"/home/myuser/work/TEST.ps","Test Print SIMPLEX",
                      defaultP->num_options,defaultP->options);
num_options = cupsRemoveOption("Duplex",num_options,&options);

//DUPLEX Long Edge
num_options = cupsAddOption ("Duplex", "DuplexNoTumble",num_options,&options);
jobid = cupsPrintFile(defaultP->name,"/home/myuser/work/TEST.ps","Test Print DUPLEX Long Edge ",
                      defaultP->num_options,defaultP->options);
num_options = cupsRemoveOption("Duplex",num_options,&options);

//DUPLEX Short Edge
num_options = cupsAddOption ("Duplex", "DuplexTumble",num_options,&options);
jobid = cupsPrintFile(defaultP->name,"/home/myuser/work/TEST.ps","Test Print DUPLEX Short Edge ",
                      defaultP->num_options,defaultP->options);
num_options = cupsRemoveOption("Duplex",num_options,&options);
}

1 个答案:

答案 0 :(得分:1)

这是正确的方法。每个cupsPrintFile(...)的第二行中有错误的参数。应该是num_options, &options而不是defaultP->num_options,defaultP->options