---
name: "kdk_printer_set_options"
section: "3"
platform: "linux"
package: "libkysdk-system"
version: "3.0.1.4-1"
release: "Arch Linux 2026-11-07"
platforms: ["linux"]
url: "https://carta.tech/man/kdk_printer_set_options"
---

# kdk\_printer\_set\_options(3)

设置打印参数

## NAME

kdk\_printer\_get\_available\_list - 设置打印参数

## SYNOPSIS

```
#include <libkyprinter.h>

extern void kdk_printer_set_options(int number_up, const char *media, const char *number_up_layout, const char *sides);

Link with -lkyprinter.
```

## Detailed Description

The main function of the interface is to set the printing parameters, each setting will clear the previous set of printing parameters, this setting is a global setting, after setting, all printers will use this parameter to print.

The argument *number\_up* is cups properties, a piece of paper to print several pages, such as 2 4 etc.

The argument *media* is cups properties, paper type, such as "A4".

The argument *number\_up\_layout* is cups properties, such as "lrtb".

The argument *sides* is cups properties, such as "one-sided", "two-sided-long-edge", "two-sided-short-edge".

## RETURN VALUE

No return value

## EXAMPLES

```
#include "libkyprinter.h"
#include <stdio.h>
int main()
{
    int index = 0;
    //获取打印机列表
    char **printers = kdk_printer_get_available_list();
    while (printers[index])
    {
        printf("%zd: %s0, index + 1, printers[index]);
        //取消当前打印机所有打印任务
        kdk_printer_cancel_all_jobs(printers[index]);
        //获取url对应的文件名
        char *url = "http://www.cztouch.com/upfiles/soft/testpdf.pdf";
        int res = -1;
        char *filename = kdk_printer_get_filename(url); //从完整路径名中解析出文件名称，例如：/home/test/abc.txt,解析完成后为abc.txt
        printf("filename = %s0, filename);
        //设置打印参数
        kdk_printer_set_options(2, "A4", "lrtb", "two-sided-long-edge");
        //下载
        res = kdk_printer_print_download_remote_file(url, filename);
        printf("[%s] res = %d0, __FUNCTION__, res);
        printf("[%s] filepath = %s0, __FUNCTION__, filename);
        //打印
        int job_id = kdk_printer_print_local_file(printers[index], filename);
        if (job_id == 0)
        {
            //打印失败
            printf("[%s] create print job fail0, __FUNCTION__);
        }
        else
        {
            //打印成功，等待一会获取任务状态
            sleep(10);
            int status = kdk_printer_get_job_status(printers[index], job_id);
        }
        index++;
        free(filename);
    }
    kdk_printer_freeall(printers);
    return 0;
}
```

## CONFORMING TO

These functions are as per the withdrawn POSIX.1e draft specification. The following functions are Linux extensions: **kdk\_printer\_get\_list**(), **kdk\_printer\_get\_available\_list**(), **kdk\_printer\_print\_download\_remote\_file**(), **kdk\_printer\_print\_local\_file**(), **kdk\_printer\_cancel\_all\_jobs**(), **kdk\_printer\_get\_status**(), **kdk\_printer\_get\_job\_status**(), **kdk\_printer\_get\_filename**() and **kdk\_printer\_freeall**().

## SEE ALSO

[**kdk\_printer\_get\_list**(3)](/man/kdk_printer_get_list/3.md), [**kdk\_printer\_get\_available\_list**(3)](/man/kdk_printer_get_available_list/3.md), [**kdk\_printer\_print\_download\_remote\_file**(3)](/man/kdk_printer_print_download_remote_file/3.md), [**kdk\_printer\_print\_local\_file**(3)](/man/kdk_printer_print_local_file/3.md), [**kdk\_printer\_cancel\_all\_jobs**(3)](/man/kdk_printer_cancel_all_jobs/3.md), [**kdk\_printer\_get\_status**(3)](/man/kdk_printer_get_status/3.md), [**kdk\_printer\_get\_job\_status**(3)](/man/kdk_printer_get_job_status/3.md), [**kdk\_printer\_get\_filename**(3)](/man/kdk_printer_get_filename/3.md) and [**kdk\_printer\_freeall**(3)](/man/kdk_printer_freeall/3.md).
