0

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.

reto
  • 16,189
  • 7
  • 53
  • 67
pojomx
  • 780
  • 2
  • 11
  • 24

2 Answers2

3

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! :)

Spoke
  • 76
  • 1
  • 6
  • 2
    By the way if you run the app found [here](http://cups4j.org/downloads/cups4j.gui.zip) you can see all of the supported attributes for your printer. – Spoke Sep 25 '12 at 20:06
  • I will choose the answer, can't test, but i think it could work. xD – pojomx Feb 04 '15 at 18:14
0

For me works this

PrintJob printJob = new PrintJob.Builder(printData)
            .pageFormat("10x15mm")
            .build();
Neffi
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 14 '23 at 22:06