0

I'm sending RAW data (escape codes) to the printer with the following code:

PrintService pservice = this.getPrintService();
DocPrintJob job = pservice.createPrintJob();
DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
Doc doc = new SimpleDoc(printdata, flavor, null);
job.addPrintJobListener(this);
    try {
        job.print(doc, null);
...

This works correctly in Windows, the printer interprets the escape codes and prints as i would expect.

In Linux (i installed the CUPS version of the driver) when i send the raw data it simply prints an empty page and reports a printing error. The weird thing is that if i send the data using the system lpr command everything works correctly.

Any clues on what could be going wrong?

[note]Feel free to edit my title, i couldn't think of a better one

[edit] This is the error log I get: LOGS

[edit2]Similar thread with a solution i do not really like: Linux printing in java

[edit3] Experimenting with different DocFlavors i came up with new errors:

E [07/Dec/2012:17:45:44 +0100] Unknown directive SystemGroup on line 4 of /etc/cups/cupsd.conf.
E [07/Dec/2012:17:45:44 +0100] Unknown directive JobPrivateAccess on line 85 of /etc/cups/cupsd.conf.
E [07/Dec/2012:17:45:44 +0100] Unknown directive JobPrivateValues on line 86 of /etc/cups/cupsd.conf.
E [07/Dec/2012:17:45:44 +0100] Unknown directive SubscriptionPrivateAccess on line 87 of /etc/cups/cupsd.conf.
E [07/Dec/2012:17:45:44 +0100] Unknown directive SubscriptionPrivateValues on line 88 of /etc/cups/cupsd.conf.
W [07/Dec/2012:17:45:44 +0100] CreateProfile failed: org.freedesktop.ColorManager.AlreadyExists:profile id 'LabelWriter-400-Gray..' already exists
W [07/Dec/2012:17:45:44 +0100] CreateDevice failed: org.freedesktop.ColorManager.AlreadyExists:device id 'cups-LabelWriter-400' already exists

Could this point to a CUPS configuration error?

Community
  • 1
  • 1
Enoon
  • 421
  • 4
  • 17
  • which CUPS driver are you using? anything in CUPS log? i think driver needs to be configured for raw printing otherwise it will do conversion based on mime type – Raber Dec 06 '12 at 13:08
  • I'm using the drivers found here: https://dymo.custhelp.com/app/answers/detail/a_id/101/~/dymo-drivers-and-downloads#lw_linux (i have a Dymo 400). Since i'm a linux newbie, could you point me were to look for the logs? – Enoon Dec 06 '12 at 13:15
  • take look at this http://www.cups.org/documentation.php/doc-1.6/options.html#RAW, the logs should be in /var/log/cups – Raber Dec 06 '12 at 13:34
  • Thanks. I attached the logs to the main post. I read your link; the funny thing is that "cat filename | lpr" works even without using the _-o raw_option. From the log it seems it encounter problems with _Error: /undefined in Q',_ – Enoon Dec 06 '12 at 13:49
  • maybe you could get hold of print job file after cups is finished with it and see what are the contents and if they are different from what you sent, cups spool dir is /var/spool/cups i think but cannot remember where do finished job go – Raber Dec 06 '12 at 14:26
  • I'll do this. In the meantime i went through the logs and it appears (but i may very well be wrong) that CUPS treats it as a postscript file (which would be very wrong), could this be it? – Enoon Dec 06 '12 at 14:44
  • probably, there is a raw mime type 'application/vnd.cups-raw', maybe you can try it – Raber Dec 06 '12 at 15:00
  • How would you suggest to try it in the code? – Enoon Dec 06 '12 at 15:59
  • I suppose you need to play with http://docs.oracle.com/javase/1.4.2/docs/api/javax/print/DocFlavor.html but i never used it :) – Raber Dec 07 '12 at 08:42
  • I'm lost, DocFlavor.BYTE_ARRAY.AUTOSENSE should be the correct one and it works on Windows. – Enoon Dec 07 '12 at 16:10
  • my point was: DocFlavor.BYTE_ARRAY.AUTOSENSE gives mime type of "application/octet-stream", maybe try DocFlavor.BYTE_ARRAY("application/vnd.cups-raw")? – Raber Dec 07 '12 at 16:20
  • I tried but it still gives an error. I'm updating the question with the new log information – Enoon Dec 07 '12 at 16:51
  • The important part is hidden in this comment. http://stackoverflow.com/questions/6228055/linux-printing-in-java#comment7256388_6228055 – tresf Sep 20 '16 at 07:12

0 Answers0