CUPS - Cups4j - 定义页面/介质大小

发布于 2024-12-14 06:47:51 字数 195 浏览 6 评论 0原文

我在 Java 应用程序中使用 Cups4j,在 Linux 下,使用热敏打印机,我需要定义介质的尺寸,因此我可以在打印机上使用 80 毫米或 50 毫米的纸卷。

有一个“属性”方法,但我不知道(没有太多信息)如何定义要打印的介质的尺寸。

I am using Cups4j in a java app, under Linux, with a thermal printer, I need to define the size of the media, so I can use 80mm or 50mm paper rolls on the printer.

There is an "attribute" method, but I don't know (there is not really much info) how to define the size of the media to print.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哎呦我呸! 2024-12-21 06:47:51

由于这个问题已经有 10 个月了,我猜你要么在其他地方找到了答案,要么放弃了。

不管怎样,根据我的理解,你必须做这样的事情:

    PrintJob job = new PrintJob.Builder(in).jobName("PrintLabel").userName ("anonymous").copies(1).build();
    HashMap<String, String> printJobAttributes = new HashMap<String, String>();
    printJobAttributes.put("job-attributes", "media:keyword:????_80x50mm");
    job.setAttributes(printJobAttributes );

我现在实际上正在尝试解决同样的问题。我不知道在问号所在的地方使用什么,并且我不确定“媒体”是正确使用的属性。如果您能够找到另一个更完整的答案,请告诉我们! :)

Since this question is 10 months old, I'm guessing you either found an answer somewhere else or gave up.

Anyway, from what I understand you would have to do something like this:

    PrintJob job = new PrintJob.Builder(in).jobName("PrintLabel").userName ("anonymous").copies(1).build();
    HashMap<String, String> printJobAttributes = new HashMap<String, String>();
    printJobAttributes.put("job-attributes", "media:keyword:????_80x50mm");
    job.setAttributes(printJobAttributes );

I'm actually trying to figure the same thing out right now. I'm stuck at what to use where the question marks are, and I'm not sure "media" is the right attribute to use. If you were able to find another more complete answer let us know! :)

韶华倾负 2024-12-21 06:47:51

对我来说这是有效的

PrintJob printJob = new PrintJob.Builder(printData)
            .pageFormat("10x15mm")
            .build();

For me works this

PrintJob printJob = new PrintJob.Builder(printData)
            .pageFormat("10x15mm")
            .build();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文