빠른 요약:반환된 용지 크기는 lpoptions
"w154h64"와 유사하지만 libcups API를 사용하면 반환된 용지 크기는 "custom_54.19x22.27mm_54.19x22.27mm"와 같습니다.
노트: 이것은 CUPS 2.3.1이 설치된 Ubuntu 20.04.6 LTS에 있습니다.
lpoptions
이것이 내 DYMO LabelWriter 450 Turbo 프린터의 용지 크기를 얻기 위해 사용할 때 얻은 것입니다. (명확성을 위해 출력을 래핑했습니다.)
$ lpoptions -p LabelWriter-450-Turbo -l
PageSize/Media Size: w154h64 w72h154 w72h72 w162h90 w54h144 w118h252
w167h188 w79h252 w167h252 *w167h288 w154h198 w82h248 w154h64.1
w79h252.1 w102h252 w154h286 w154h198.1 w54h424 w131h221 w57h248
w54h144.1 w72h72.1 w72h72.2 w162h90.1 30334_2-1_4_in_x_1-1_4_in w73h86
w72h154.1 w118h252.1 w54h203 w54h180 w36h136 w72h108 w65h90 w167h288.1
w168h252 w144h169 w71h144 w144h252 w80h144 w162h504
30383_PC_Postage_3-Part w167h540 30384_PC_Postage_2-Part w167h756
30387_PC_Postage_EPS w167h188.1 w176h292 w167h288.2 w112h126 w79h252.2
w102h252.1 w154h286.1 w154h286.2 w154h198.2 w63h419 w139h221 w36h144
w108h539 w167h539 w154h7680 w154h792 Custom.WIDTHxHEIGHT
Resolution/Output Resolution: *300dpi 300x600dpi
DymoHalftoning/Halftoning: Default *ErrorDiffusion NLL
DymoPrintDensity/Print Density: Light Medium *Normal Dark
DymoPrintQuality/Print Quality: *Text Graphics
libcups API를 사용하여 프로그래밍 방식으로 동일한 용지 크기 목록을 얻을 수 있기를 원합니다. 나는 두 가지 다른 방법으로 용지 크기를 가져오는 이 프로그램을 작성했습니다. ( cupsFindDestSupported
및
cupsGetDestMediaByIndex
) 이 두 가지 방법은 서로 일치하지만 내가 얻는 것과는 완전히 다릅니다 lpoptions
.
프로그램:
/* Compile with:
* gcc -o media `cups-config --cflags` media.c `cups-config --libs`
*/
#include <stdio.h>
#include <cups/cups.h>
int print_dest(void *user_data, unsigned unused_flags, cups_dest_t *dest)
{
if (dest->instance)
printf("%s/%s\n", dest->name, dest->instance);
else
puts(dest->name);
cups_dinfo_t *info = cupsCopyDestInfo (CUPS_HTTP_DEFAULT, dest);
if (cupsCheckDestSupported(CUPS_HTTP_DEFAULT, dest, info,
CUPS_MEDIA, NULL)) {
ipp_attribute_t *media =
cupsFindDestSupported(CUPS_HTTP_DEFAULT, dest, info,
CUPS_MEDIA);
int i, count = ippGetCount(media);
puts("media supported:");
for (i = 0; i < count; i ++)
printf(" %s\n", ippGetString(media, i, NULL));
}
unsigned flags = 0;
cups_size_t size;
int i;
int count = cupsGetDestMediaCount(CUPS_HTTP_DEFAULT,
dest, info,
flags);
printf ("count = %d\n", count);
for (i = 0; i < count; i ++) {
if (cupsGetDestMediaByIndex(CUPS_HTTP_DEFAULT, dest, info,
i, flags,
&size)) {
const char *loc =
cupsLocalizeDestMedia (CUPS_HTTP_DEFAULT, dest, info,
flags, &size);
printf(" %s:\n", size.media);
printf(" Local: %s\n", loc ? loc : "N/A");
printf(" Width: %.2fin\n", size.width / 2540.0);
printf(" Length: %.2fin\n", size.length / 2540.0);
printf(" Bottom: %.2fin\n", size.bottom / 2540.0);
printf(" Left: %.2fin\n", size.left / 2540.0);
printf(" Right: %.2fin\n", size.right / 2540.0);
printf(" Top: %.2fin\n", size.top / 2540.0);
}
}
return (1);
}
int main(void)
{
cupsEnumDests(CUPS_DEST_FLAGS_NONE, 1000, NULL, 0, 0, print_dest, NULL);
return (0);
}
이 프로그램의 출력은 다음과 같습니다.
LabelWriter-450-Turbo
media supported:
custom_54.19x22.27mm_54.19x22.27mm
custom_25.4x54.02mm_25.4x54.02mm
custom_1x1in_1x1in
custom_2.25x1.25in_2.25x1.25in
custom_0.75x2in_0.75x2in
custom_41.32x88.9mm_41.32x88.9mm
custom_58.67x66.04mm_58.67x66.04mm
custom_27.86x88.9mm_27.86x88.9mm
custom_58.67x88.9mm_58.67x88.9mm
custom_58.76x101.6mm_58.76x101.6mm
custom_54.02x69.85mm_54.02x69.85mm
custom_28.62x87.29mm_28.62x87.29mm
custom_35.73x88.56mm_35.73x88.56mm
custom_54.02x100.84mm_54.02x100.84mm
custom_19.05x149.27mm_19.05x149.27mm
custom_46.06x77.81mm_46.06x77.81mm
custom_19.9x87.29mm_19.9x87.29mm
custom_25.74x30.14mm_25.74x30.14mm
custom_19.05x71.46mm_19.05x71.46mm
custom_0.75x2.5in_0.75x2.5in
custom_12.7x47.67mm_12.7x47.67mm
custom_1x1.5in_1x1.5in
custom_22.86x31.75mm_22.86x31.75mm
custom_58.93x88.9mm_58.93x88.9mm
custom_50.8x59.52mm_50.8x59.52mm
custom_24.81x50.8mm_24.81x50.8mm
custom_2x3.5in_2x3.5in
custom_27.94x50.8mm_27.94x50.8mm
custom_2.25x7in_2.25x7in
custom_58.76x190.5mm_58.76x190.5mm
custom_58.76x266.7mm_58.76x266.7mm
custom_61.89x102.87mm_61.89x102.87mm
custom_39.29x44.45mm_39.29x44.45mm
custom_22.01x147.66mm_22.01x147.66mm
custom_49.02x77.81mm_49.02x77.81mm
custom_0.5x2in_0.5x2in
custom_38.02x189.99mm_38.02x189.99mm
custom_58.76x189.99mm_58.76x189.99mm
custom_54.02x2709.33mm_54.02x2709.33mm
custom_54.02x279.4mm_54.02x279.4mm
custom_min_3.53x3.53mm
custom_max_56.9x2709.33mm
count = 40
custom_12.7x47.67mm_12.7x47.67mm:
Local: N/A
Width: 0.50in
Length: 1.88in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.23in
custom_0.5x2in_0.5x2in:
Local: N/A
Width: 0.50in
Length: 2.00in
Bottom: 0.06in
Left: 0.04in
Right: 0.04in
Top: 0.22in
custom_0.75x2in_0.75x2in:
Local: N/A
Width: 0.75in
Length: 2.00in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.23in
custom_0.75x2.5in_0.75x2.5in:
Local: N/A
Width: 0.75in
Length: 2.50in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.23in
custom_19.05x71.46mm_19.05x71.46mm:
Local: N/A
Width: 0.75in
Length: 2.81in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.22in
custom_19.05x149.27mm_19.05x149.27mm:
Local: N/A
Width: 0.75in
Length: 5.88in
Bottom: 0.06in
Left: 0.04in
Right: 0.04in
Top: 0.22in
custom_19.9x87.29mm_19.9x87.29mm:
Local: N/A
Width: 0.78in
Length: 3.44in
Bottom: 0.06in
Left: 0.00in
Right: 0.04in
Top: 0.22in
custom_22.01x147.66mm_22.01x147.66mm:
Local: N/A
Width: 0.87in
Length: 5.81in
Bottom: 0.06in
Left: 0.00in
Right: 0.04in
Top: 0.23in
custom_22.86x31.75mm_22.86x31.75mm:
Local: N/A
Width: 0.90in
Length: 1.25in
Bottom: 0.06in
Left: 0.07in
Right: 0.04in
Top: 0.23in
custom_24.81x50.8mm_24.81x50.8mm:
Local: N/A
Width: 0.98in
Length: 2.00in
Bottom: 1.19in
Left: 0.00in
Right: 0.04in
Top: 0.06in
custom_1x1in_1x1in:
Local: N/A
Width: 1.00in
Length: 1.00in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.09in
custom_1x1.5in_1x1.5in:
Local: N/A
Width: 1.00in
Length: 1.50in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.23in
custom_25.4x54.02mm_25.4x54.02mm:
Local: N/A
Width: 1.00in
Length: 2.13in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.09in
custom_25.74x30.14mm_25.74x30.14mm:
Local: N/A
Width: 1.01in
Length: 1.19in
Bottom: 0.06in
Left: 0.00in
Right: 0.04in
Top: 0.06in
custom_27.86x88.9mm_27.86x88.9mm:
Local: N/A
Width: 1.10in
Length: 3.50in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.23in
custom_27.94x50.8mm_27.94x50.8mm:
Local: N/A
Width: 1.10in
Length: 2.00in
Bottom: 0.06in
Left: 0.12in
Right: 0.04in
Top: 0.31in
custom_28.62x87.29mm_28.62x87.29mm:
Local: N/A
Width: 1.13in
Length: 3.44in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.20in
custom_35.73x88.56mm_35.73x88.56mm:
Local: N/A
Width: 1.41in
Length: 3.49in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.22in
custom_38.02x189.99mm_38.02x189.99mm:
Local: N/A
Width: 1.50in
Length: 7.48in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.22in
custom_39.29x44.45mm_39.29x44.45mm:
Local: N/A
Width: 1.55in
Length: 1.75in
Bottom: 0.25in
Left: 0.06in
Right: 0.13in
Top: 0.22in
custom_41.32x88.9mm_41.32x88.9mm:
Local: N/A
Width: 1.63in
Length: 3.50in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.23in
custom_46.06x77.81mm_46.06x77.81mm:
Local: N/A
Width: 1.81in
Length: 3.06in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.22in
custom_49.02x77.81mm_49.02x77.81mm:
Local: N/A
Width: 1.93in
Length: 3.06in
Bottom: 0.06in
Left: 0.00in
Right: 0.04in
Top: 0.22in
custom_50.8x59.52mm_50.8x59.52mm:
Local: N/A
Width: 2.00in
Length: 2.34in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.22in
custom_2x3.5in_2x3.5in:
Local: N/A
Width: 2.00in
Length: 3.50in
Bottom: 0.06in
Left: 0.12in
Right: 0.04in
Top: 0.37in
custom_54.02x69.85mm_54.02x69.85mm:
Local: N/A
Width: 2.13in
Length: 2.75in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.22in
custom_54.02x100.84mm_54.02x100.84mm:
Local: N/A
Width: 2.13in
Length: 3.97in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.21in
custom_54.02x279.4mm_54.02x279.4mm:
Local: N/A
Width: 2.13in
Length: 11.00in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.23in
custom_54.02x2709.33mm_54.02x2709.33mm:
Local: N/A
Width: 2.13in
Length: 106.67in
Bottom: 0.24in
Left: 0.06in
Right: 0.07in
Top: 0.22in
custom_54.19x22.27mm_54.19x22.27mm:
Local: N/A
Width: 2.13in
Length: 0.88in
Bottom: 0.06in
Left: 0.00in
Right: 0.04in
Top: 0.06in
custom_2.25x1.25in_2.25x1.25in:
Local: N/A
Width: 2.25in
Length: 1.25in
Bottom: 0.06in
Left: 0.04in
Right: 0.04in
Top: 0.06in
custom_2.25x7in_2.25x7in:
Local: N/A
Width: 2.25in
Length: 7.00in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.22in
custom_58.67x66.04mm_58.67x66.04mm:
Local: N/A
Width: 2.31in
Length: 2.60in
Bottom: 0.24in
Left: 0.06in
Right: 0.07in
Top: 0.23in
custom_58.67x88.9mm_58.67x88.9mm:
Local: N/A
Width: 2.31in
Length: 3.50in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.23in
custom_58.76x101.6mm_58.76x101.6mm:
Local: N/A
Width: 2.31in
Length: 4.00in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.23in
custom_58.76x189.99mm_58.76x189.99mm:
Local: N/A
Width: 2.31in
Length: 7.48in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.22in
custom_58.76x190.5mm_58.76x190.5mm:
Local: N/A
Width: 2.31in
Length: 7.50in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.22in
custom_58.76x266.7mm_58.76x266.7mm:
Local: N/A
Width: 2.31in
Length: 10.50in
Bottom: 0.06in
Left: 0.06in
Right: 0.04in
Top: 0.22in
custom_58.93x88.9mm_58.93x88.9mm:
Local: N/A
Width: 2.32in
Length: 3.50in
Bottom: 0.06in
Left: 0.00in
Right: 0.08in
Top: 0.37in
custom_61.89x102.87mm_61.89x102.87mm:
Local: N/A
Width: 2.44in
Length: 4.05in
Bottom: 0.06in
Left: 0.00in
Right: 0.20in
Top: 0.37in
무슨 일이 일어나고 있으며 보고서의 용지 크기 목록을 얻으려면 어떻게 해야 합니까 lpoptions
? (파싱 결과는 제외 lpoptions
)
감사해요!