Hello Thomas,
Two days and (two nights) down the line ... you drew a bleak picture and
by gaw, it is bleak.
I have designed the till receipts with JasperReports - the prettiest
receipts you've ever seen ;-). I have used JasperReports before on
Windoze and Linux, which had been no problem apart from a few minor
niggles on Linux.
The difference now is that I am not dealing with fixed paper sizes. I
managed to adjust the page height before filling the report. The output
has the correct paper size. But now come the Java printing woes...
Jasper can either
- print (via /java.awt.print.Printable/)
- export to PDF
I really "just" need to print to default printer. Even though the
printer is configured to "variable length" and "Custom paper size",
Jasper/Java print will *always* produce a 11in long receipt. (As though
the page size always defaults to Letter). I have looked through the
Jasper code and am certain that they set the /Page/ height to what I set
it for the document.
The Jasper viewer shows the page in the correct size, PDF output is
correct too. It must fail somewhere between Java and Linux. I also know
that the printer is capapble of dynamic length printing. You can pipe
something to lpr and it will cut at end of doc.
As printing via Jasper, i.e. AWT Print API fails, I tried other routes
via export to PDF.
a) as a Stream into Jipsi (for CUPS), which is based on javax print API.
Same problem - 11in receipt.
b) via javax Print API: lookupDefaultPrintService() (which fails BTW if
you have multiple printers, known bug), SimpleDoc from Stream. Again,
11in receipt. MediaPrintableArea is not IPP conformant and is ignored.
I played around on shell-level:
1) lpr ... receipt.pdf --> 11in page
2) convert receipt.pdf to postscript:
lpr ... receipt.ps produces short receipt. The length information must
be derived from the postscript file (bounding box). Although the length
info must be in the pdf, too, because that's where the .ps came from,
but lpr seems to ignore that.
It seems I have to go down the command line option:
Thomas said:
Tarlika Elisabeth Schmitz wrote:
If you want to circumvent the whole Java printing system, do what has
been done for at least 30 years in Unix applications for printing: Pipe
your document to the line printer spooler lp or lpr (depends on the Unix
version). In Java you can do it with Runtime.exec().
On cmdline level I need to convert PDF to PS and pipe that into lpr.
Sorry, now come the daft questions:
How exactly do I do this? Do I have to write the PDF to disk first?
If you do it manually you need to know the printer specification. Get
the printer manual to understand the printer's language. Or, if
The printer specs are scant - *very* scant. The docs don't give any
examples what command line parameters need to be passed to lpr for
variable length.
We're lucky that we got the docs at all, they'd forgotten to include
them with this version of the driver.
--
Regards/Gruß,
Tarlika Elisabeth Schmitz